添加项目文件。
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Microsoft Visual Studio Solution File, Format Version 12.00
 | 
				
			||||||
 | 
					# Visual Studio Version 17
 | 
				
			||||||
 | 
					VisualStudioVersion = 17.3.32922.545
 | 
				
			||||||
 | 
					MinimumVisualStudioVersion = 10.0.40219.1
 | 
				
			||||||
 | 
					Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DM_Weight", "DM_Weight\DM_Weight.csproj", "{439FA76B-F874-40DB-BAF2-E3647CD55B10}"
 | 
				
			||||||
 | 
					EndProject
 | 
				
			||||||
 | 
					Global
 | 
				
			||||||
 | 
						GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
				
			||||||
 | 
							Debug|Any CPU = Debug|Any CPU
 | 
				
			||||||
 | 
							Release|Any CPU = Release|Any CPU
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
						GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
						GlobalSection(SolutionProperties) = preSolution
 | 
				
			||||||
 | 
							HideSolutionNode = FALSE
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
						GlobalSection(ExtensibilityGlobals) = postSolution
 | 
				
			||||||
 | 
							SolutionGuid = {E50E8179-1102-41F1-92F5-2905C75898A6}
 | 
				
			||||||
 | 
						EndGlobalSection
 | 
				
			||||||
 | 
					EndGlobal
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,62 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					<configuration>
 | 
				
			||||||
 | 
					  <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=hkcdb_dpc;userid=root;password=root" />
 | 
				
			||||||
 | 
					  </connectionStrings>
 | 
				
			||||||
 | 
						<!--<runtime>
 | 
				
			||||||
 | 
							--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
				
			||||||
 | 
							<legacyUnhandledExceptionPolicy enabled="1"/>
 | 
				
			||||||
 | 
						</runtime>-->
 | 
				
			||||||
 | 
						<appSettings>
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							<!-- 设备id -->
 | 
				
			||||||
 | 
							<add key="machineId" value="DM1" />
 | 
				
			||||||
 | 
							<!--2023/7/13 药房代码 有则写无则空 -->
 | 
				
			||||||
 | 
							<add key="storage" value="" />
 | 
				
			||||||
 | 
							<!-- 登录模式 1单人登录2双人登录 -->
 | 
				
			||||||
 | 
							<add key="loginMode" value="2" />
 | 
				
			||||||
 | 
							<!-- 登录顺序,指定先登录的人的名称有效值,只有在登录模式等于2时才会生效; 发药人:【operator】审核人:【reviewer】 -->
 | 
				
			||||||
 | 
							<add key="firstLogin" value="operator" />
 | 
				
			||||||
 | 
							<!-- 按处方还药或者按取药记录还药 1:处方2:药品-->
 | 
				
			||||||
 | 
							<add key="returnDrugMode" value="1" />
 | 
				
			||||||
 | 
							<!-- 自动退出时间,单位秒,为0时不自动退出 -->
 | 
				
			||||||
 | 
							<add key="autoExit" value="0"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<add key="gridConnectionString" value="MYSQL; Database=hkcdb; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
 | 
				
			||||||
 | 
							<!-- 查询处方是orderNo还是orderGroupNo -->
 | 
				
			||||||
 | 
							<add key="OrderNoName" value="orderNo" />
 | 
				
			||||||
 | 
							<!-- 后门耗材板地址 没有则填写0-->
 | 
				
			||||||
 | 
							<add key="DoorAddr" value="1" />
 | 
				
			||||||
 | 
							<!-- 是否有can总线串口-->
 | 
				
			||||||
 | 
							<add key="CanBusExsit" value="true" />
 | 
				
			||||||
 | 
							<!-- 单支抽屉储物箱有则写地址无则为0-->
 | 
				
			||||||
 | 
							<add key="StorageBoxAddr" value="1" />
 | 
				
			||||||
 | 
							<!-- 抽屉串口使用的协议232或者485 -->
 | 
				
			||||||
 | 
							<add key="DrawerProtocol" value="485" />
 | 
				
			||||||
 | 
							<!-- 抽屉串口的串口号 -->
 | 
				
			||||||
 | 
							<add key="DrawerPortPath" value="COM1" />
 | 
				
			||||||
 | 
							<!-- can总线串口的串口号 -->
 | 
				
			||||||
 | 
							<add key="CanBusPortPath" value="COM6" />
 | 
				
			||||||
 | 
							<!-- 条码枪串口的串口号 -->
 | 
				
			||||||
 | 
							<add key="ScanCodePortPath" value="COM8" />
 | 
				
			||||||
 | 
							<!-- 抽屉串口的串口号 --><!--
 | 
				
			||||||
 | 
							<add key="DrawerPortPath" value="COM11" />
 | 
				
			||||||
 | 
							--><!-- can总线串口的串口号 --><!--
 | 
				
			||||||
 | 
							<add key="CanBusPortPath" value="COM12" />
 | 
				
			||||||
 | 
							--><!-- 条码枪串口的串口号 --><!--
 | 
				
			||||||
 | 
							<add key="ScanPortPath" value="COM7" />-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<!-- 指纹机类型 1:无屏幕;2:有屏幕 -->
 | 
				
			||||||
 | 
							<add  key="machineType" value="2"/>
 | 
				
			||||||
 | 
							<!-- 指纹机号码 -->
 | 
				
			||||||
 | 
							<add  key="machineNumber" value="1"/>
 | 
				
			||||||
 | 
							<!-- 指纹机ip -->
 | 
				
			||||||
 | 
							<add  key="fingerIp" value="192.168.1.201"/>
 | 
				
			||||||
 | 
							<!--一个抽屉对应标签数-->
 | 
				
			||||||
 | 
							<add  key="labelCount" value="2"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						</appSettings>
 | 
				
			||||||
 | 
					</configuration>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					<prism:PrismApplication x:Class="DM_Weight.App"
 | 
				
			||||||
 | 
					             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
 | 
					             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 | 
				
			||||||
 | 
					             xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"
 | 
				
			||||||
 | 
					             d1p1:Ignorable="d"
 | 
				
			||||||
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
				
			||||||
 | 
					             xmlns:local="clr-namespace:DM_Weight"
 | 
				
			||||||
 | 
					             xmlns:prism="http://prismlibrary.com/">
 | 
				
			||||||
 | 
					    <Application.Resources>
 | 
				
			||||||
 | 
					        <ResourceDictionary>
 | 
				
			||||||
 | 
					            <ResourceDictionary.MergedDictionaries>
 | 
				
			||||||
 | 
					                <materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Indigo" SecondaryColor="Cyan" />
 | 
				
			||||||
 | 
					                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            </ResourceDictionary.MergedDictionaries>
 | 
				
			||||||
 | 
					        </ResourceDictionary>
 | 
				
			||||||
 | 
					    </Application.Resources>
 | 
				
			||||||
 | 
					    </prism:PrismApplication>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,252 @@
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util.TabTip;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using DM_Weight.ViewModels;
 | 
				
			||||||
 | 
					using DM_Weight.Views.Dialog;
 | 
				
			||||||
 | 
					using DM_Weight.Views;
 | 
				
			||||||
 | 
					using log4net.Config;
 | 
				
			||||||
 | 
					using Prism.Ioc;
 | 
				
			||||||
 | 
					using Prism.Services.Dialogs;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.ComponentModel;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Data;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Controls;
 | 
				
			||||||
 | 
					using Prism.Unity;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using System.Windows.Interop;
 | 
				
			||||||
 | 
					using System.Windows.Threading;
 | 
				
			||||||
 | 
					using System.Timers;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// Interaction logic for App.xaml
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class App : PrismApplication
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        #region 当前登录用户的发药人信息
 | 
				
			||||||
 | 
					        private static UserList _currentFaUserList=new UserList();
 | 
				
			||||||
 | 
					        public static UserList CurrentFaUserList
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _currentFaUserList;
 | 
				
			||||||
 | 
					            set=> _currentFaUserList = value;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion 当前登录用户的发药人信息
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 当前登录用户的审核人信息
 | 
				
			||||||
 | 
					        private static UserList _currentShenUserList= new UserList();
 | 
				
			||||||
 | 
					        public static UserList CurrentShenUserList
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _currentShenUserList;
 | 
				
			||||||
 | 
					            set => _currentShenUserList = value;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion 当前登录用户的审核人信息
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(App));
 | 
				
			||||||
 | 
					        public App()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //TabTipAutomation.IgnoreHardwareKeyboard = HardwareKeyboardIgnoreOptions.IgnoreAll;
 | 
				
			||||||
 | 
					            //TabTipAutomation.BindTo<TextBox>();
 | 
				
			||||||
 | 
					            //TabTipAutomation.BindTo<PasswordBox>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        protected override Window CreateShell()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //UI线程未捕获异常处理事件
 | 
				
			||||||
 | 
					            this.DispatcherUnhandledException += OnDispatcherUnhandledException;
 | 
				
			||||||
 | 
					            //Task线程内未捕获异常处理事件
 | 
				
			||||||
 | 
					            TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
 | 
				
			||||||
 | 
					            //多线程异常
 | 
				
			||||||
 | 
					            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return Container.Resolve<MainWindow>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Error($"发生错误:{e.Exception.Message}");
 | 
				
			||||||
 | 
					            e.Handled = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            foreach (Exception item in e.Exception.InnerExceptions)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Error($"异常类型:{item.GetType()}{Environment.NewLine}来自:{item.Source}{Environment.NewLine}异常内容:{item.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //将异常标识为已经观察到 
 | 
				
			||||||
 | 
					            e.SetObserved();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Error($"Unhandled exception.{e.ToString()}");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        protected override void InitializeShell(Window shell)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            base.InitializeShell(shell);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        protected override void RegisterTypes(IContainerRegistry containerRegistry)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 注入日志
 | 
				
			||||||
 | 
					            XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterInstance<ILog>(LogManager.GetLogger(""));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 串口工具
 | 
				
			||||||
 | 
					            containerRegistry.RegisterSingleton<PortUtil>();
 | 
				
			||||||
 | 
					            // 指纹机工具
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterSingleton<FingerprintUtil>();
 | 
				
			||||||
 | 
					            // 组态屏工具
 | 
				
			||||||
 | 
					            containerRegistry.RegisterSingleton<ScreenUtil>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            containerRegistry.Register<IDialogService, MaterialDialogService>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 主窗口
 | 
				
			||||||
 | 
					            containerRegistry.Register<MainWindow>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<MainWindow, MainWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 分页
 | 
				
			||||||
 | 
					            //containerRegistry.Register<Pagination>();
 | 
				
			||||||
 | 
					            //containerRegistry.Register<PaginationViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 登录页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<LoginWindow, LoginWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 布局页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<HomeWindow, HomeWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 录入指纹模态框
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<FingerprintDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<FingerprintDialog, FingerprintDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #region 取药
 | 
				
			||||||
 | 
					            // 处方取药页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
 | 
				
			||||||
 | 
					            // 处方取药模态框
 | 
				
			||||||
 | 
					            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<TakeDrugControl, TakeDrugControlViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #region 加药
 | 
				
			||||||
 | 
					            // 自选加药页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<SelfAddWindow, SelfAddWindowViewModel>();
 | 
				
			||||||
 | 
					            // 调拨加药页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<InvoiceInWindow, InvoiceInWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 调拨取药模态框
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<InvoiceAddDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<InvoiceAddDialog, InvoiceAddDialogViewModel>();
 | 
				
			||||||
 | 
					            // 抽屉加药页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<DrawerAddDrugWindow, DrawerAddDrugWindowViewModel>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<AddManunoDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<AddManunoDialog, AddManunoDialogViewModel>();
 | 
				
			||||||
 | 
					            // 自选加药模态框
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<SelfAddDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<SelfAddDialog, SelfAddDialogViewModel>();
 | 
				
			||||||
 | 
					            //多批次抽屉加药
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<AddDrugControl, AddDrugControlViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #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>();
 | 
				
			||||||
 | 
					            // 归还空瓶模态框
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<ReturnEmptyDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<ReturnEmptyDialog, ReturnEmptyDialogViewModel>();
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #region 库存管理
 | 
				
			||||||
 | 
					            // 库存列表页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<StockListWindow, StockListWindowViewModel>();
 | 
				
			||||||
 | 
					            // 库位绑定模态框
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<BindingChannelDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<BindingChannelDialog, BindingChannelDialogViewModel>();
 | 
				
			||||||
 | 
					            // 库位绑定模态框
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<BindingChannelNewDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<BindingChannelNewDialog, BindingChannelNewDialogViewModel>();
 | 
				
			||||||
 | 
					            // 库存盘点页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<CheckStockWindow, CheckStockWindowViewModel>();
 | 
				
			||||||
 | 
					            // 药品列表页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<DrugListWindow, DrugListWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #region 系统设置
 | 
				
			||||||
 | 
					            // 用户管理页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<UserManagerWindow, UserManagerWindowViewModel>();
 | 
				
			||||||
 | 
					            // 编辑用户模态框
 | 
				
			||||||
 | 
					            containerRegistry.RegisterDialog<EditUserDialog>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<EditUserDialog, EditUserDialogViewModel>();
 | 
				
			||||||
 | 
					            // 角色管理页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<RoleManagerWindow, RoleManagerWindowViewModel>();
 | 
				
			||||||
 | 
					            // 系统设置
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<SettingWindow, SettingWindowViewModel>();
 | 
				
			||||||
 | 
					            // 调试页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<DebugWindow, DebugWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 设备记录页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<MachineRecordWindow, MachineRecordWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //交接班
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<ChangeShiftsWindow, ChangeShiftsWindowViewModel>();
 | 
				
			||||||
 | 
					            //交接班记录
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<ChangeShiftsListWindow, ChangeShiftsListWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //交接班
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[assembly: ThemeInfo(
 | 
				
			||||||
 | 
					    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
 | 
				
			||||||
 | 
					                                     //(used if a resource is not found in the page,
 | 
				
			||||||
 | 
					                                     // or application resource dictionaries)
 | 
				
			||||||
 | 
					    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
 | 
				
			||||||
 | 
					                                              //(used if a resource is not found in the page,
 | 
				
			||||||
 | 
					                                              // app, or any theme specific resource dictionaries)
 | 
				
			||||||
 | 
					)]
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,43 @@
 | 
				
			||||||
 | 
					<UserControl x:Class="DM_Weight.Components.pagination.Pagination"
 | 
				
			||||||
 | 
					             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.Components.pagination"
 | 
				
			||||||
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <Grid>
 | 
				
			||||||
 | 
					        <StackPanel Margin="0 6 20 6" HorizontalAlignment="Right" Orientation="Horizontal">
 | 
				
			||||||
 | 
					            <TextBlock x:Name="InfoBlock" Padding="0 0 6 0" VerticalAlignment="Center" />
 | 
				
			||||||
 | 
					            <Button
 | 
				
			||||||
 | 
					                ToolTip="首页"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
				
			||||||
 | 
					                Command="{x:Static local:Pagination.FirstCommand}"
 | 
				
			||||||
 | 
					                Name="First"
 | 
				
			||||||
 | 
					                Content="{materialDesign:PackIcon PageFirst}" />
 | 
				
			||||||
 | 
					            <Button
 | 
				
			||||||
 | 
					                ToolTip="上一页"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
				
			||||||
 | 
					                Command="{x:Static local:Pagination.PrevCommand}"
 | 
				
			||||||
 | 
					                Name="Prve"
 | 
				
			||||||
 | 
					                Content="{materialDesign:PackIcon ChevronLeft}"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <TextBlock x:Name="CurrentPageText" Padding="6 0 6 0" VerticalAlignment="Center" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <Button
 | 
				
			||||||
 | 
					                ToolTip="下一页"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
				
			||||||
 | 
					                Command="{x:Static local:Pagination.NextCommand}"
 | 
				
			||||||
 | 
					                Name="Next"
 | 
				
			||||||
 | 
					                Content="{materialDesign:PackIcon ChevronRight}"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <Button
 | 
				
			||||||
 | 
					                ToolTip="末页"
 | 
				
			||||||
 | 
					                Style="{StaticResource MaterialDesignIconForegroundButton}"
 | 
				
			||||||
 | 
					                Command="{x:Static local:Pagination.EndCommand}"
 | 
				
			||||||
 | 
					                Name="End"
 | 
				
			||||||
 | 
					                Content="{materialDesign:PackIcon PageLast}" />
 | 
				
			||||||
 | 
					        </StackPanel>
 | 
				
			||||||
 | 
					    </Grid>
 | 
				
			||||||
 | 
					</UserControl>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,265 @@
 | 
				
			||||||
 | 
					using NetTaste;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.ComponentModel;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Reflection;
 | 
				
			||||||
 | 
					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.Components.pagination
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// Pagination.xaml 的交互逻辑
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public partial class Pagination : UserControl
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public Pagination()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					            ResetInfoText();
 | 
				
			||||||
 | 
					            ResetCurrentPageText();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        static Pagination()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            InitializeCommands();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static readonly Type _typeofSelf = typeof(Pagination);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static void InitializeCommands()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            FirstCommand = new RoutedCommand("First", _typeofSelf);
 | 
				
			||||||
 | 
					            PrevCommand = new RoutedCommand("Prev", _typeofSelf);
 | 
				
			||||||
 | 
					            NextCommand = new RoutedCommand("Next", _typeofSelf);
 | 
				
			||||||
 | 
					            EndCommand = new RoutedCommand("End", _typeofSelf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            CommandManager.RegisterClassCommandBinding(_typeofSelf,
 | 
				
			||||||
 | 
					                new CommandBinding(FirstCommand, OnFirstComman, OnCanFirstComman));
 | 
				
			||||||
 | 
					            CommandManager.RegisterClassCommandBinding(_typeofSelf,
 | 
				
			||||||
 | 
					                new CommandBinding(PrevCommand, OnPrevCommand, OnCanPrevCommand));
 | 
				
			||||||
 | 
					            CommandManager.RegisterClassCommandBinding(_typeofSelf,
 | 
				
			||||||
 | 
					                new CommandBinding(NextCommand, OnNextCommand, OnCanNextCommand));
 | 
				
			||||||
 | 
					            CommandManager.RegisterClassCommandBinding(_typeofSelf,
 | 
				
			||||||
 | 
					                new CommandBinding(EndCommand, OnEndCommand, OnCanEndCommand));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static RoutedCommand FirstCommand { get; private set; }
 | 
				
			||||||
 | 
					        private static void OnFirstComman(object sender, RoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var ctrl = sender as Pagination;
 | 
				
			||||||
 | 
					            ctrl.CurrentPage = 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static void OnCanFirstComman(object sender, CanExecuteRoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var ctrl = sender as Pagination;
 | 
				
			||||||
 | 
					            e.CanExecute = ctrl.CurrentPage > 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static RoutedCommand PrevCommand { get; private set; }
 | 
				
			||||||
 | 
					        private static void OnPrevCommand(object sender, RoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var ctrl = sender as Pagination;
 | 
				
			||||||
 | 
					            ctrl.CurrentPage--;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static void OnCanPrevCommand(object sender, CanExecuteRoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var ctrl = sender as Pagination;
 | 
				
			||||||
 | 
					            e.CanExecute = ctrl.CurrentPage > 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static RoutedCommand NextCommand { get; private set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static void OnNextCommand(object sender, RoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var ctrl = sender as Pagination;
 | 
				
			||||||
 | 
					            ctrl.CurrentPage++;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static void OnCanNextCommand(object sender, CanExecuteRoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var ctrl = sender as Pagination;
 | 
				
			||||||
 | 
					            e.CanExecute = ctrl.CurrentPage < ctrl.PageCount;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public static RoutedCommand EndCommand { get; private set; }
 | 
				
			||||||
 | 
					        private static void OnEndCommand(object sender, RoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var ctrl = sender as Pagination;
 | 
				
			||||||
 | 
					            ctrl.CurrentPage = ctrl.PageCount;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static void OnCanEndCommand(object sender, CanExecuteRoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var ctrl = sender as Pagination;
 | 
				
			||||||
 | 
					            e.CanExecute = ctrl.CurrentPage < ctrl.PageCount;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 默认当前页码
 | 
				
			||||||
 | 
					        public static int DefaultCurrentPage = 1;
 | 
				
			||||||
 | 
					        // 默认总条数
 | 
				
			||||||
 | 
					        public static int DefaultTotalPages = 0;
 | 
				
			||||||
 | 
					        // 默认每页条数列表
 | 
				
			||||||
 | 
					        public static List<int> DefaultPageSizeList = new List<int> { 10, 20, 50, 100 };
 | 
				
			||||||
 | 
					        // 是否显示页码条数信息
 | 
				
			||||||
 | 
					        public static bool DefaultInfoTextIsEnabel = true;
 | 
				
			||||||
 | 
					        // 默认每页条数
 | 
				
			||||||
 | 
					        public static int DefaultPageSize = 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static readonly DependencyProperty CurrentPageProperty = DependencyProperty
 | 
				
			||||||
 | 
					                .Register("CurrentPage",
 | 
				
			||||||
 | 
					                typeof(int),
 | 
				
			||||||
 | 
					                typeof(Pagination),
 | 
				
			||||||
 | 
					                new FrameworkPropertyMetadata(DefaultCurrentPage, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
 | 
				
			||||||
 | 
					        public static readonly DependencyProperty PageSizeProperty = DependencyProperty
 | 
				
			||||||
 | 
					                .Register("PageSize",
 | 
				
			||||||
 | 
					                typeof(int),
 | 
				
			||||||
 | 
					                typeof(Pagination),
 | 
				
			||||||
 | 
					                new FrameworkPropertyMetadata(DefaultPageSize, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
 | 
				
			||||||
 | 
					        public static readonly DependencyProperty TotalPagesProperty = DependencyProperty
 | 
				
			||||||
 | 
					                .Register("TotalPages",
 | 
				
			||||||
 | 
					                typeof(int),
 | 
				
			||||||
 | 
					                typeof(Pagination),
 | 
				
			||||||
 | 
					                new FrameworkPropertyMetadata(DefaultTotalPages, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnItemsSourceChanged)));
 | 
				
			||||||
 | 
					        public static readonly DependencyProperty InfoTextIsEnabelProperty = DependencyProperty
 | 
				
			||||||
 | 
					                .Register("InfoTextIsEnabel",
 | 
				
			||||||
 | 
					                typeof(bool),
 | 
				
			||||||
 | 
					                typeof(Pagination),
 | 
				
			||||||
 | 
					                new FrameworkPropertyMetadata(DefaultInfoTextIsEnabel, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
 | 
				
			||||||
 | 
					        private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Pagination p = (Pagination)d;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            p.ResetInfoText();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Bindable(true)]
 | 
				
			||||||
 | 
					        [Category("Appearance")]
 | 
				
			||||||
 | 
					        public int CurrentPage
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return (int)GetValue(CurrentPageProperty); }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetValue(CurrentPageProperty, value);
 | 
				
			||||||
 | 
					                if (InfoTextIsEnabel)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ResetInfoText();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                ResetCurrentPageText();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private static void OnCurrentPageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    Pagination p = d as Pagination;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //    if (p != null)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        Console.WriteLine(e.NewValue);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Bindable(true)]
 | 
				
			||||||
 | 
					        [Category("Appearance")]
 | 
				
			||||||
 | 
					        public int PageSize
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return (int)GetValue(PageSizeProperty); }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetValue(PageSizeProperty, value);
 | 
				
			||||||
 | 
					                if (InfoTextIsEnabel)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ResetInfoText();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                ResetCurrentPageText();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Bindable(true)]
 | 
				
			||||||
 | 
					        [Category("Appearance")]
 | 
				
			||||||
 | 
					        public int TotalPages
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return (int)GetValue(TotalPagesProperty); }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            { 
 | 
				
			||||||
 | 
					                SetValue(TotalPagesProperty, value);
 | 
				
			||||||
 | 
					                if (InfoTextIsEnabel)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ResetInfoText();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                ResetCurrentPageText();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool InfoTextIsEnabel
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return (bool)GetValue(InfoTextIsEnabelProperty); }
 | 
				
			||||||
 | 
					            set { SetValue(InfoTextIsEnabelProperty, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int PageCount
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => (int)Math.Ceiling((double)TotalPages / PageSize);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void ResetInfoText()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            this.Dispatcher.BeginInvoke(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (InfoTextIsEnabel)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (TotalPages <= PageSize)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        this.InfoBlock.Text = $"1-{TotalPages}/{TotalPages}";
 | 
				
			||||||
 | 
					                        if (TotalPages == 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            this.InfoBlock.Text = $"0-{TotalPages}/{TotalPages}";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        this.InfoBlock.Text = ((CurrentPage - 1) * PageSize + 1) + "-" + (CurrentPage * PageSize > TotalPages ? TotalPages : CurrentPage * PageSize) + "/" + TotalPages;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                } else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    this.InfoBlock.Visibility = Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void ResetCurrentPageText()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            this.Dispatcher.BeginInvoke(() =>
 | 
				
			||||||
 | 
					            { 
 | 
				
			||||||
 | 
					                this.CurrentPageText.Text = CurrentPage + "";
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,81 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Components.pagination
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class PaginationViewModel: BindableBase, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static readonly DependencyProperty PageSizeProperty = DependencyProperty
 | 
				
			||||||
 | 
					        .Register("CurrentPage",
 | 
				
			||||||
 | 
					                typeof(int),
 | 
				
			||||||
 | 
					                typeof(Pagination),
 | 
				
			||||||
 | 
					                new FrameworkPropertyMetadata(10));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 每页条数
 | 
				
			||||||
 | 
					        private int _pageSize = 10;
 | 
				
			||||||
 | 
					        // 当前页码
 | 
				
			||||||
 | 
					        private int _currentPage = 1;
 | 
				
			||||||
 | 
					        // 总条数
 | 
				
			||||||
 | 
					        private int _totalPages = 0;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public int PageSize { get=> _pageSize;  set => SetProperty(ref _pageSize, value); }
 | 
				
			||||||
 | 
					        public int CurrentPage { get => _currentPage; set => SetProperty(ref _currentPage, value); }
 | 
				
			||||||
 | 
					        public int TotalPages { get => _totalPages; set => SetProperty(ref _totalPages, value); }
 | 
				
			||||||
 | 
					        // 总页数 
 | 
				
			||||||
 | 
					        public int PageCount
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => (int)Math.Ceiling((double)TotalPages/ PageSize);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string InfoText
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => ((CurrentPage - 1) * PageSize + 1) + "-" + (CurrentPage * PageSize > TotalPages ? TotalPages : CurrentPage * PageSize) + "/" + TotalPages;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand ToFirst
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                CurrentPage = 1;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand ToPrve
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                CurrentPage -= 1;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand ToNext
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                CurrentPage += 1;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand ToEnd
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                CurrentPage = PageCount;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,106 @@
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class BoardTypeConverter : IMultiValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int BoardType = int.Parse(value[0].ToString());
 | 
				
			||||||
 | 
					            int DrawerType = int.Parse(value[1].ToString());
 | 
				
			||||||
 | 
					            switch (BoardType)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case 1:
 | 
				
			||||||
 | 
					                    if (DrawerType == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "物理隔断";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if(DrawerType == 2)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "内置回收";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "外置回收";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                case 2:
 | 
				
			||||||
 | 
					                    if (DrawerType == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "单支计数";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (DrawerType == 2)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "计数回收(内置)";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "计数回收(外置)";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                case 3:
 | 
				
			||||||
 | 
					                    if (DrawerType == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "管控药盒";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (DrawerType == 2)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "药盒回收(内置)";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "外置回收";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                case 4:
 | 
				
			||||||
 | 
					                    if (DrawerType == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "冰箱";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (DrawerType == 2)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "内置回收";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "外置回收";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                case 5:
 | 
				
			||||||
 | 
					                    if (DrawerType == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "智能显示";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (DrawerType == 2)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "内置回收";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "外置回收";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                case 6:
 | 
				
			||||||
 | 
					                    if (DrawerType == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "称重计数";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (DrawerType == 2)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "称重回收(内置)";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        return "计数回收(外置)";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return "";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					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 ChangeShiftsStatusConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            bool status = bool.Parse(value.ToString());
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class DrawerSelectConverter : IMultiValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int ButtonDrawerNo = int.Parse(value[0].ToString());
 | 
				
			||||||
 | 
					            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,31 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Drawing;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ForeColorConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if((bool)value)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return "#3ECFED";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return "#808080";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class GroupSumConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        #region 分组组内求和
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var total = 0;
 | 
				
			||||||
 | 
					            // DataGrid分组后对应的组及组内元素CollectionViewGroup.Items 类型是ReadOnlyObservableCollection<object>
 | 
				
			||||||
 | 
					            if (value is ReadOnlyObservableCollection<object> items)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                foreach (var item in items)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var de = item as ChannelStock;
 | 
				
			||||||
 | 
					                    total += de.Quantity;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return "总库存:" + total;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -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.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class InputQuantityConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public bool ReadOnlyValue { get; set; } = true;
 | 
				
			||||||
 | 
					        public bool NotReadOnlyValue { get; set; } = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return int.Parse(value.ToString()) == 2 || int.Parse(value.ToString()) == 6 ? ReadOnlyValue : NotReadOnlyValue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Binding.DoNothing;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,59 @@
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class MachineTypeConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int status = int.Parse(value.ToString());
 | 
				
			||||||
 | 
					            //完成
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("drugNameSearch"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if ((status == 1) || (status == 2))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(parameter.ToString().Equals("saveBtn"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if(status==1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(parameter.ToString().Equals("gridviewColumn"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if(status== 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return 150;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return 0;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return Visibility.Collapsed;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class NullableToEnabelConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public bool NullValue { get; set; } = false;
 | 
				
			||||||
 | 
					        public bool NotNullValue { get; set; } = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return value == null ? NullValue : NotNullValue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Binding.DoNothing;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class OrderStatusConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string strRet = string.Empty;
 | 
				
			||||||
 | 
					            switch (value.ToString())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case "0":
 | 
				
			||||||
 | 
					                    strRet = "待取药";
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                    case "1":
 | 
				
			||||||
 | 
					                    strRet = "已取药";
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                    case "2":
 | 
				
			||||||
 | 
					                    strRet = "已退回";
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                default:
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return strRet;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,56 @@
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class PaginationConverter : IMultiValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string type = values[0].ToString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(type) && "First".Equals(type))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int CurrentPage = int.Parse(values[1].ToString());
 | 
				
			||||||
 | 
					                return CurrentPage > 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(type) && "Prve".Equals(type))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int CurrentPage = int.Parse(values[1].ToString());
 | 
				
			||||||
 | 
					                return CurrentPage > 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(type) && "Next".Equals(type))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int CurrentPage = int.Parse(values[1].ToString());
 | 
				
			||||||
 | 
					                int PageCount = int.Parse(values[2].ToString());
 | 
				
			||||||
 | 
					                return PageCount > CurrentPage;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(type) && "End".Equals(type))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int CurrentPage = int.Parse(values[1].ToString());
 | 
				
			||||||
 | 
					                int PageCount = int.Parse(values[2].ToString());
 | 
				
			||||||
 | 
					                return PageCount > CurrentPage;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(type) && "InfoText".Equals(type))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int CurrentPage = int.Parse(values[1].ToString());
 | 
				
			||||||
 | 
					                int PageCount = int.Parse(values[2].ToString());
 | 
				
			||||||
 | 
					                int PageSize = int.Parse(values[3].ToString());
 | 
				
			||||||
 | 
					                int TotalPages = int.Parse(values[4].ToString());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return ((CurrentPage - 1) * PageSize + 1) + "-" + (CurrentPage * PageSize > TotalPages ? TotalPages : CurrentPage * PageSize) + "/" + TotalPages; ;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class QuantityCountConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public bool IsEnabled { get; set; } = true;
 | 
				
			||||||
 | 
					        public bool NotIsEnabled { get; set; } = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if ((int)value> 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,30 @@
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ShiftsStateConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if(value.ToString().Equals("1"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return "已交班";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return "未交班";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,85 @@
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class StatusConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int status = int.Parse(value.ToString());
 | 
				
			||||||
 | 
					            //完成
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("CompleteBtn"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status == 3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //关闭
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("CloseBtn"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status > 0 && status < 3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("opearBtnLoading"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status > 0 && status < 3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //取药
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("opearBtnVisible"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status < 3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //取消
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("CancelBtn"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return Visibility.Collapsed;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public sealed class MessageAttribute : Attribute
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public MessageAttribute()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public MessageAttribute(int value)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,128 @@
 | 
				
			||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <OutputType>WinExe</OutputType>
 | 
				
			||||||
 | 
					    <TargetFramework>net6.0-windows</TargetFramework>
 | 
				
			||||||
 | 
					    <Nullable>enable</Nullable>
 | 
				
			||||||
 | 
					    <UseWPF>true</UseWPF>
 | 
				
			||||||
 | 
					    <PackageIcon></PackageIcon>
 | 
				
			||||||
 | 
					    <Product>毒麻管理程序</Product>
 | 
				
			||||||
 | 
					    <ApplicationIcon>Images\favicon.ico</ApplicationIcon>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<ItemGroup>
 | 
				
			||||||
 | 
							<None Remove="Images\body-bg.jpg" />
 | 
				
			||||||
 | 
							<None Remove="Images\box-16.jpg" />
 | 
				
			||||||
 | 
							<None Remove="Images\box.png" />
 | 
				
			||||||
 | 
							<None Remove="Images\favicon.ico" />
 | 
				
			||||||
 | 
							<None Remove="Images\finger-bg-r.png" />
 | 
				
			||||||
 | 
							<None Remove="Images\logo.png" />
 | 
				
			||||||
 | 
							<None Remove="Images\TbExit.png" />
 | 
				
			||||||
 | 
							<None Remove="Images\TbJiay.png" />
 | 
				
			||||||
 | 
							<None Remove="Images\TbKuc.png" />
 | 
				
			||||||
 | 
							<None Remove="Images\TbQyao.png" />
 | 
				
			||||||
 | 
							<None Remove="Images\TbSet.png" />
 | 
				
			||||||
 | 
							<None Remove="Images\TbTuiy.png" />
 | 
				
			||||||
 | 
						</ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <COMReference Include="zkemkeeper">
 | 
				
			||||||
 | 
					      <WrapperTool>tlbimp</WrapperTool>
 | 
				
			||||||
 | 
					      <VersionMinor>0</VersionMinor>
 | 
				
			||||||
 | 
					      <VersionMajor>1</VersionMajor>
 | 
				
			||||||
 | 
					      <Guid>fe9ded34-e159-408e-8490-b720a5e632c7</Guid>
 | 
				
			||||||
 | 
					      <Lcid>0</Lcid>
 | 
				
			||||||
 | 
					      <Isolated>false</Isolated>
 | 
				
			||||||
 | 
					      <EmbedInteropTypes>False</EmbedInteropTypes>
 | 
				
			||||||
 | 
					    </COMReference>
 | 
				
			||||||
 | 
					    <COMReference Include="gregn6Lib">
 | 
				
			||||||
 | 
					      <WrapperTool>tlbimp</WrapperTool>
 | 
				
			||||||
 | 
					      <VersionMinor>0</VersionMinor>
 | 
				
			||||||
 | 
					      <VersionMajor>6</VersionMajor>
 | 
				
			||||||
 | 
					      <Guid>4018f953-1bfe-441e-8a04-dc8ba1ff060e</Guid>
 | 
				
			||||||
 | 
					      <Lcid>0</Lcid>
 | 
				
			||||||
 | 
					      <Isolated>false</Isolated>
 | 
				
			||||||
 | 
					      <EmbedInteropTypes>False</EmbedInteropTypes>
 | 
				
			||||||
 | 
					    </COMReference>
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Content Include="Images\favicon.ico" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
						<Resource Include="Images\body-bg.jpg" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\box-16.jpg" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\box.png" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\favicon.ico" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\finger-bg-r.png" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\logo.png" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\TbExit.png" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\TbJiay.png" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\TbKuc.png" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\TbQyao.png" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\TbSet.png" />
 | 
				
			||||||
 | 
					    <Resource Include="Images\TbTuiy.png" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="log4net" Version="2.0.15" />
 | 
				
			||||||
 | 
					    <PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
 | 
				
			||||||
 | 
					    <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
 | 
				
			||||||
 | 
					    <PackageReference Include="Prism.Unity" Version="8.1.97" />
 | 
				
			||||||
 | 
					    <PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
 | 
				
			||||||
 | 
					    <PackageReference Include="SuperSimpleTcp" Version="3.0.10" />
 | 
				
			||||||
 | 
					    <PackageReference Include="System.Drawing.Common" Version="7.0.0" />
 | 
				
			||||||
 | 
					    <PackageReference Include="System.IO.Ports" Version="7.0.0" />
 | 
				
			||||||
 | 
					    <PackageReference Include="System.Management" Version="7.0.1" />
 | 
				
			||||||
 | 
					    <PackageReference Include="System.Reactive" Version="5.0.0" />
 | 
				
			||||||
 | 
					    <PackageReference Include="System.Speech" Version="7.0.0" />
 | 
				
			||||||
 | 
					    <PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <ApplicationDefinition Update="App.xaml">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </ApplicationDefinition>
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <None Update="App.config">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="log4net.config">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\changeShifts_temp.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\account_book_temp.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\changeShifts_temp.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\machine_log_check.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\machine_log_return.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\machine_log_add.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\machine_log_take.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\stock_template.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Page Update="Views\Dialog\InvoiceTakeDialog.xaml">
 | 
				
			||||||
 | 
					      <XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
 | 
				
			||||||
 | 
					    </Page>
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,174 @@
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Microsoft.Data.SqlClient.Server;
 | 
				
			||||||
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					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.msg;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using zkemkeeper;
 | 
				
			||||||
 | 
					namespace DM_Weight.Finger
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class FingerprintUtil
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
 | 
				
			||||||
 | 
					        public zkemkeeper.CZKEMClass axCZKEM1; //= new zkemkeeper.CZKEMClass();
 | 
				
			||||||
 | 
					        public bool bIsConnected = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string fingerIp = ConfigurationManager.AppSettings["fingerIp"].ToString();
 | 
				
			||||||
 | 
					        private int fingerPort = 4370;
 | 
				
			||||||
 | 
					        private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"].ToString());
 | 
				
			||||||
 | 
					        private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"].ToString());
 | 
				
			||||||
 | 
					        private readonly IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public FingerprintUtil(IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					            logger.Info($"进入构造器,开始连接指纹机");
 | 
				
			||||||
 | 
					            Task.Run(() =>
 | 
				
			||||||
 | 
					           {
 | 
				
			||||||
 | 
					               ConnectionMain();
 | 
				
			||||||
 | 
					           });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void ConnectionMain()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                axCZKEM1 = new CZKEMClass();
 | 
				
			||||||
 | 
					                bIsConnected = axCZKEM1.Connect_Net(fingerIp, fingerPort);
 | 
				
			||||||
 | 
					                logger.Info($"连接指纹机,IP:{fingerIp},端口:{fingerPort},机器号:{machineNumber},连接结果:{bIsConnected}");
 | 
				
			||||||
 | 
					                if (bIsConnected)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (axCZKEM1.RegEvent(machineNumber, 65535))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
 | 
				
			||||||
 | 
					                        //this.axCZKEM1.OnEnrollFinger += new zkemkeeper._IZKEMEvents_OnEnrollFingerEventHandler(axCZKEM1_OnEnrollFinger);
 | 
				
			||||||
 | 
					                        this.axCZKEM1.OnEnrollFingerEx += new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<FingerprintEvent>().Publish(new FingerprintMsg()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "CONNECT",
 | 
				
			||||||
 | 
					                    Result = bIsConnected,
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch(Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"连接指纹机异常{ex.Message.ToString()}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //If your fingerprint(or your card) passes the verification,this event will be triggered
 | 
				
			||||||
 | 
					        private void axCZKEM1_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            FingerprintMsg message = new FingerprintMsg()
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Message = "LOGIN",
 | 
				
			||||||
 | 
					                Id = Convert.ToInt32(sEnrollNumber),
 | 
				
			||||||
 | 
					                VerifyMethod = iVerifyMethod
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            logger.Info($"触发用户验证通过事件,用户id:{sEnrollNumber}验证方式:{iVerifyMethod}");
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Publish(message);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //When you are enrolling your finger,this event will be triggered.
 | 
				
			||||||
 | 
					        private void axCZKEM1_OnEnrollFinger(int iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            FingerprintMsg message = new FingerprintMsg()
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Message = "INS_FINGER",
 | 
				
			||||||
 | 
					                Id = iEnrollNumber,
 | 
				
			||||||
 | 
					                FingerIndex = iFingerIndex
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            axCZKEM1.StartIdentify();
 | 
				
			||||||
 | 
					            axCZKEM1.RefreshData(1);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            logger.Info($"触发用户登记指纹事件,用户id:{iEnrollNumber}指纹索引:{iFingerIndex}登记结果:{(iActionResult == 0)}");
 | 
				
			||||||
 | 
					            message.Result = (iActionResult == 0);
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Publish(message);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void axCZKEM1_OnEnrollFingerEx(string iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            FingerprintMsg message = new FingerprintMsg()
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Message = "INS_FINGER",
 | 
				
			||||||
 | 
					                Id = Convert.ToInt32(iEnrollNumber),
 | 
				
			||||||
 | 
					                FingerIndex = iFingerIndex
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            axCZKEM1.StartIdentify();
 | 
				
			||||||
 | 
					            axCZKEM1.RefreshData(1);
 | 
				
			||||||
 | 
					            logger.Info($"触发用户登记指纹事件1,用户id:{iEnrollNumber}指纹索引:{iFingerIndex}登记结果:{(iActionResult == 0)}");
 | 
				
			||||||
 | 
					            message.Result = (iActionResult == 0);
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Publish(message);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * 删除用户
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        public bool DelUser(int Id)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            bool result = false;
 | 
				
			||||||
 | 
					            axCZKEM1.EnableDevice(machineNumber, false);
 | 
				
			||||||
 | 
					            if (machineType == 1)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                result = axCZKEM1.DeleteEnrollData(machineNumber, Id, machineNumber, 12);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                result = axCZKEM1.SSR_DeleteEnrollData(machineNumber, Id.ToString(), 12);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            axCZKEM1.RefreshData(machineNumber);
 | 
				
			||||||
 | 
					            axCZKEM1.EnableDevice(machineNumber, true);
 | 
				
			||||||
 | 
					            return result;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * 添加或修改用户
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        public bool SaveUser(UserList User)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            bool result = false;
 | 
				
			||||||
 | 
					            axCZKEM1.SetStrCardNumber(User.UserBarcode);
 | 
				
			||||||
 | 
					            if (machineType == 1)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                result = axCZKEM1.SetUserInfo(machineNumber, User.Id, User.Nickname, "123456", 0, true);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                result = axCZKEM1.SSR_SetUserInfo(machineNumber, User.Id.ToString(), User.Nickname, "123456", 0, true);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return result;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * 添加或修改用户指纹
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        public bool SaveFingerprint(int Id, int FingerIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            bool result = false;
 | 
				
			||||||
 | 
					            // 取消其他操作
 | 
				
			||||||
 | 
					            bool res2 = axCZKEM1.CancelOperation();
 | 
				
			||||||
 | 
					            // 删除源指纹
 | 
				
			||||||
 | 
					            bool res = axCZKEM1.DelUserTmp(machineNumber, Id, FingerIndex);
 | 
				
			||||||
 | 
					            // 添加新指纹
 | 
				
			||||||
 | 
					            result = axCZKEM1.StartEnrollEx(Id.ToString(), FingerIndex, 3);
 | 
				
			||||||
 | 
					            return result;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
		 After Width: | Height: | Size: 5.5 KiB  | 
| 
		 After Width: | Height: | Size: 5.4 KiB  | 
| 
		 After Width: | Height: | Size: 20 KiB  | 
| 
		 After Width: | Height: | Size: 5.6 KiB  | 
| 
		 After Width: | Height: | Size: 5.4 KiB  | 
| 
		 After Width: | Height: | Size: 5.6 KiB  | 
| 
		 After Width: | Height: | Size: 19 KiB  | 
| 
		 After Width: | Height: | Size: 18 KiB  | 
| 
		 After Width: | Height: | Size: 5.5 KiB  | 
| 
		 After Width: | Height: | Size: 264 KiB  | 
| 
		 After Width: | Height: | Size: 53 KiB  | 
| 
		 After Width: | Height: | Size: 3.6 KiB  | 
| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class AddChannelStockManuNo
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        //是否选中
 | 
				
			||||||
 | 
					        public bool ItemIsChecked { get; set; }
 | 
				
			||||||
 | 
					        //抽屉号
 | 
				
			||||||
 | 
					        public string RowNo { get; set; }
 | 
				
			||||||
 | 
					        //库位号
 | 
				
			||||||
 | 
					        public string ColNo { get; set; }
 | 
				
			||||||
 | 
					        //药品名称
 | 
				
			||||||
 | 
					        public string DrugName { get; set; }
 | 
				
			||||||
 | 
					        //规格
 | 
				
			||||||
 | 
					        public string DrugSpec { get; set; }
 | 
				
			||||||
 | 
					        //批次
 | 
				
			||||||
 | 
					        public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					        //效期
 | 
				
			||||||
 | 
					        public string EffDate { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,196 @@
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("channel_list")]
 | 
				
			||||||
 | 
					    public class ChannelList : BindableBase
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "chnguid", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public string Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "row_no")]
 | 
				
			||||||
 | 
					        public int DrawerNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "col_no")]
 | 
				
			||||||
 | 
					        public int ColNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "pos_no")]
 | 
				
			||||||
 | 
					        public int PosNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ///// <summary>
 | 
				
			||||||
 | 
					        /////  
 | 
				
			||||||
 | 
					        ///// 默认值: NULL
 | 
				
			||||||
 | 
					        /////</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
 | 
					        //public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					        ///// <summary>
 | 
				
			||||||
 | 
					        /////  
 | 
				
			||||||
 | 
					        ///// 默认值: NULL
 | 
				
			||||||
 | 
					        /////</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "eff_date")]
 | 
				
			||||||
 | 
					        //public string EffDate { get; set; }
 | 
				
			||||||
 | 
					        ///// <summary>
 | 
				
			||||||
 | 
					        /////  
 | 
				
			||||||
 | 
					        ///// 默认值: NULL
 | 
				
			||||||
 | 
					        /////</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "quantity")]
 | 
				
			||||||
 | 
					        //public int Quantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 1
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drawer_type")]
 | 
				
			||||||
 | 
					        public int DrawerType { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 1
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "board_type")]
 | 
				
			||||||
 | 
					        public int BoardType { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 1
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "state")]
 | 
				
			||||||
 | 
					        public int? State { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public bool IsSelected { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public InOutInvoice Invoice { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public string Location
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => DrawerNo + "-" + ColNo;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //private int _addQuantity = 0;
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public int AddQuantity
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _addQuantity;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        SetProperty(ref _addQuantity, value);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private int _takeQuantity = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public int TakeQuantity
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _takeQuantity;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        if (value > Quantity)
 | 
				
			||||||
 | 
					        //        {
 | 
				
			||||||
 | 
					        //            throw new ArgumentException("取药数量不能大于库存");
 | 
				
			||||||
 | 
					        //        }
 | 
				
			||||||
 | 
					        //        SetProperty(ref _takeQuantity, value);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        //private int _returnQuantity = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public int ReturnQuantity
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _returnQuantity;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        SetProperty(ref _returnQuantity, value);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private int _checkQuantity = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public int CheckQuantity
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _checkQuantity;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        if (value < 0)
 | 
				
			||||||
 | 
					        //        {
 | 
				
			||||||
 | 
					        //            throw new ArgumentException("盘点数量不能是负数");
 | 
				
			||||||
 | 
					        //        }
 | 
				
			||||||
 | 
					        //        SetProperty(ref _checkQuantity, value);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public int? CanReturnQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DrugInfo? _DrugInfo;
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
 | 
				
			||||||
 | 
					        public DrugInfo Drug { get => _DrugInfo; set => SetProperty(ref _DrugInfo, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public int process { get; set; } = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DrugManuNo? _drugManuNo;
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public DrugManuNo? drugManuNo { get => _drugManuNo; set => SetProperty(ref _drugManuNo, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock>? _channelStocks;
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToMany, nameof(ChannelStock.Chnguid))]
 | 
				
			||||||
 | 
					        public List<ChannelStock> channelStocks { get => _channelStocks; set => SetProperty(ref _channelStocks, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DelegateCommand<ChannelList> _addManunoCommand;
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public DelegateCommand<ChannelList> AddManunoCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (_addManunoCommand == null)
 | 
				
			||||||
 | 
					                    _addManunoCommand = new DelegateCommand<ChannelList>(o => DoDelete(o));
 | 
				
			||||||
 | 
					                return _addManunoCommand;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DoDelete(ChannelList parameter)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,197 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using Oracle.ManagedDataAccess.Types;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 
 | 
				
			||||||
 | 
					    ///</summary>
 | 
				
			||||||
 | 
					    [Serializable]
 | 
				
			||||||
 | 
					    [SugarTable("channel_stock")]
 | 
				
			||||||
 | 
					    public class ChannelStock : BindableBase
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "chsguid", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public string Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName ="chnguid")]
 | 
				
			||||||
 | 
					        public string Chnguid { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "row_no")]
 | 
				
			||||||
 | 
					        public int DrawerNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "col_no")]
 | 
				
			||||||
 | 
					        public int ColNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "pos_no")]
 | 
				
			||||||
 | 
					        public int PosNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
 | 
					        public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "eff_date")]
 | 
				
			||||||
 | 
					        public string EffDate { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "quantity")]
 | 
				
			||||||
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 1
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drawer_type")]
 | 
				
			||||||
 | 
					        public int DrawerType { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 1
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "board_type")]
 | 
				
			||||||
 | 
					        public int BoardType { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 1
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "state")]
 | 
				
			||||||
 | 
					        public int? State { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public bool IsSelected { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public InOutInvoice Invoice { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public string Location
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => DrawerNo + "-" + ColNo;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private int _addQuantity = 0;
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int AddQuantity
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _addQuantity;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _addQuantity, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _takeQuantity = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int TakeQuantity
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _takeQuantity;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (value > Quantity)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    throw new ArgumentException("取药数量不能大于库存");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                SetProperty(ref _takeQuantity, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //private string _tipMessage=string.Empty;
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public string TipMessage
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _tipMessage;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        SetProperty(ref _tipMessage, value);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        private int _returnQuantity = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int ReturnQuantity
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _returnQuantity;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _returnQuantity, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _checkQuantity = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int CheckQuantity
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _checkQuantity;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (value < 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    throw new ArgumentException("盘点数量不能是负数");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                SetProperty(ref _checkQuantity, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int? CanReturnQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DrugInfo? _DrugInfo;
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
 | 
				
			||||||
 | 
					        public DrugInfo DrugInfo { get => _DrugInfo; set => SetProperty(ref _DrugInfo, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int process { get; set; } = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DrugManuNo? _drugManuNo;
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public DrugManuNo? drugManuNo { get => _drugManuNo; set => SetProperty(ref _drugManuNo, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private string _manuNoEffDate;
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public string ManuNoEffDate { get => _manuNoEffDate; set => SetProperty(ref _manuNoEffDate, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ChannelList? _channelList;
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(Chnguid))]
 | 
				
			||||||
 | 
					        public ChannelList ChannelLst { get => _channelList; set => SetProperty(ref _channelList, value); }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,89 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 
 | 
				
			||||||
 | 
					    ///</summary>
 | 
				
			||||||
 | 
					    [SugarTable("drug_info")]
 | 
				
			||||||
 | 
					    public class DrugInfo
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "pharmacy")]
 | 
				
			||||||
 | 
					        //public string Pharmacy { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// ҩƷID 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// ƴ 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "py_code")]
 | 
				
			||||||
 | 
					        public string PyCode { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "BD_code")]
 | 
				
			||||||
 | 
					        //public string BdCode { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// ҩƷ 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_barcode")]
 | 
				
			||||||
 | 
					        public string DrugBarcode { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// ҩƷ<D2A9><C6B7><EFBFBD><EFBFBD> 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_name")]
 | 
				
			||||||
 | 
					        public string DrugName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_brand_name")]
 | 
				
			||||||
 | 
					        public string DrugBrandname { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// ҩƷ<D2A9><C6B7><EFBFBD> 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_spec")]
 | 
				
			||||||
 | 
					        public string DrugSpec { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// <20><><EFBFBD><EFBFBD> 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "dosage")]
 | 
				
			||||||
 | 
					        public string Dosage { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// <20><>װ<EFBFBD><D7B0>λ 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "pack_unit")]
 | 
				
			||||||
 | 
					        public string PackUnit { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manufactory")]
 | 
				
			||||||
 | 
					        public string Manufactory { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// <20><><EFBFBD>ҩ<EFBFBD><D2A9> 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "max_stock")]
 | 
				
			||||||
 | 
					        public int? MaxStock { get; set; }
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore=true)]
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToMany, nameof(ChannelStock.DrugId), nameof(DrugId))]//BookA表中的studenId
 | 
				
			||||||
 | 
					        public List<ChannelStock> channelStocks { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToMany, nameof(DrugManuNo.DrugId))]//BookA表中的studenId
 | 
				
			||||||
 | 
					        public List<DrugManuNo>? DrugManuNos { get; set; }
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int? StockQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public string drug_name_spec { get; set; }
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "drug_name_spec")]
 | 
				
			||||||
 | 
					        //public string Name { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,39 @@
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("drug_manu_no")]
 | 
				
			||||||
 | 
					    public class DrugManuNo:BindableBase
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private string _id;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "dmnguid", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public string Id { get=>_id; set=>SetProperty(ref _id,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _drugId;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get=>_drugId; set=>SetProperty(ref _drugId,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _manuNo;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
 | 
					        public string ManuNo { get=>_manuNo; set=>SetProperty(ref _manuNo,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _manuDate;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_date")]
 | 
				
			||||||
 | 
					        public string ManuDate { get=> _manuDate; set=>SetProperty(ref _manuDate,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _effDate;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "eff_date")]
 | 
				
			||||||
 | 
					        public string EffDate { get=>_effDate; set=>SetProperty(ref _effDate,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private string _manuNoEffDate;
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        //public string ManuNoEffDate { get => _manuNoEffDate; set => SetProperty(ref _manuNoEffDate, value); }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,45 @@
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    //交接班表
 | 
				
			||||||
 | 
					    [SugarTable("hkc_changeshifts")]
 | 
				
			||||||
 | 
					    public class HkcChangeShifts:BindableBase
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id",IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "optDate")]
 | 
				
			||||||
 | 
					        public DateTime? OptDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "FromOperator")]
 | 
				
			||||||
 | 
					        public string FromOperator { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "FromRviewer")]
 | 
				
			||||||
 | 
					        public string FromRviewer { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ToOperator")]
 | 
				
			||||||
 | 
					        public string ToOperator { get;set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ToReviewer")]
 | 
				
			||||||
 | 
					        public string ToReviewer { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ToDate")]
 | 
				
			||||||
 | 
					        public DateTime? ToDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "State")]
 | 
				
			||||||
 | 
					        public string State { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "optState")]
 | 
				
			||||||
 | 
					        public string OptState { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string Machineid { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,149 @@
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Reactive;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("in_out_invoice")]
 | 
				
			||||||
 | 
					    public class InOutInvoice
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键(序号)       
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity =true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "in_pharmacy_id")]
 | 
				
			||||||
 | 
					        public string InPharmacyId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "out_pharmacy_id")]
 | 
				
			||||||
 | 
					        public string OutPharmacyId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 库存管理单位(入库单位代码) 
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "storage")]
 | 
				
			||||||
 | 
					        public string storage { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         /// <summary>
 | 
				
			||||||
 | 
					         /// 单据号
 | 
				
			||||||
 | 
					         /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "invoice_no")]
 | 
				
			||||||
 | 
					        public string InvoiceNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "invoice_date")]
 | 
				
			||||||
 | 
					        public string InvoiceDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
 | 
				
			||||||
 | 
					        public DrugInfo DrugInfo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品规格
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_spec")]
 | 
				
			||||||
 | 
					        public string DrugSpec { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 计算单位
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "units")]
 | 
				
			||||||
 | 
					        public string Units { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 厂商标识
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "firm_id")]
 | 
				
			||||||
 | 
					        public string FirmId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 包装规格(反映药品含量及包装信息,如0.25g*30)   
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "package_spec")]
 | 
				
			||||||
 | 
					        public string PackageSpec { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 数量(以包装单位所计的数量)      
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "quantity")]
 | 
				
			||||||
 | 
					        public int quantity { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 计量单位,可使用任一级管理上方便的包装
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "package_units")]
 | 
				
			||||||
 | 
					        public string PackageUnits { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品批次
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_manu_no")]
 | 
				
			||||||
 | 
					        public string DrugManuNo { get; set; }
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 创建时间(入库日期)
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "create_time")]
 | 
				
			||||||
 | 
					        public DateTime CreateTime { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 1.请领入库 0.其它
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "type")]
 | 
				
			||||||
 | 
					        public int Type { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 类型描述
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "type_describe")]
 | 
				
			||||||
 | 
					        public string TypeDescribe { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 供货方
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "supplier")]
 | 
				
			||||||
 | 
					        public string Supplier { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 操作人
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operator")]
 | 
				
			||||||
 | 
					        public string Operator { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 存放库房
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "sub_storage")]
 | 
				
			||||||
 | 
					        public string SubStorage { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 备注
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "memos")]
 | 
				
			||||||
 | 
					        public string Memos { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "status")]
 | 
				
			||||||
 | 
					        public int Status { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_eff_date")]
 | 
				
			||||||
 | 
					        public string DrugEffDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "his_id")]
 | 
				
			||||||
 | 
					        public string HisId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "cancel_flag")]
 | 
				
			||||||
 | 
					        public int CancelFlag { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [Serializable]
 | 
				
			||||||
 | 
					    public class Invoice
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string InvoiceNo { get; set; }
 | 
				
			||||||
 | 
					        public string InvoiceDate { get; set; }
 | 
				
			||||||
 | 
					        public int Count { get; set; }
 | 
				
			||||||
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					        public int Status { get; set; }
 | 
				
			||||||
 | 
					        public string PharmacyName1 { get; set; }
 | 
				
			||||||
 | 
					        public string PharmacyName2 { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,147 @@
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Security.Principal;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("dm_machine_record")]
 | 
				
			||||||
 | 
					    public class MachineRecord
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 设备id 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品id 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
 | 
				
			||||||
 | 
					        public DrugInfo DrugInfo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 数量 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "quantity")]
 | 
				
			||||||
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "stock_quantity")]
 | 
				
			||||||
 | 
					        public int? StockQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "check_quantity")]
 | 
				
			||||||
 | 
					        public int? CheckQuantity { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 批号 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
 | 
					        public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 操作人id 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operator")]
 | 
				
			||||||
 | 
					        public int? Operator { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(Operator))]
 | 
				
			||||||
 | 
					        public UserList User { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 审核人id 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "reviewer")]
 | 
				
			||||||
 | 
					        public int? Reviewer { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 操作时间 
 | 
				
			||||||
 | 
					        /// 默认值: CURRENT_TIMESTAMP
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operation_time")]
 | 
				
			||||||
 | 
					        public DateTime OperationTime { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 效期 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "eff_date")]
 | 
				
			||||||
 | 
					        public DateTime? EffDate { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 出库入库类型(1入库2出库31还药32还空瓶) 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "type")]
 | 
				
			||||||
 | 
					        public int Type { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 出入库调拨单id 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "invoice_id")]
 | 
				
			||||||
 | 
					        public string InvoiceId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 列号 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "col_no")]
 | 
				
			||||||
 | 
					        public int ColNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 抽屉号 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drawer_no")]
 | 
				
			||||||
 | 
					        public int DrawerNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 取药科室 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "department_id")]
 | 
				
			||||||
 | 
					        public string DepartmentId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 是否已经退药(0:没有1:还了部分2:完成) 
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "status", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
 | 
					        public int Status { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 退药量 
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "return_quantity1", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
 | 
					        public int ReturnQuantity1 { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 退空瓶量 
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
 | 
					        public int ReturnQuantity2 { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 取药记录id 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "get_id")]
 | 
				
			||||||
 | 
					        public int? GetId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 是否已经销毁 
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "is_destroy", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
 | 
					        public int? IsDestroy { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int CanReturnQuantity
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => Quantity - ReturnQuantity1 - ReturnQuantity2;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public bool IsSelected { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品对应批号库存
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manunoQuantity")]
 | 
				
			||||||
 | 
					        public int? ManunoQuantity { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,131 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 
 | 
				
			||||||
 | 
					    ///</summary>
 | 
				
			||||||
 | 
					    [SugarTable("order_detail")]
 | 
				
			||||||
 | 
					    public class OrderDetail
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "order_id")]
 | 
				
			||||||
 | 
					        //public int? OrderId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_id")]
 | 
				
			||||||
 | 
					        public string PatientId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "order_no")]
 | 
				
			||||||
 | 
					        public string OrderNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "charge_date")]
 | 
				
			||||||
 | 
					        public DateTime ChargeDate { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "serial_no")]
 | 
				
			||||||
 | 
					        //public int? SerialNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
 | 
				
			||||||
 | 
					        public DrugInfo DrugInfo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "quantity")]
 | 
				
			||||||
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "order_unit")]
 | 
				
			||||||
 | 
					        public string OrderUnit { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 1
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "unit_convercoef")]
 | 
				
			||||||
 | 
					        public int? UnitConvercoef { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "set_manu_no")]
 | 
				
			||||||
 | 
					        public string SetManuNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "set_eff_date")]
 | 
				
			||||||
 | 
					        public string SetEffDate { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "price")]
 | 
				
			||||||
 | 
					        //public string Price { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "total_price")]
 | 
				
			||||||
 | 
					        //public string TotalPrice { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "use_discrip")]
 | 
				
			||||||
 | 
					        public string UseDiscrip { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "use_frequ")]
 | 
				
			||||||
 | 
					        public string UseFrequ { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "use_once")]
 | 
				
			||||||
 | 
					        public string UseOnce { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "use_by")]
 | 
				
			||||||
 | 
					        public string UseBy { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: '0'
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "use_self")]
 | 
				
			||||||
 | 
					        public string UseSelf { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "use_dosage")]
 | 
				
			||||||
 | 
					        public string UseDosage { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,32 @@
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("hkc_order_finish")] 
 | 
				
			||||||
 | 
					    public class OrderFinish
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "pharmacy")]
 | 
				
			||||||
 | 
					        public string Pharmacy { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_id")]
 | 
				
			||||||
 | 
					        public string PatientId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "order_no")]
 | 
				
			||||||
 | 
					        public string OrderNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "state")]
 | 
				
			||||||
 | 
					        public int State { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operator")]
 | 
				
			||||||
 | 
					        public string Operator { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,192 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 
 | 
				
			||||||
 | 
					    ///</summary>
 | 
				
			||||||
 | 
					    [SugarTable("order_info")]
 | 
				
			||||||
 | 
					    public class OrderInfo
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "order_id", IsPrimaryKey = true, IsIdentity = true)]
 | 
				
			||||||
 | 
					        public int OrderId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "pharmacy")]
 | 
				
			||||||
 | 
					        public string Pharmacy { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "order_no")]
 | 
				
			||||||
 | 
					        public string OrderNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_id")]
 | 
				
			||||||
 | 
					        public string PatientId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "p_name")]
 | 
				
			||||||
 | 
					        public string PName { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "sex")]
 | 
				
			||||||
 | 
					        public string Sex { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "age")]
 | 
				
			||||||
 | 
					        public string Age { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id_number")]
 | 
				
			||||||
 | 
					        public string IdNumber { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_card")]
 | 
				
			||||||
 | 
					        public string PatientCard { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "invoice_no")]
 | 
				
			||||||
 | 
					        public string InvoiceNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_no")]
 | 
				
			||||||
 | 
					        public string PatientNo { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "doctor_name")]
 | 
				
			||||||
 | 
					        public string DoctorName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "order_date")]
 | 
				
			||||||
 | 
					        public DateTime OrderDate { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "charge_date")]
 | 
				
			||||||
 | 
					        public DateTime ChargeDate { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "recv_date")]
 | 
				
			||||||
 | 
					        public DateTime RecvDate { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "dept_name")]
 | 
				
			||||||
 | 
					        public string DeptName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "disease")]
 | 
				
			||||||
 | 
					        public string Disease { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "order_type")]
 | 
				
			||||||
 | 
					        public string OrderType { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "charge_type")]
 | 
				
			||||||
 | 
					        public string ChargeType { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "state")]
 | 
				
			||||||
 | 
					        public int State { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "his_disp_flag")]
 | 
				
			||||||
 | 
					        public int? HisDispFlag { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "cancel_flag")]
 | 
				
			||||||
 | 
					        public int? CancelFlag { get; set; }
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "dm_status")]
 | 
				
			||||||
 | 
					        public int? DmStatus { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "agent_name")]
 | 
				
			||||||
 | 
					        //public string AgentName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "agent_id_no")]
 | 
				
			||||||
 | 
					        //public string AgentIdNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "costs")]
 | 
				
			||||||
 | 
					        public decimal? Costs { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "payments")]
 | 
				
			||||||
 | 
					        //public decimal? Payments { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "dispensary")]
 | 
				
			||||||
 | 
					        //public string Dispensary { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName = "identity")]
 | 
				
			||||||
 | 
					        //public string Identity { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,35 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 
 | 
				
			||||||
 | 
					    ///</summary>
 | 
				
			||||||
 | 
					    [Serializable]
 | 
				
			||||||
 | 
					    public class PremissionDm
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         public int Id { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 菜单名 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         public string PremissionName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 菜单路径 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         public string PremissionPath { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 图片source 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        public string PremissionImage { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public ObservableCollection<PremissionDm>? Children { get; set; }
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 
 | 
				
			||||||
 | 
					    ///</summary>
 | 
				
			||||||
 | 
					    [SugarTable("role")]
 | 
				
			||||||
 | 
					    public class RoleDm
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="id" ,IsPrimaryKey = true ,IsIdentity = true  )]
 | 
				
			||||||
 | 
					         public int? Id { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="role_name"    )]
 | 
				
			||||||
 | 
					         public string RoleName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName="role_des"    )]
 | 
				
			||||||
 | 
					        //public string RoleDes { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        ///[SugarColumn(ColumnName="permissions"    )]
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "permissions", ColumnDataType = "varchar(4000)" /*可以设置类型*/, IsJson = true)]//必填
 | 
				
			||||||
 | 
					        public List<PremissionDm> Permissions { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="machine_id"    )]
 | 
				
			||||||
 | 
					         public string MachineId { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,55 @@
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("hkc_shiftsreport")]
 | 
				
			||||||
 | 
					    public class ShiftsReport
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_name")]
 | 
				
			||||||
 | 
					        public string DrugName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_spec")]
 | 
				
			||||||
 | 
					        public string DrugSpec { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "beforeNum")]
 | 
				
			||||||
 | 
					        public int? BeforeNum { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "getNum")]
 | 
				
			||||||
 | 
					        public int? GetNum { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "useNum")]
 | 
				
			||||||
 | 
					        public int? UseNum { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
 | 
					        public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "surplus")]
 | 
				
			||||||
 | 
					        public int? Surplus { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "opt_Date")]
 | 
				
			||||||
 | 
					        public DateTime OptDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "FromOperator")]
 | 
				
			||||||
 | 
					        public string FromOperator { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "FromReviewer")]
 | 
				
			||||||
 | 
					        public string FromReviewer { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ToOperator")]
 | 
				
			||||||
 | 
					        public string ToOperator { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ToReviewer")]
 | 
				
			||||||
 | 
					        public string ToReviewer { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machineId")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,77 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 
 | 
				
			||||||
 | 
					    ///</summary>
 | 
				
			||||||
 | 
					    [SugarTable("user_list")]
 | 
				
			||||||
 | 
					    public class UserList
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="id" ,IsPrimaryKey = true ,IsIdentity = true  )]
 | 
				
			||||||
 | 
					         public int Id { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="user_id"    )]
 | 
				
			||||||
 | 
					         public string UserName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="user_name"    )]
 | 
				
			||||||
 | 
					         public string Nickname { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="pass_word"    )]
 | 
				
			||||||
 | 
					         public string PassWord { get; set; }
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="user_barcode"    )]
 | 
				
			||||||
 | 
					         public string UserBarcode { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         //[SugarColumn(ColumnName="status"    )]
 | 
				
			||||||
 | 
					         //public int? Status { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="machine_role_id"    )]
 | 
				
			||||||
 | 
					         public int? RoleId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(RoleId))]
 | 
				
			||||||
 | 
					        public RoleDm? Role { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(ColumnName="user_card"    )]
 | 
				
			||||||
 | 
					        // public string UserCard { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="machine_id"    )]
 | 
				
			||||||
 | 
					         public string MachineId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					         [SugarColumn(ColumnName="sign"    )]
 | 
				
			||||||
 | 
					         public byte[] Sign { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public override string ToString()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return "userList = [UserName:" + Nickname + ", UserId:" + UserName + "]";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,171 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using SuperSimpleTcp;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Channels;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Markup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ScreenUtil
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(ScreenUtil));
 | 
				
			||||||
 | 
					        SimpleTcpServer server = new SimpleTcpServer("0.0.0.0:8888");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        string ipport { get; set; } = "";
 | 
				
			||||||
 | 
					        public ScreenUtil()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            server.Events.ClientConnected += (object sender, ConnectionEventArgs e) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                ipport = e.IpPort;
 | 
				
			||||||
 | 
					                logger.Info($"[{e.IpPort}] client connected");
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            server.Events.ClientDisconnected += (object sender, ConnectionEventArgs e) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"[{e.IpPort}] client disconnected: {e.Reason}");
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            server.Events.DataReceived += (object sender, DataReceivedEventArgs e) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"[{e.IpPort}]: {e.Data.Array}");
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            // let's go!
 | 
				
			||||||
 | 
					            server.Start();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private byte[] head = new byte[] { 0xee, 0xb1, 0x12 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private byte[] end = new byte[] { 0xFF, 0xFC, 0xFF, 0xFF };
 | 
				
			||||||
 | 
					        public void SetStockInfo(ChannelStock channel, int screenId)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 添加画面id
 | 
				
			||||||
 | 
					            byte[] a = Copy2NewArr(head, HighLow(screenId));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
 | 
				
			||||||
 | 
					            //if (channel.DrugInfo.DrugName != null)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            byte[] content = Encoding.GetEncoding("gb2312").GetBytes(channel.DrugInfo?.DrugName??"");
 | 
				
			||||||
 | 
					                a = WriteInfo(a, content, channel.ColNo * 10 + 1);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //if (channel.DrugInfo.Manufactory != null)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					                byte[] content1 = Encoding.GetEncoding("gb2312").GetBytes(channel.DrugInfo?.Manufactory?? "");
 | 
				
			||||||
 | 
					                a = WriteInfo(a, content1, channel.ColNo * 10 + 2);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //if (channel.DrugInfo.DrugSpec != null)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					                byte[] content2 = Encoding.GetEncoding("gb2312").GetBytes(channel.DrugInfo?.DrugSpec ?? "");
 | 
				
			||||||
 | 
					                a = WriteInfo(a, content2, channel.ColNo * 10 + 3);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //if (channel.ManuNo != null)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                byte[] content3 = Encoding.GetEncoding("gb2312").GetBytes(channel.ManuNo);
 | 
				
			||||||
 | 
					                a = WriteInfo(a, content3, channel.ColNo * 10 + 4);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //if (channel.EffDate != null)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					                byte[] content4 = Encoding.GetEncoding("gb2312").GetBytes(channel.EffDate);
 | 
				
			||||||
 | 
					                a = WriteInfo(a, content4, channel.ColNo * 10 + 5);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //if (channel.Quantity != null)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					                byte[] content5 = Encoding.GetEncoding("gb2312").GetBytes(channel.Quantity.ToString());
 | 
				
			||||||
 | 
					                a = WriteInfo(a, content5, channel.ColNo * 10 + 6);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            // 添加结束块
 | 
				
			||||||
 | 
					            byte[] b = Copy2NewArr(a, end);
 | 
				
			||||||
 | 
					            server.Send(ipport, b);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void TellChange(int d)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            byte[] buffer = new byte[] { 0xee, 0xb5, 0x01, 0x00, 0xFF, 0xFC, 0xFF, 0xFF };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void SetStockInfo(List<ChannelStock> channels, int screenId)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 添加画面id
 | 
				
			||||||
 | 
					            byte[] a = Copy2NewArr(head, HighLow(screenId));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for (int i = 0; i < channels.Count; i++)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                ChannelStock channel = channels[i];
 | 
				
			||||||
 | 
					                if (channel.DrugInfo.DrugName != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    byte[] content = Encoding.ASCII.GetBytes(channel.DrugInfo.DrugName);
 | 
				
			||||||
 | 
					                    a = WriteInfo(a, content, channels[0].DrawerNo * 10 + 1);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (channel.DrugInfo.Manufactory != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    byte[] content = Encoding.ASCII.GetBytes(channel.DrugInfo.Manufactory);
 | 
				
			||||||
 | 
					                    a = WriteInfo(a, content, channels[0].DrawerNo * 10 + 2);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (channel.DrugInfo.DrugSpec != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    byte[] content = Encoding.ASCII.GetBytes(channel.DrugInfo.DrugSpec);
 | 
				
			||||||
 | 
					                    a = WriteInfo(a, content, channels[0].DrawerNo * 10 + 3);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (channel.ManuNo != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    byte[] content = Encoding.ASCII.GetBytes(channel.ManuNo);
 | 
				
			||||||
 | 
					                    a = WriteInfo(a, content, channels[0].DrawerNo * 10 + 4);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (channel.EffDate != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    byte[] content = Encoding.ASCII.GetBytes(channel.EffDate);
 | 
				
			||||||
 | 
					                    a = WriteInfo(a, content, channels[0].DrawerNo * 10 + 5);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (channel.Quantity != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    byte[] content = Encoding.ASCII.GetBytes(channel.Quantity.ToString());
 | 
				
			||||||
 | 
					                    a = WriteInfo(a, content, channels[0].DrawerNo * 10 + 6);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // 添加结束块
 | 
				
			||||||
 | 
					            byte[] b = Copy2NewArr(a, end);
 | 
				
			||||||
 | 
					            server.Send(ipport, b);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public byte[] WriteInfo(byte[] a, byte[] content, int id)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 添加控件id
 | 
				
			||||||
 | 
					            byte[] b = Copy2NewArr(a, HighLow(id));
 | 
				
			||||||
 | 
					            // 添加需要向控件内写入的字节长度
 | 
				
			||||||
 | 
					            byte[] c = Copy2NewArr(b, HighLow(content.Length));
 | 
				
			||||||
 | 
					            // 写入内容
 | 
				
			||||||
 | 
					            return Copy2NewArr(c, content);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public byte[] HighLow(int data)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            byte high = Convert.ToByte((data >> 8) & 0x00ff); //位运算:右移8位
 | 
				
			||||||
 | 
					            byte low = Convert.ToByte(data & 0x00ff);         //去掉高位
 | 
				
			||||||
 | 
					            return new byte[] {high, low};
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public byte[] Copy2NewArr(byte[] source1, byte[] source2)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            byte[] target = new byte[source1.Length + source2.Length];
 | 
				
			||||||
 | 
					            Buffer.BlockCopy(source1, 0, target, 0, source1.Length);
 | 
				
			||||||
 | 
					            Buffer.BlockCopy(source2, 0, target, source1.Length, source2.Length);
 | 
				
			||||||
 | 
					            return target;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,200 @@
 | 
				
			||||||
 | 
					using gregn6Lib;
 | 
				
			||||||
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Report
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class GridReportUtil
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 定义Grid++Report报表主对象
 | 
				
			||||||
 | 
					        public static GridppReport Report = new GridppReport();
 | 
				
			||||||
 | 
					        public static string gridConnectionString =  ConfigurationManager.AppSettings["gridConnectionString"];
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * 打印预览
 | 
				
			||||||
 | 
					         * tempname: 模板文件名称
 | 
				
			||||||
 | 
					         * data: 模板数据
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        public static void PrintReport(string tempname, object data)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
 | 
					            GridppReport Report = new GridppReport();
 | 
				
			||||||
 | 
					            // 加载模板文件
 | 
				
			||||||
 | 
					            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + tempname);
 | 
				
			||||||
 | 
					            string s = JsonConvert.SerializeObject(data);
 | 
				
			||||||
 | 
					            // 加载数据
 | 
				
			||||||
 | 
					            Report.LoadDataFromXML(JsonConvert.SerializeObject(data));
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static void PrintReportStock()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
 | 
					            GridppReport Report = new GridppReport();
 | 
				
			||||||
 | 
					            Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            string machine_id=(ConfigurationManager.AppSettings["machineId"] ?? "DM1"); 
 | 
				
			||||||
 | 
					            string SQL = $@"SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
 | 
				
			||||||
 | 
					                          di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity,
 | 
				
			||||||
 | 
					                          cl.`drug_id` AS drugId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` =  '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`";
 | 
				
			||||||
 | 
					            // 加载模板文件
 | 
				
			||||||
 | 
					            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "stock_template.grf");
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
 | 
				
			||||||
 | 
					            DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
 | 
				
			||||||
 | 
					            string p_machine_id= (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
 | 
					             GridppReport Report = new GridppReport();
 | 
				
			||||||
 | 
					            // 加载模板文件
 | 
				
			||||||
 | 
					            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "account_book_temp.grf");
 | 
				
			||||||
 | 
					            string SQL = string.Empty;
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
				
			||||||
 | 
					            Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
 | 
					                Report.ParameterByName("startDate").Value = startDate ?? Convert.ToDateTime("2010-1-1");
 | 
				
			||||||
 | 
					                Report.ParameterByName("endDate").Value = endDate ?? DateTime.Now.AddDays(1);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            //Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
 | 
					            SQL = $@"SELECT  mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0)) 
 | 
				
			||||||
 | 
					                        AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0)) AS `outQuantity`,
 | 
				
			||||||
 | 
					                         mr.`operation_time` AS `operationTime`,IF(mr.`type`=1,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
 | 
				
			||||||
 | 
					                         di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`, 
 | 
				
			||||||
 | 
					                        mr.`manu_no` AS `manuNo`, mr.`eff_date` AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName` FROM 
 | 
				
			||||||
 | 
					                        dm_machine_record mr  LEFT JOIN drug_info di ON mr.`drug_id` = di.`drug_id`  LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`  
 | 
				
			||||||
 | 
					                        LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id` WHERE mr.`machine_id` = '{p_machine_id}' AND mr.`operation_time` > '{p_startDate}'
 | 
				
			||||||
 | 
					                        AND mr.`operation_time` < '{p_endDate}'  ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`";
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static void PrintReportMechineRecord(int type, DateTime? startDate, DateTime? endDate)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
 | 
					            GridppReport Report = new GridppReport();
 | 
				
			||||||
 | 
					            DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
 | 
				
			||||||
 | 
					            DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
 | 
				
			||||||
 | 
					            string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
 | 
					            string SQL = string.Empty;
 | 
				
			||||||
 | 
					            Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
 | 
					                Report.ParameterByName("startDate").Value = startDate ?? DateTime.Now.AddYears(-10);
 | 
				
			||||||
 | 
					                Report.ParameterByName("endDate").Value = endDate ?? DateTime.Now.AddDays(1);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            // 加载模板文件
 | 
				
			||||||
 | 
					            if (type == 1)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_add.grf");
 | 
				
			||||||
 | 
					                SQL = $@"SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`quantity` AS quantity,
 | 
				
			||||||
 | 
					                      dmr.`manu_no` AS manuNo,dmr.`eff_date` AS effDate,dmr.`operation_time` AS operationTime,
 | 
				
			||||||
 | 
					                      di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,
 | 
				
			||||||
 | 
					                      di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity,dmr.`drug_id` AS drugId,
 | 
				
			||||||
 | 
					                      ul.`user_name` AS nickname FROM dm_machine_record dmr LEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`
 | 
				
			||||||
 | 
					                    LEFT JOIN user_list ul ON ul.`id` = dmr.`Operator` WHERE dmr.`type` = 1 AND dmr.`machine_id` = '{p_machine_id}'
 | 
				
			||||||
 | 
					                     AND dmr.`operation_time` > '{p_startDate}' AND dmr.`operation_time` < '{p_endDate}'";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (type == 2)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_take.grf");
 | 
				
			||||||
 | 
					                SQL = $@" SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`quantity` AS quantity,
 | 
				
			||||||
 | 
					                      dmr.`manu_no` AS manuNo,dmr.`eff_date` AS effDate,dmr.`operation_time` AS operationTime,
 | 
				
			||||||
 | 
					                      di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,
 | 
				
			||||||
 | 
					                      di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity,dmr.`drug_id` AS drugId,
 | 
				
			||||||
 | 
					                      ul.`user_name` AS nickname FROM dm_machine_record dmr LEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`
 | 
				
			||||||
 | 
					                    LEFT JOIN user_list ul ON ul.`id` = dmr.`Operator` WHERE dmr.`type` = 2 
 | 
				
			||||||
 | 
					                     AND dmr.`machine_id` ='{p_machine_id}'  AND dmr.`operation_time` > '{p_startDate}'
 | 
				
			||||||
 | 
					                     AND dmr.`operation_time` < '{p_endDate}'";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (type == 3)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_return.grf");
 | 
				
			||||||
 | 
					                SQL = $@" SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,
 | 
				
			||||||
 | 
					                      CONCAT(dmr.`quantity`,IF(dmr.`type`=32,""(空瓶)"","""")) AS quantity,dmr.`manu_no` AS manuNo,
 | 
				
			||||||
 | 
					                      dmr.`eff_date` AS effDate,dmr.`operation_time` AS operationTime,di.`drug_name` AS drugName,
 | 
				
			||||||
 | 
					                      di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,
 | 
				
			||||||
 | 
					                      di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity,
 | 
				
			||||||
 | 
					                      dmr.`drug_id` AS drugId,ul.`user_name` AS nickname FROM dm_machine_record dmr
 | 
				
			||||||
 | 
					                    LEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id` LEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`
 | 
				
			||||||
 | 
					                    WHERE dmr.`type` in (31, 32) AND dmr.`machine_id` = '{p_machine_id}' AND dmr.`operation_time` > '{p_startDate}'
 | 
				
			||||||
 | 
					                     AND dmr.`operation_time` < '{p_endDate}'";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_check.grf");
 | 
				
			||||||
 | 
					                SQL = $@" SELECT dmr.`drawer_no` AS drawerNo,dmr.`col_no` AS colNo,dmr.`type` AS `type`,dmr.`quantity` AS quantity,
 | 
				
			||||||
 | 
					                          dmr.`manu_no` AS manuNo,dmr.`eff_date` AS effDate,dmr.`operation_time` AS operationTime,
 | 
				
			||||||
 | 
					                          di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,
 | 
				
			||||||
 | 
					                          di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity,dmr.`drug_id` AS drugId,
 | 
				
			||||||
 | 
					                          ul.`user_name` AS nickname FROM dm_machine_record dmr LEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`
 | 
				
			||||||
 | 
					                        LEFT JOIN user_list ul ON ul.`id` = dmr.`Operator` WHERE dmr.`type` = 4 
 | 
				
			||||||
 | 
					                         AND dmr.`machine_id` = '{p_machine_id}' AND dmr.`operation_time` > '{p_startDate}'
 | 
				
			||||||
 | 
					                        AND dmr.`operation_time` < '{p_endDate}'";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.QuerySQL= SQL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * 打印预览
 | 
				
			||||||
 | 
					         * tempname: 模板文件名称
 | 
				
			||||||
 | 
					         * data: 模板数据
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					        public static void PrintMachineRecordReport(List<MachineRecord> data)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
 | 
					            GridppReport Report = new GridppReport();
 | 
				
			||||||
 | 
					            // 加载模板文件
 | 
				
			||||||
 | 
					            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//machine_log.grf");
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            // 加载数据
 | 
				
			||||||
 | 
					            Report.ParameterByName("type").AsInteger = 1;
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //交接班记录报表
 | 
				
			||||||
 | 
					        public static void PrintChangeShiftsReport(DateTime? startDate,DateTime? endDate)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
 | 
				
			||||||
 | 
					            DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
 | 
				
			||||||
 | 
					            string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
 | 
					            GridppReport Report = new GridppReport();
 | 
				
			||||||
 | 
					            // 加载模板文件
 | 
				
			||||||
 | 
					            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "changeShifts_temp.grf");
 | 
				
			||||||
 | 
					            string SQL = string.Empty;
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
				
			||||||
 | 
					            Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
 | 
					                Report.ParameterByName("startDate").Value = startDate ?? Convert.ToDateTime("2010-1-1");
 | 
				
			||||||
 | 
					                Report.ParameterByName("endDate").Value = endDate ?? DateTime.Now.AddDays(1);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            SQL = $@"SELECT opt_date,drug_name,drug_spec,beforenum,getnum,usenum,manu_no,surplus,CONCAT(fromoperator,' ',fromreviewer) as fromoperator,
 | 
				
			||||||
 | 
					                    CONCAT(tooperator,' ',toreviewer) as tooperator
 | 
				
			||||||
 | 
					                    from `hkc_shiftsreport` WHERE `machineid` = '{p_machine_id}' AND `opt_date` > '{p_startDate}'
 | 
				
			||||||
 | 
					                        AND opt_date < '{p_endDate}'  ORDER BY opt_date";
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,606 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.3.0.1",
 | 
				
			||||||
 | 
						"Font":{
 | 
				
			||||||
 | 
							"Name":"宋体",
 | 
				
			||||||
 | 
							"Size":105000,
 | 
				
			||||||
 | 
							"Weight":400,
 | 
				
			||||||
 | 
							"Charset":134
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Printer":{
 | 
				
			||||||
 | 
							"Oriention":"Landscape",
 | 
				
			||||||
 | 
							"LeftMargin":1,
 | 
				
			||||||
 | 
							"TopMargin":1.42875,
 | 
				
			||||||
 | 
							"RightMargin":1,
 | 
				
			||||||
 | 
							"BottomMargin":1.8
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"DetailGrid":{
 | 
				
			||||||
 | 
							"CenterView":true,
 | 
				
			||||||
 | 
							"AppendBlankRow":true,
 | 
				
			||||||
 | 
							"Recordset":{
 | 
				
			||||||
 | 
								"Field":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"日期",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"M/d",
 | 
				
			||||||
 | 
										"DBFieldName":"operationTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"操作类型",
 | 
				
			||||||
 | 
										"DBFieldName":"type"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"批号",
 | 
				
			||||||
 | 
										"DBFieldName":"manuNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"上次批次结存",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"beforeManuQuan"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"入库数量",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"inQuantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"出库数量",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"outQuantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"批号结存",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"manuQuantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"总结存",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"stockQuantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"收/发药人",
 | 
				
			||||||
 | 
										"DBFieldName":"operatorName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"复核人",
 | 
				
			||||||
 | 
										"DBFieldName":"reviewerName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"药品名称",
 | 
				
			||||||
 | 
										"DBFieldName":"drugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"规格",
 | 
				
			||||||
 | 
										"DBFieldName":"drugSpec"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"单位",
 | 
				
			||||||
 | 
										"DBFieldName":"packUnit"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"剂型",
 | 
				
			||||||
 | 
										"DBFieldName":"dosage"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"厂家",
 | 
				
			||||||
 | 
										"DBFieldName":"manuFactory"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"有效期",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yy/M/d",
 | 
				
			||||||
 | 
										"DBFieldName":"effDate"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"sign1",
 | 
				
			||||||
 | 
										"Type":"Binary"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"sign2",
 | 
				
			||||||
 | 
										"Type":"Binary"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugId"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"凭证号",
 | 
				
			||||||
 | 
										"DBFieldName":"invoiceId"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"日期",
 | 
				
			||||||
 | 
									"Width":1.77271
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"凭证号",
 | 
				
			||||||
 | 
									"Width":2.19604
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"批号",
 | 
				
			||||||
 | 
									"Width":3.99521
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"有效期",
 | 
				
			||||||
 | 
									"Width":2.43417
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"入库数量",
 | 
				
			||||||
 | 
									"Width":1.79917
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"出库数量",
 | 
				
			||||||
 | 
									"Width":1.79917
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column4",
 | 
				
			||||||
 | 
									"Width":1.98438
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"收/发药人",
 | 
				
			||||||
 | 
									"Width":2.80458
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"复核人",
 | 
				
			||||||
 | 
									"Width":2.80458
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column2",
 | 
				
			||||||
 | 
									"Width":2.35479
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column3",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":0.85,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"日期",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"日期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"凭证号",
 | 
				
			||||||
 | 
										"DataField":"凭证号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"批号",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"批号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"有效期",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"有效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"入库数量",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"入库数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"出库数量",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"出库数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column4",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"总结存"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"收/发药人",
 | 
				
			||||||
 | 
										"FreeCell":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox12",
 | 
				
			||||||
 | 
												"Dock":"Fill",
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"DataField":"收/发药人"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"复核人",
 | 
				
			||||||
 | 
										"FreeCell":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox13",
 | 
				
			||||||
 | 
												"Dock":"Fill",
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"DataField":"复核人"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column2",
 | 
				
			||||||
 | 
										"FreeCell":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox6",
 | 
				
			||||||
 | 
												"Dock":"Fill",
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"药库"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column3",
 | 
				
			||||||
 | 
										"FreeCell":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox7",
 | 
				
			||||||
 | 
												"Dock":"Fill",
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"门诊药房"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.19063,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnGroupHeaderPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"日期",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"日期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"凭证号",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"凭证号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"批号",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"批号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"有效期",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"有效\r\n期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"入库数量",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"借入\r\n数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"出库数量",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"发出\r\n数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column4",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"总结存"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"收/发药人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"发药人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"复核人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"复核人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column2",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"供应单位"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column3",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"领用部门"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Group":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Group1",
 | 
				
			||||||
 | 
									"ByFields":"drugId",
 | 
				
			||||||
 | 
									"GroupHeader":{
 | 
				
			||||||
 | 
										"PrintGridBorder":false,
 | 
				
			||||||
 | 
										"RepeatOnPage":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox15",
 | 
				
			||||||
 | 
												"Left":28.3898,
 | 
				
			||||||
 | 
												"Top":0.238125,
 | 
				
			||||||
 | 
												"Width":2.01083,
 | 
				
			||||||
 | 
												"Height":0.79375,
 | 
				
			||||||
 | 
												"Text":"生产厂家:"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox11",
 | 
				
			||||||
 | 
												"Left":30.3742,
 | 
				
			||||||
 | 
												"Top":0.211667,
 | 
				
			||||||
 | 
												"Width":5.3975,
 | 
				
			||||||
 | 
												"Height":0.79375,
 | 
				
			||||||
 | 
												"Text":"[#manuFactory#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox16",
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":1.19063,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"Text":"品名:"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox7",
 | 
				
			||||||
 | 
												"Left":1.16417,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":5.63563,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"DataField":"药品名称"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox17",
 | 
				
			||||||
 | 
												"Left":6.93208,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":1.11125,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"Text":"规格:"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox8",
 | 
				
			||||||
 | 
												"Left":8.01688,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":3.175,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"DataField":"规格"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox18",
 | 
				
			||||||
 | 
												"Left":11.5888,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":1.21708,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"Text":"单位:"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox9",
 | 
				
			||||||
 | 
												"Left":12.7794,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":1.87854,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"DataField":"单位"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox19",
 | 
				
			||||||
 | 
												"Left":15.3988,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":1.16417,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"Text":"剂型:"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox10",
 | 
				
			||||||
 | 
												"Left":16.5365,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":2.83104,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"DataField":"剂型"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox20",
 | 
				
			||||||
 | 
												"Left":19.7379,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":2.01083,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"Text":"生产厂家:"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox11",
 | 
				
			||||||
 | 
												"Left":21.7223,
 | 
				
			||||||
 | 
												"Top":0.05,
 | 
				
			||||||
 | 
												"Width":5.92667,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"DataField":"厂家"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										],
 | 
				
			||||||
 | 
										"NewPageColumn":"Before"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									"GroupFooter":{
 | 
				
			||||||
 | 
										"Visible":false
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							]
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Parameter":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"machine_id"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"startDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"endDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"ReportHeader":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader1",
 | 
				
			||||||
 | 
								"Height":1.79917,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"MemoBox",
 | 
				
			||||||
 | 
										"Name":"MemoBox1",
 | 
				
			||||||
 | 
										"Dock":"Fill",
 | 
				
			||||||
 | 
										"Center":"Both",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":262500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"麻醉、精神药品逐笔专用账册"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,346 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.3.0.1",
 | 
				
			||||||
 | 
						"Font":{
 | 
				
			||||||
 | 
							"Name":"宋体",
 | 
				
			||||||
 | 
							"Size":105000,
 | 
				
			||||||
 | 
							"Weight":400,
 | 
				
			||||||
 | 
							"Charset":134
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Printer":{
 | 
				
			||||||
 | 
							"Oriention":"Landscape",
 | 
				
			||||||
 | 
							"LeftMargin":1,
 | 
				
			||||||
 | 
							"TopMargin":1.4287,
 | 
				
			||||||
 | 
							"RightMargin":1,
 | 
				
			||||||
 | 
							"BottomMargin":1.8
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"DetailGrid":{
 | 
				
			||||||
 | 
							"CenterView":true,
 | 
				
			||||||
 | 
							"Recordset":{
 | 
				
			||||||
 | 
								"Field":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"日期",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd",
 | 
				
			||||||
 | 
										"DBFieldName":"opt_date"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"品名",
 | 
				
			||||||
 | 
										"DBFieldName":"drug_name"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"规格",
 | 
				
			||||||
 | 
										"DBFieldName":"drug_spec"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"上班结存数",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"beforenum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"领用数",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"getnum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"消耗数",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"usenum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"批号",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"manu_no"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"余",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"surplus"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"交班人",
 | 
				
			||||||
 | 
										"DBFieldName":"fromoperator"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"接班人",
 | 
				
			||||||
 | 
										"DBFieldName":"tooperator"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"日期",
 | 
				
			||||||
 | 
									"Width":2.56646
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"品名",
 | 
				
			||||||
 | 
									"Width":4.60375
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"规格",
 | 
				
			||||||
 | 
									"Width":2.59292
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"上班结存数",
 | 
				
			||||||
 | 
									"Width":1.4
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"领用数",
 | 
				
			||||||
 | 
									"Width":1.4
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"消耗数",
 | 
				
			||||||
 | 
									"Width":1.4
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"批号",
 | 
				
			||||||
 | 
									"Width":1.98438
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"余",
 | 
				
			||||||
 | 
									"Width":0.608542
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"交班人",
 | 
				
			||||||
 | 
									"Width":2.80458
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"接班人",
 | 
				
			||||||
 | 
									"Width":2.35479
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":0.85,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"日期",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"日期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"品名",
 | 
				
			||||||
 | 
										"DataField":"品名"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"规格",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"规格"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"上班结存数",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"上班结存数"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"领用数",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"领用数"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"消耗数",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"消耗数"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"批号",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"批号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"余",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"余"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"交班人",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"交班人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"接班人",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"接班人"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.00542,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"日期",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"日期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"品名",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"品名"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"规格",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"规格"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"上班结存数",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"WordWrap":true,
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"上班\r\n结存数"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"领用数",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"WordWrap":true,
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"领用数"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"消耗数",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"WordWrap":true,
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"消耗数"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"批号",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"批号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"余",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"余"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"交班人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"交班人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"接班人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":105000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"接班人"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Group":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Group1",
 | 
				
			||||||
 | 
									"ByFields":"日期",
 | 
				
			||||||
 | 
									"GroupHeader":{
 | 
				
			||||||
 | 
										"Height":0,
 | 
				
			||||||
 | 
										"PrintGridBorder":false,
 | 
				
			||||||
 | 
										"NewPageColumn":"Before"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									"GroupFooter":{
 | 
				
			||||||
 | 
										"Visible":false,
 | 
				
			||||||
 | 
										"PrintGridBorder":false
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							]
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Parameter":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"machine_id"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"startDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"endDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"ReportHeader":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader1",
 | 
				
			||||||
 | 
								"Height":1.79917,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"MemoBox",
 | 
				
			||||||
 | 
										"Name":"MemoBox1",
 | 
				
			||||||
 | 
										"Dock":"Fill",
 | 
				
			||||||
 | 
										"Center":"Both",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":262500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"交接班记录"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,283 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.3.0.1",
 | 
				
			||||||
 | 
						"Font":{
 | 
				
			||||||
 | 
							"Name":"宋体",
 | 
				
			||||||
 | 
							"Size":105000,
 | 
				
			||||||
 | 
							"Weight":400,
 | 
				
			||||||
 | 
							"Charset":134
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Printer":{
 | 
				
			||||||
 | 
							"LeftMargin":0.3175,
 | 
				
			||||||
 | 
							"TopMargin":0.899583,
 | 
				
			||||||
 | 
							"RightMargin":0.396875
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"DetailGrid":{
 | 
				
			||||||
 | 
							"CenterView":true,
 | 
				
			||||||
 | 
							"AppendBlankRow":true,
 | 
				
			||||||
 | 
							"Recordset":{
 | 
				
			||||||
 | 
								"QuerySQL":"SELECT \r\n  dmr.`drawer_no` AS drawerNo,\r\n  dmr.`col_no` AS colNo,\r\n  dmr.`type` AS `type`,\r\n  dmr.`quantity` AS quantity,\r\n  dmr.`manu_no` AS manuNo,\r\n  dmr.`eff_date` AS effDate,\r\n  dmr.`operation_time` AS operationTime,\r\n  di.`drug_name` AS drugName,\r\n  di.`drug_spec` AS drugSpec,\r\n  di.`pack_unit` AS packUnit,\r\n  di.`manufactory` AS manuFactory,\r\n  di.`max_stock` AS baseQuantity,\r\n  dmr.`drug_id` AS drugId,\r\n  ul.`user_name` AS nickname\r\nFROM\r\n  dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 1 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
 | 
				
			||||||
 | 
								"Field":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"操作人",
 | 
				
			||||||
 | 
										"DBFieldName":"Nickname"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"时间",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd HH:mm:ss",
 | 
				
			||||||
 | 
										"DBFieldName":"operationTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"药品名称",
 | 
				
			||||||
 | 
										"DBFieldName":"DrugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"数量",
 | 
				
			||||||
 | 
										"DBFieldName":"quantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"批次",
 | 
				
			||||||
 | 
										"DBFieldName":"manuNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"效期",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd",
 | 
				
			||||||
 | 
										"DBFieldName":"effDate"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"库位",
 | 
				
			||||||
 | 
										"DBFieldName":"drawerNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"colNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"type2",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"type"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"操作人",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"时间",
 | 
				
			||||||
 | 
									"Width":3.78354
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"药品名称",
 | 
				
			||||||
 | 
									"Width":4.63021
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"数量",
 | 
				
			||||||
 | 
									"Width":1.98438
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"批次",
 | 
				
			||||||
 | 
									"Width":2.61938
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"效期",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"库位",
 | 
				
			||||||
 | 
									"Width":2.59292
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":1.00542,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"操作人",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"操作人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"时间",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"药品名称",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"批次",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"效期",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"库位",
 | 
				
			||||||
 | 
										"FreeCell":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox1",
 | 
				
			||||||
 | 
												"Left":9.60438,
 | 
				
			||||||
 | 
												"Top":-2.16958,
 | 
				
			||||||
 | 
												"Width":2.80458,
 | 
				
			||||||
 | 
												"Height":0.661458
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox1",
 | 
				
			||||||
 | 
												"Dock":"Fill",
 | 
				
			||||||
 | 
												"Center":"Both",
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#库位#] - [#colNo#]"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.40229,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"操作人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"操作人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"时间",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"药品名称",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"批次",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"效期",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"库位",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"库位"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Parameter":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"startDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime",
 | 
				
			||||||
 | 
								"Format":"yyyy-MM-dd hh:mm:ss",
 | 
				
			||||||
 | 
								"Value":"2023/1/1"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"endDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime",
 | 
				
			||||||
 | 
								"Format":"yyyy-MM-dd hh:mm:ss",
 | 
				
			||||||
 | 
								"Value":"2023/4/28 23:59:59"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"machine_id",
 | 
				
			||||||
 | 
								"Value":"DM1"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"ReportHeader":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader1",
 | 
				
			||||||
 | 
								"Height":1.79917,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"MemoBox",
 | 
				
			||||||
 | 
										"Name":"MemoBox2",
 | 
				
			||||||
 | 
										"Left":7.59354,
 | 
				
			||||||
 | 
										"Top":0.211667,
 | 
				
			||||||
 | 
										"Width":5.60917,
 | 
				
			||||||
 | 
										"Height":1.19063,
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":217500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"入库记录"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,283 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.3.0.1",
 | 
				
			||||||
 | 
						"Font":{
 | 
				
			||||||
 | 
							"Name":"宋体",
 | 
				
			||||||
 | 
							"Size":105000,
 | 
				
			||||||
 | 
							"Weight":400,
 | 
				
			||||||
 | 
							"Charset":134
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Printer":{
 | 
				
			||||||
 | 
							"LeftMargin":0.3175,
 | 
				
			||||||
 | 
							"TopMargin":0.899583,
 | 
				
			||||||
 | 
							"RightMargin":0.396875
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"DetailGrid":{
 | 
				
			||||||
 | 
							"CenterView":true,
 | 
				
			||||||
 | 
							"AppendBlankRow":true,
 | 
				
			||||||
 | 
							"Recordset":{
 | 
				
			||||||
 | 
								"QuerySQL":"SELECT \r\n  dmr.`drawer_no` AS drawerNo,\r\n  dmr.`col_no` AS colNo,\r\n  dmr.`type` AS `type`,\r\n  dmr.`quantity` AS quantity,\r\n  dmr.`manu_no` AS manuNo,\r\n  dmr.`eff_date` AS effDate,\r\n  dmr.`operation_time` AS operationTime,\r\n  di.`drug_name` AS drugName,\r\n  di.`drug_spec` AS drugSpec,\r\n  di.`pack_unit` AS packUnit,\r\n  di.`manufactory` AS manuFactory,\r\n  di.`max_stock` AS baseQuantity,\r\n  dmr.`drug_id` AS drugId,\r\n  ul.`user_name` AS nickname\r\nFROM\r\n  dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 4 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
 | 
				
			||||||
 | 
								"Field":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"操作人",
 | 
				
			||||||
 | 
										"DBFieldName":"Nickname"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"时间",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd HH:mm:ss",
 | 
				
			||||||
 | 
										"DBFieldName":"operationTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"药品名称",
 | 
				
			||||||
 | 
										"DBFieldName":"DrugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"数量",
 | 
				
			||||||
 | 
										"DBFieldName":"quantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"批次",
 | 
				
			||||||
 | 
										"DBFieldName":"manuNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"效期",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd",
 | 
				
			||||||
 | 
										"DBFieldName":"effDate"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"库位",
 | 
				
			||||||
 | 
										"DBFieldName":"drawerNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"colNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"type2",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"type"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"操作人",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"时间",
 | 
				
			||||||
 | 
									"Width":3.78354
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"药品名称",
 | 
				
			||||||
 | 
									"Width":4.63021
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"数量",
 | 
				
			||||||
 | 
									"Width":1.98438
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"批次",
 | 
				
			||||||
 | 
									"Width":2.61938
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"效期",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"库位",
 | 
				
			||||||
 | 
									"Width":2.59292
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":1.00542,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"操作人",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"操作人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"时间",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"药品名称",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"批次",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"效期",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"库位",
 | 
				
			||||||
 | 
										"FreeCell":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox1",
 | 
				
			||||||
 | 
												"Left":9.60438,
 | 
				
			||||||
 | 
												"Top":-2.16958,
 | 
				
			||||||
 | 
												"Width":2.80458,
 | 
				
			||||||
 | 
												"Height":0.661458
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox1",
 | 
				
			||||||
 | 
												"Dock":"Fill",
 | 
				
			||||||
 | 
												"Center":"Both",
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#库位#] - [#colNo#]"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.40229,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"操作人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"操作人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"时间",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"药品名称",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"批次",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"效期",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"库位",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"库位"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Parameter":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"startDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime",
 | 
				
			||||||
 | 
								"Format":"yyyy-MM-dd hh:mm:ss",
 | 
				
			||||||
 | 
								"Value":"2023/1/1"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"endDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime",
 | 
				
			||||||
 | 
								"Format":"yyyy-MM-dd hh:mm:ss",
 | 
				
			||||||
 | 
								"Value":"2023/4/28 23:59:59"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"machine_id",
 | 
				
			||||||
 | 
								"Value":"DM1"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"ReportHeader":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader1",
 | 
				
			||||||
 | 
								"Height":1.79917,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"MemoBox",
 | 
				
			||||||
 | 
										"Name":"MemoBox2",
 | 
				
			||||||
 | 
										"Left":7.59354,
 | 
				
			||||||
 | 
										"Top":0.211667,
 | 
				
			||||||
 | 
										"Width":5.60917,
 | 
				
			||||||
 | 
										"Height":1.19063,
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":217500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"盘点记录"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,283 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.3.0.1",
 | 
				
			||||||
 | 
						"Font":{
 | 
				
			||||||
 | 
							"Name":"宋体",
 | 
				
			||||||
 | 
							"Size":105000,
 | 
				
			||||||
 | 
							"Weight":400,
 | 
				
			||||||
 | 
							"Charset":134
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Printer":{
 | 
				
			||||||
 | 
							"LeftMargin":0.3175,
 | 
				
			||||||
 | 
							"TopMargin":0.899583,
 | 
				
			||||||
 | 
							"RightMargin":0.396875
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"DetailGrid":{
 | 
				
			||||||
 | 
							"CenterView":true,
 | 
				
			||||||
 | 
							"AppendBlankRow":true,
 | 
				
			||||||
 | 
							"Recordset":{
 | 
				
			||||||
 | 
								"QuerySQL":"SELECT \r\n  dmr.`drawer_no` AS drawerNo,\r\n  dmr.`col_no` AS colNo,\r\n  dmr.`type` AS `type`,\r\n  CONCAT(dmr.`quantity`,IF(dmr.`type`=32,\"(空瓶)\",\"\")) AS quantity,\r\n  dmr.`manu_no` AS manuNo,\r\n  dmr.`eff_date` AS effDate,\r\n  dmr.`operation_time` AS operationTime,\r\n  di.`drug_name` AS drugName,\r\n  di.`drug_spec` AS drugSpec,\r\n  di.`pack_unit` AS packUnit,\r\n  di.`manufactory` AS manuFactory,\r\n  di.`max_stock` AS baseQuantity,\r\n  dmr.`drug_id` AS drugId,\r\n  ul.`user_name` AS nickname\r\nFROM\r\n  dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` in (31, 32)\r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
 | 
				
			||||||
 | 
								"Field":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"操作人",
 | 
				
			||||||
 | 
										"DBFieldName":"Nickname"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"时间",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd HH:mm:ss",
 | 
				
			||||||
 | 
										"DBFieldName":"operationTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"药品名称",
 | 
				
			||||||
 | 
										"DBFieldName":"DrugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"数量",
 | 
				
			||||||
 | 
										"DBFieldName":"quantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"批次",
 | 
				
			||||||
 | 
										"DBFieldName":"manuNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"效期",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd",
 | 
				
			||||||
 | 
										"DBFieldName":"effDate"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"库位",
 | 
				
			||||||
 | 
										"DBFieldName":"drawerNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"colNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"type2",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"type"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"操作人",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"时间",
 | 
				
			||||||
 | 
									"Width":3.78354
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"药品名称",
 | 
				
			||||||
 | 
									"Width":4.63021
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"数量",
 | 
				
			||||||
 | 
									"Width":1.98438
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"批次",
 | 
				
			||||||
 | 
									"Width":2.61938
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"效期",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"库位",
 | 
				
			||||||
 | 
									"Width":2.59292
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":1.00542,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"操作人",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"操作人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"时间",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"药品名称",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"批次",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"效期",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"库位",
 | 
				
			||||||
 | 
										"FreeCell":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox1",
 | 
				
			||||||
 | 
												"Left":9.60438,
 | 
				
			||||||
 | 
												"Top":-2.16958,
 | 
				
			||||||
 | 
												"Width":2.80458,
 | 
				
			||||||
 | 
												"Height":0.661458
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox1",
 | 
				
			||||||
 | 
												"Dock":"Fill",
 | 
				
			||||||
 | 
												"Center":"Both",
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#库位#] - [#colNo#]"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.40229,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"操作人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"操作人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"时间",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"药品名称",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"批次",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"效期",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"库位",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"库位"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Parameter":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"startDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime",
 | 
				
			||||||
 | 
								"Format":"yyyy-MM-dd hh:mm:ss",
 | 
				
			||||||
 | 
								"Value":"2023/1/1"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"endDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime",
 | 
				
			||||||
 | 
								"Format":"yyyy-MM-dd hh:mm:ss",
 | 
				
			||||||
 | 
								"Value":"2023/4/28 23:59:59"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"machine_id",
 | 
				
			||||||
 | 
								"Value":"DM1"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"ReportHeader":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader1",
 | 
				
			||||||
 | 
								"Height":1.79917,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"MemoBox",
 | 
				
			||||||
 | 
										"Name":"MemoBox2",
 | 
				
			||||||
 | 
										"Left":7.59354,
 | 
				
			||||||
 | 
										"Top":0.211667,
 | 
				
			||||||
 | 
										"Width":5.60917,
 | 
				
			||||||
 | 
										"Height":1.19063,
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":217500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"归还记录"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,283 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.3.0.1",
 | 
				
			||||||
 | 
						"Font":{
 | 
				
			||||||
 | 
							"Name":"宋体",
 | 
				
			||||||
 | 
							"Size":105000,
 | 
				
			||||||
 | 
							"Weight":400,
 | 
				
			||||||
 | 
							"Charset":134
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Printer":{
 | 
				
			||||||
 | 
							"LeftMargin":0.3175,
 | 
				
			||||||
 | 
							"TopMargin":0.899583,
 | 
				
			||||||
 | 
							"RightMargin":0.396875
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"DetailGrid":{
 | 
				
			||||||
 | 
							"CenterView":true,
 | 
				
			||||||
 | 
							"AppendBlankRow":true,
 | 
				
			||||||
 | 
							"Recordset":{
 | 
				
			||||||
 | 
								"QuerySQL":"SELECT \r\n  dmr.`drawer_no` AS drawerNo,\r\n  dmr.`col_no` AS colNo,\r\n  dmr.`type` AS `type`,\r\n  dmr.`quantity` AS quantity,\r\n  dmr.`manu_no` AS manuNo,\r\n  dmr.`eff_date` AS effDate,\r\n  dmr.`operation_time` AS operationTime,\r\n  di.`drug_name` AS drugName,\r\n  di.`drug_spec` AS drugSpec,\r\n  di.`pack_unit` AS packUnit,\r\n  di.`manufactory` AS manuFactory,\r\n  di.`max_stock` AS baseQuantity,\r\n  dmr.`drug_id` AS drugId,\r\n  ul.`user_name` AS nickname\r\nFROM\r\n  dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 2 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
 | 
				
			||||||
 | 
								"Field":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"操作人",
 | 
				
			||||||
 | 
										"DBFieldName":"Nickname"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"时间",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd HH:mm:ss",
 | 
				
			||||||
 | 
										"DBFieldName":"operationTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"药品名称",
 | 
				
			||||||
 | 
										"DBFieldName":"DrugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"数量",
 | 
				
			||||||
 | 
										"DBFieldName":"quantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"批次",
 | 
				
			||||||
 | 
										"DBFieldName":"manuNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"效期",
 | 
				
			||||||
 | 
										"Type":"DateTime",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd",
 | 
				
			||||||
 | 
										"DBFieldName":"effDate"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"库位",
 | 
				
			||||||
 | 
										"DBFieldName":"drawerNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"colNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"type2",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"type"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"操作人",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"时间",
 | 
				
			||||||
 | 
									"Width":3.78354
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"药品名称",
 | 
				
			||||||
 | 
									"Width":4.63021
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"数量",
 | 
				
			||||||
 | 
									"Width":1.98438
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"批次",
 | 
				
			||||||
 | 
									"Width":2.61938
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"效期",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"库位",
 | 
				
			||||||
 | 
									"Width":2.59292
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":1.00542,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"操作人",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"操作人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"时间",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"药品名称",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"批次",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"效期",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"库位",
 | 
				
			||||||
 | 
										"FreeCell":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox1",
 | 
				
			||||||
 | 
												"Left":9.60438,
 | 
				
			||||||
 | 
												"Top":-2.16958,
 | 
				
			||||||
 | 
												"Width":2.80458,
 | 
				
			||||||
 | 
												"Height":0.661458
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox1",
 | 
				
			||||||
 | 
												"Dock":"Fill",
 | 
				
			||||||
 | 
												"Center":"Both",
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#库位#] - [#colNo#]"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.40229,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"操作人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"操作人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"时间",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"药品名称",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"批次",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"效期",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"库位",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"库位"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Parameter":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"startDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime",
 | 
				
			||||||
 | 
								"Format":"yyyy-MM-dd hh:mm:ss",
 | 
				
			||||||
 | 
								"Value":"2023/1/1"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"endDate",
 | 
				
			||||||
 | 
								"DataType":"DateTime",
 | 
				
			||||||
 | 
								"Format":"yyyy-MM-dd hh:mm:ss",
 | 
				
			||||||
 | 
								"Value":"2023/4/28 23:59:59"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"machine_id",
 | 
				
			||||||
 | 
								"Value":"DM1"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"ReportHeader":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader1",
 | 
				
			||||||
 | 
								"Height":1.79917,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"MemoBox",
 | 
				
			||||||
 | 
										"Name":"MemoBox2",
 | 
				
			||||||
 | 
										"Left":7.59354,
 | 
				
			||||||
 | 
										"Top":0.211667,
 | 
				
			||||||
 | 
										"Width":5.60917,
 | 
				
			||||||
 | 
										"Height":1.19063,
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":217500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"出库记录"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,346 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.3.0.1",
 | 
				
			||||||
 | 
						"Font":{
 | 
				
			||||||
 | 
							"Name":"宋体",
 | 
				
			||||||
 | 
							"Size":105000,
 | 
				
			||||||
 | 
							"Weight":400,
 | 
				
			||||||
 | 
							"Charset":134
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Printer":{
 | 
				
			||||||
 | 
							"Oriention":"Landscape"
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"DetailGrid":{
 | 
				
			||||||
 | 
							"CenterView":true,
 | 
				
			||||||
 | 
							"PrintAdaptMethod":"ResizeToFit",
 | 
				
			||||||
 | 
							"AppendBlankRow":true,
 | 
				
			||||||
 | 
							"Recordset":{
 | 
				
			||||||
 | 
								"QuerySQL":"SELECT \r\n  cl.`row_no` AS drawerNo,\r\n  cl.`col_no` AS colNo,\r\n  cl.`quantity` AS quantity,\r\n  cl.`manu_no` AS manuNo,\r\n  cl.`eff_date` AS effDate,\r\n  di.`drug_name` AS drugName,\r\n  di.`drug_spec` AS drugSpec,\r\n  di.`pack_unit` AS packUnit,\r\n  di.`manufactory` AS manuFactory,\r\n  di.`max_stock` AS baseQuantity,\r\n  cl.`drug_id` AS drugId\r\nFROM\r\n  channel_stock cl\r\nINNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id`\r\nWHERE cl.`machine_id` =  :machine_id\r\n AND cl.`drawer_type` = 1\r\n ORDER BY cl.`drug_id`",
 | 
				
			||||||
 | 
								"Field":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugSpec"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"manuFactory"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"quantityCount"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"manuNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"effDate"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"quantity",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"Format":"0"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drawerNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugId"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"baseQuantity",
 | 
				
			||||||
 | 
										"Type":"Integer"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"drugName",
 | 
				
			||||||
 | 
									"Width":5.37104
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"drugSpec"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"manuFactory",
 | 
				
			||||||
 | 
									"Width":4.60375
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column1"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"quantityCount",
 | 
				
			||||||
 | 
									"Width":2.59292
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"manuNo"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"effDate"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"quantity",
 | 
				
			||||||
 | 
									"Width":2.43417
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":0.79375,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"drugName",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"drugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"drugSpec",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"drugSpec"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"manuFactory",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"manuFactory"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column1",
 | 
				
			||||||
 | 
										"FreeCell":true
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"quantityCount",
 | 
				
			||||||
 | 
										"FreeCell":true
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"manuNo",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"manuNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"effDate",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"effDate"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"quantity",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"quantity"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.19063,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"drugName",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"药品名称"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"drugSpec",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"规格"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"manuFactory",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"厂家"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column1",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"基数"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"quantityCount",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"总库存"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"manuNo",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"批次"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"effDate",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"效期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"quantity",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"数量"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Group":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"drugId",
 | 
				
			||||||
 | 
									"ByFields":"drugId",
 | 
				
			||||||
 | 
									"GroupHeader":{
 | 
				
			||||||
 | 
										"Visible":false,
 | 
				
			||||||
 | 
										"Height":0.79375,
 | 
				
			||||||
 | 
										"RepeatOnPage":true,
 | 
				
			||||||
 | 
										"OccupyColumn":true,
 | 
				
			||||||
 | 
										"IncludeFooter":true,
 | 
				
			||||||
 | 
										"OccupiedColumns":"drugName;drugSpec;manuFactory;quantityCount;Column1",
 | 
				
			||||||
 | 
										"VAlign":"Middle"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									"GroupFooter":{
 | 
				
			||||||
 | 
										"Visible":false,
 | 
				
			||||||
 | 
										"Height":0.396875
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Group1",
 | 
				
			||||||
 | 
									"ByFields":"drugId",
 | 
				
			||||||
 | 
									"GroupHeader":{
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox3",
 | 
				
			||||||
 | 
												"AlignColumn":"drugName",
 | 
				
			||||||
 | 
												"Width":5.3975,
 | 
				
			||||||
 | 
												"Height":1.19063,
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#drugName#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox4",
 | 
				
			||||||
 | 
												"AlignColumn":"drugSpec",
 | 
				
			||||||
 | 
												"Left":5.37104,
 | 
				
			||||||
 | 
												"Width":3.01625,
 | 
				
			||||||
 | 
												"Height":1.19063,
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#drugSpec#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox5",
 | 
				
			||||||
 | 
												"AlignColumn":"manuFactory",
 | 
				
			||||||
 | 
												"Left":8.36083,
 | 
				
			||||||
 | 
												"Width":4.63021,
 | 
				
			||||||
 | 
												"Height":1.19063,
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#manuFactory#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox6",
 | 
				
			||||||
 | 
												"AlignColumn":"Column1",
 | 
				
			||||||
 | 
												"Left":12.9646,
 | 
				
			||||||
 | 
												"Width":3.01625,
 | 
				
			||||||
 | 
												"Height":1.19063,
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#baseQuantity#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"SummaryBox",
 | 
				
			||||||
 | 
												"Name":"SummaryBox1",
 | 
				
			||||||
 | 
												"AlignColumn":"quantityCount",
 | 
				
			||||||
 | 
												"Left":15.9544,
 | 
				
			||||||
 | 
												"Width":2.61938,
 | 
				
			||||||
 | 
												"Height":1.19063,
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"DataField":"quantity",
 | 
				
			||||||
 | 
												"Format":"0"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										],
 | 
				
			||||||
 | 
										"OccupyColumn":true,
 | 
				
			||||||
 | 
										"SameAsColumn":false,
 | 
				
			||||||
 | 
										"OccupiedColumns":"Column1;drugName;drugSpec;manuFactory;quantityCount",
 | 
				
			||||||
 | 
										"VAlign":"Middle"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									"GroupFooter":{
 | 
				
			||||||
 | 
										"Visible":false
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							]
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Parameter":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"machine_id",
 | 
				
			||||||
 | 
								"Value":"DM1"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"ReportHeader":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader1",
 | 
				
			||||||
 | 
								"Height":2.40771,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"StaticBox",
 | 
				
			||||||
 | 
										"Name":"StaticBox1",
 | 
				
			||||||
 | 
										"Center":"Horizontal",
 | 
				
			||||||
 | 
										"Left":8.89,
 | 
				
			||||||
 | 
										"Top":0.608542,
 | 
				
			||||||
 | 
										"Width":9.18104,
 | 
				
			||||||
 | 
										"Height":1.21708,
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":217500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"毒麻药品库存信息"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Controls;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Validation
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class NotEmptyValidationRule : ValidationRule
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return string.IsNullOrWhiteSpace((value ?? "").ToString())
 | 
				
			||||||
 | 
					                ? new ValidationResult(false, "字段不能为空")
 | 
				
			||||||
 | 
					                : ValidationResult.ValidResult;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,534 @@
 | 
				
			||||||
 | 
					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 == "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;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (msg.WindowName == "AddDrugControl")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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,
 | 
				
			||||||
 | 
					                                    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)
 | 
				
			||||||
 | 
					                                }).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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,151 @@
 | 
				
			||||||
 | 
					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 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 AddManunoDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string Title => "添加批次";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					        private ChannelStock? _channelStock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ObservableCollection<AddChannelStockManuNo>? _addChannelStocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ObservableCollection<AddChannelStockManuNo>? AddChannelStocks
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _addChannelStocks;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _addChannelStocks, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public ChannelStock? ChStock
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _channelStock;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _channelStock, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					         ///全选
 | 
				
			||||||
 | 
					         /// </summary>
 | 
				
			||||||
 | 
					        private bool _allChecked = false;
 | 
				
			||||||
 | 
					        public bool IsAllChecked
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _allChecked; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _allChecked, value);
 | 
				
			||||||
 | 
					                if (!IsItemCheck)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    RequestData();
 | 
				
			||||||
 | 
					                    //根据全选或反选设置其后的选中状态
 | 
				
			||||||
 | 
					                    AddChannelStocks.ToList().ForEach(oi => oi.ItemIsChecked = _allChecked);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    IsItemCheck = false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public bool _isItemCheck = false;
 | 
				
			||||||
 | 
					        public bool IsItemCheck
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _isItemCheck;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _isItemCheck, value);
 | 
				
			||||||
 | 
					                if (AddChannelStocks.ToList().Where(od => od.ItemIsChecked == false).Count() <= 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    IsAllChecked = true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ChannelStock channelStock = parameters.GetValue<ChannelStock>("addManuno");
 | 
				
			||||||
 | 
					            ChStock = channelStock;
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public AddManunoDialogViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					            //    .Includes(cs => cs.DrugInfo, di => di.DrugManuNos)
 | 
				
			||||||
 | 
					            //    .Where(cs => cs.DrawerNo == ChStock.DrawerNo&&cs.ColNo==ChStock.ColNo)
 | 
				
			||||||
 | 
					            //    .Where(cs => cs.DrawerType == 1)
 | 
				
			||||||
 | 
					            //    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
				
			||||||
 | 
					            //    .Where(cs => cs.DrugId ==ChStock.DrugId )
 | 
				
			||||||
 | 
					            //    .OrderBy(cs => cs.ManuNo)
 | 
				
			||||||
 | 
					            //    .ToList();
 | 
				
			||||||
 | 
					            //ChannelStocks = queryData.Select(cs =>
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    cs.drugManuNo = cs.DrugInfo.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //    return cs;
 | 
				
			||||||
 | 
					            //}).ToList();
 | 
				
			||||||
 | 
					            //obChannelStock = new ObservableCollection<ChannelStock>(ChannelStocks);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            string strSQl = @"SELECT DISTINCT c.Col_no as ColNo,d.DRUG_NAME as DrugName,d.DRUG_SPEC as DrugSpec,m.eff_date as EffDate,m.Manu_No as ManuNo
 | 
				
			||||||
 | 
					                            from drug_manu_no m inner join drug_info d on m.drug_id=d.drug_id  inner join  channel_stock c on m.drug_id=c.drug_id  
 | 
				
			||||||
 | 
					                            where c.row_no=@RowNo and col_no=@ColNo and machine_id=@MachineId and m.Manu_NO<>@ManuNo order by m.Manu_No desc";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            List<AddChannelStockManuNo> queryData = SqlSugarHelper.Db.SqlQueryable<dynamic>(strSQl)
 | 
				
			||||||
 | 
					                .AddParameters(new
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
 | 
				
			||||||
 | 
					                    RowNo = ChStock.DrawerNo,
 | 
				
			||||||
 | 
					                    ColNo = ChStock.ColNo,
 | 
				
			||||||
 | 
					                    ManuNo=ChStock.ManuNo
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .Select(it => new AddChannelStockManuNo())
 | 
				
			||||||
 | 
					                .ToList();
 | 
				
			||||||
 | 
					            AddChannelStocks = new ObservableCollection<AddChannelStockManuNo>(queryData);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand SaveCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand BtnCloseCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 关闭当前窗口
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,506 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class BindingChannelDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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<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 = 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<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.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)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //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);
 | 
				
			||||||
 | 
					                            //});                            //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);
 | 
				
			||||||
 | 
					                            //});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            for (int i = 0; i < SelectChannels.Count; i++)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                var item = SelectChannels[i];
 | 
				
			||||||
 | 
					                                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);
 | 
				
			||||||
 | 
					                                    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.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;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,465 @@
 | 
				
			||||||
 | 
					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 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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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();
 | 
				
			||||||
 | 
					                                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.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.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).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;
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId }).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;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,660 @@
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					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.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Drawing;
 | 
				
			||||||
 | 
					using System.Drawing.Printing;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Reflection.PortableExecutable;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Controls;
 | 
				
			||||||
 | 
					using System.Xml;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ChangeShiftsDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string Title => "交接班";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					        //交班人 发药人
 | 
				
			||||||
 | 
					        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(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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.manunoquantity FROM dm_machine_record d2 WHERE d2.drug_id = c.`drug_id`  and d2.manu_no=c.manu_no  AND d2.operation_time < @beforeDate
 | 
				
			||||||
 | 
					                                    ORDER BY d2.operation_time 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.manunoquantity FROM dm_machine_record d2 WHERE d2.drug_id = d.`drug_id`  and d2.manu_no=d.manu_no  AND d2.operation_time < @beforeDate
 | 
				
			||||||
 | 
					                                    ORDER BY d2.operation_time 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)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                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; }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    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;
 | 
				
			||||||
 | 
					        public ChangeShiftsDialogViewModel(IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,185 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.Report;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 => false;
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ChangeShiftsListWindowViewModel(IDialogService dialogService)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = dialogService;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        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,161 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ChangeShiftsRecordWindowViewModel: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<MachineRecord>? machineRecords;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<MachineRecord>? MachineRecords
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return machineRecords; }
 | 
				
			||||||
 | 
					            set { SetProperty(ref machineRecords, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					        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 ChangeShiftsRecordWindowViewModel(IDialogService dialogService)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService= dialogService;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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,562 @@
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Core;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					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 ChangeShiftsWindowViewModel : BindableBase, IRegionMemberLifetime, IConfirmNavigationRequest
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(LoginWindowViewModel));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //交班人发药人用户名
 | 
				
			||||||
 | 
					        private string jiaoFaUsername = App.CurrentFaUserList.UserName ?? "";
 | 
				
			||||||
 | 
					        public string JiaoFaUsername { get => jiaoFaUsername; set { SetProperty(ref jiaoFaUsername, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //交班人发药人密码
 | 
				
			||||||
 | 
					        private string jiaoFaPassword;
 | 
				
			||||||
 | 
					        public string JiaoFaPassword { get => jiaoFaPassword; set { SetProperty(ref jiaoFaPassword, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //交班人审核人用户名
 | 
				
			||||||
 | 
					        private string jiaoShenUsername = App.CurrentShenUserList.UserName ?? "";
 | 
				
			||||||
 | 
					        public string JiaoShenUsername { get => jiaoShenUsername; set { SetProperty(ref jiaoShenUsername, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //交班人审核人密码
 | 
				
			||||||
 | 
					        private string jiaoShenPassword;
 | 
				
			||||||
 | 
					        public string JiaoShenPassword { get => jiaoShenPassword; set { SetProperty(ref jiaoShenPassword, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接班人发药人用户名
 | 
				
			||||||
 | 
					        private string jieFaUsername;
 | 
				
			||||||
 | 
					        public string JieFaUsername { get => jieFaUsername; set { SetProperty(ref jieFaUsername, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接班人发药人密码
 | 
				
			||||||
 | 
					        private string jieFaPassword;
 | 
				
			||||||
 | 
					        public string JieFaPassword { get => jieFaPassword; set { SetProperty(ref jieFaPassword, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接班人审核人用户名
 | 
				
			||||||
 | 
					        private string jieShenUsername;
 | 
				
			||||||
 | 
					        public string JieShenUsername { get => jieShenUsername; set { SetProperty(ref jieShenUsername, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接班人审核人密码
 | 
				
			||||||
 | 
					        private string jieShenPassword;
 | 
				
			||||||
 | 
					        public string JieShenPassword { get => jieShenPassword; set { SetProperty(ref jieShenPassword, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接班人发药人
 | 
				
			||||||
 | 
					        public UserList Operator { get; set; }
 | 
				
			||||||
 | 
					        //接班人审核人
 | 
				
			||||||
 | 
					        public UserList Reviewer { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private Boolean _loginBtnEnable = true;
 | 
				
			||||||
 | 
					        public Boolean LoginBtnEnable { get { return _loginBtnEnable; } set { SetProperty(ref _loginBtnEnable, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string firstLogin = ConfigurationManager.AppSettings["firstLogin"]?.ToString() ?? "operator";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //交班确认按钮是否可用
 | 
				
			||||||
 | 
					        private bool _jieBanOk = true;
 | 
				
			||||||
 | 
					        public bool JieBanOk { get => _jieBanOk; set { SetProperty(ref _jieBanOk, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接班确认按钮是否可用
 | 
				
			||||||
 | 
					        private bool _jiaoBanOk = true;
 | 
				
			||||||
 | 
					        public bool JiaoBanOk { get => _jiaoBanOk; set { SetProperty(ref _jiaoBanOk, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IRegionManager _regionManager;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _fingerMsg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool FingerMsg
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _fingerMsg;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _fingerMsg, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ChangeShiftsWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 交班确认按钮
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool JiaoBanFYRFlag = false; //交班发药人flag
 | 
				
			||||||
 | 
					        private bool JiaoBanSHRFlag = false; //交班审核人flag
 | 
				
			||||||
 | 
					        public DelegateCommand JiaobanCommand => new DelegateCommand(JiaoBanAction);
 | 
				
			||||||
 | 
					        private void JiaoBanAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(JiaoFaUsername) && !string.IsNullOrEmpty(JiaoFaPassword))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                JiaoBanFYRFlag = ChangeShiftsLogin(JiaoFaUsername.Trim(), JiaoFaPassword.Trim());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (!string.IsNullOrEmpty(JiaoShenUsername) && !string.IsNullOrEmpty(JiaoShenPassword))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                JiaoBanSHRFlag = ChangeShiftsLogin(JiaoShenUsername.Trim(), JiaoShenPassword.Trim());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //提示:请输入交班人中发药人或审核人的用户名密码
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "请输入交班人中发药人或审核人的用户名密码",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (JiaoBanFYRFlag || JiaoBanSHRFlag)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                JiaoBanOk = false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion  交班确认按钮
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 接班确认按钮
 | 
				
			||||||
 | 
					        private bool JieBanFYRFlag = false; //接班发药人flag
 | 
				
			||||||
 | 
					        private bool JieBanSHRFlag = false; //接班审核人flag
 | 
				
			||||||
 | 
					        public DelegateCommand JiebanCommand => new DelegateCommand(JiebanAction);
 | 
				
			||||||
 | 
					        private void JiebanAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(JieFaUsername) && !string.IsNullOrEmpty(JieFaPassword))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                ChangeShiftsForJieLogin(JieFaUsername.Trim(), JieFaPassword.Trim());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (!string.IsNullOrEmpty(JieShenUsername) && !string.IsNullOrEmpty(JieShenPassword))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                ChangeShiftsForJieLogin(JieShenUsername.Trim(), JieShenPassword.Trim());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //提示:请输入接班人中发药人或审核人的用户名密码
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "请输入接班人中发药人或审核人的用户名密码",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (JieBanFYRFlag || JieBanSHRFlag)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                JieBanOk = false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion 接班确认按钮
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 清空按钮
 | 
				
			||||||
 | 
					        public DelegateCommand ClearOneCommand => new DelegateCommand(ClearAction);
 | 
				
			||||||
 | 
					        private void ClearAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            JiaoFaPassword = string.Empty;
 | 
				
			||||||
 | 
					            JiaoShenPassword = string.Empty;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 接班人清空按钮
 | 
				
			||||||
 | 
					        public DelegateCommand ClearTwoCommand => new DelegateCommand(ClearTwoAction);
 | 
				
			||||||
 | 
					        private void ClearTwoAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            JieFaUsername = string.Empty;
 | 
				
			||||||
 | 
					            JieFaPassword = string.Empty;
 | 
				
			||||||
 | 
					            JieShenUsername = string.Empty;
 | 
				
			||||||
 | 
					            JieShenPassword = string.Empty;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 确认交接
 | 
				
			||||||
 | 
					        public DelegateCommand ShiftsCommand => new DelegateCommand(ShiftsAction);
 | 
				
			||||||
 | 
					        private void ShiftsAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //1验证交班人与接班人是否都已登录验证2写交接信息
 | 
				
			||||||
 | 
					            if ((JiaoBanFYRFlag || JiaoBanSHRFlag) && (JieBanFYRFlag || JieBanSHRFlag))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //保存交接班信息(查询当前值班人的最后一条交接班信息(如有则修改状态,没有则插入一条)并写入一条接班人信息)
 | 
				
			||||||
 | 
					                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    List<HkcChangeShifts> listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
 | 
				
			||||||
 | 
					                      .Where(cs => cs.State == "0")
 | 
				
			||||||
 | 
					                      .WhereIF(App.CurrentFaUserList != null && !string.IsNullOrEmpty(App.CurrentFaUserList.UserName), cs => cs.FromOperator == App.CurrentFaUserList.UserName)
 | 
				
			||||||
 | 
					                      .WhereIF(App.CurrentShenUserList != null && !string.IsNullOrEmpty(App.CurrentShenUserList.UserName), cs => cs.FromRviewer == App.CurrentShenUserList.UserName)
 | 
				
			||||||
 | 
					                      .OrderByDescending(cs => cs.OptState)
 | 
				
			||||||
 | 
					                      .ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //List<MachineRecord> listMachineRecord=SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
				
			||||||
 | 
					                    //.Where(m=>)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (listHkcChangeShifts != null && listHkcChangeShifts.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //存在则修改,不存在则插入一条
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Updateable(new HkcChangeShifts()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Id = listHkcChangeShifts[0].Id,
 | 
				
			||||||
 | 
					                            ToOperator = Operator == null ? "" : Operator.UserName,
 | 
				
			||||||
 | 
					                            ToReviewer = Reviewer == null ? "" : Reviewer.UserName,
 | 
				
			||||||
 | 
					                            State = "1",
 | 
				
			||||||
 | 
					                            OptState = "1",
 | 
				
			||||||
 | 
					                            ToDate = DateTime.Now
 | 
				
			||||||
 | 
					                        }).UpdateColumns(it => new { it.ToOperator, it.ToReviewer, it.State, it.OptState,it.ToDate }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            FromOperator = App.CurrentFaUserList.UserName,
 | 
				
			||||||
 | 
					                            FromRviewer = App.CurrentShenUserList.UserName,
 | 
				
			||||||
 | 
					                            ToOperator = Operator == null ? "" : Operator.UserName,
 | 
				
			||||||
 | 
					                            ToReviewer = Reviewer == null ? "" : Reviewer.UserName,
 | 
				
			||||||
 | 
					                            State = "1",
 | 
				
			||||||
 | 
					                            OptState = "0",
 | 
				
			||||||
 | 
					                            OptDate = DateTime.Now
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        FromOperator = App.CurrentFaUserList.UserName,
 | 
				
			||||||
 | 
					                        FromRviewer = App.CurrentShenUserList.UserName,
 | 
				
			||||||
 | 
					                        State = "0",
 | 
				
			||||||
 | 
					                        OptState = "0",
 | 
				
			||||||
 | 
					                        OptDate = DateTime.Now,
 | 
				
			||||||
 | 
					                        ToDate = DateTime.Now
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                if (f.Data)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    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);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion 确认交接
 | 
				
			||||||
 | 
					        private NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					        bool ChangeShiftsLogin(string userName, string passWord)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            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 = "";
 | 
				
			||||||
 | 
					                        passWord = "";
 | 
				
			||||||
 | 
					                        return false;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (userList.Role == null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "用户还未设置权限,请联系管理员",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        userName = "";
 | 
				
			||||||
 | 
					                        passWord = "";
 | 
				
			||||||
 | 
					                        return false;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (userList.PassWord == MD5.GetMD5Hash(passWord))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (userList.UserName == App.CurrentShenUserList.UserName)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                //交班人  指纹验证发药人成功
 | 
				
			||||||
 | 
					                                JiaoBanFYRFlag = true;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else if (userList.UserName == App.CurrentFaUserList.UserName)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                //交班人  指纹验证审核人成功
 | 
				
			||||||
 | 
					                                JiaoBanSHRFlag = true;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                //接班人登录
 | 
				
			||||||
 | 
					                                SetUser(userList);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            return true;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "密码错误",
 | 
				
			||||||
 | 
					                                Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                            passWord = "";
 | 
				
			||||||
 | 
					                            return false;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "请输入账号或密码",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //LoginBtnEnable = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void ChangeShiftsForJieLogin(string userName, string passWord)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            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 = "";
 | 
				
			||||||
 | 
					                        passWord = "";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (userList.Role == null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "用户还未设置权限,请联系管理员",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        userName = "";
 | 
				
			||||||
 | 
					                        passWord = "";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (userList.PassWord == MD5.GetMD5Hash(passWord))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //接班人登录
 | 
				
			||||||
 | 
					                            SetUser(userList);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "密码错误",
 | 
				
			||||||
 | 
					                                Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                            passWord = "";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "请输入账号或密码",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //LoginBtnEnable = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        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
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (userList.UserName == App.CurrentShenUserList.UserName)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //交班人  指纹验证发药人成功
 | 
				
			||||||
 | 
					                            JiaoBanFYRFlag = true;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (userList.UserName == App.CurrentFaUserList.UserName)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //交班人  指纹验证审核人成功
 | 
				
			||||||
 | 
					                            JiaoBanSHRFlag = true;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //接班人登录
 | 
				
			||||||
 | 
					                            SetUser(userList);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (JiaoBanFYRFlag || JiaoBanSHRFlag)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            JiaoBanOk = false;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if (JieBanFYRFlag || JieBanSHRFlag)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            JieBanOk = false;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void SetUser(UserList user)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 双人登录模式
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 如果已经录入了发药人,已经有一个用户登录
 | 
				
			||||||
 | 
					                if (keys.ContainsKey("operator"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (keys.GetValue<UserList>("operator").Id != user.Id)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        keys.Add("reviewer", user);
 | 
				
			||||||
 | 
					                        Reviewer = user;
 | 
				
			||||||
 | 
					                        JieBanFYRFlag = true;
 | 
				
			||||||
 | 
					                        //RaisePropertyChanged("Reviewer");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    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);
 | 
				
			||||||
 | 
					                        Operator = user;
 | 
				
			||||||
 | 
					                        //RaisePropertyChanged("Operator");
 | 
				
			||||||
 | 
					                        JieBanSHRFlag = true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "该审核人账号已登录,请输入不同账号",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                // 第一个用户登录
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (firstLogin.Equals("operator"))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        keys.Add("operator", user);
 | 
				
			||||||
 | 
					                        Operator = user;
 | 
				
			||||||
 | 
					                        JieBanFYRFlag = true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        keys.Add("reviewer", user);
 | 
				
			||||||
 | 
					                        Reviewer = user;
 | 
				
			||||||
 | 
					                        JieBanSHRFlag = true;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            continuationCallback(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            FingerMsg = false;// !_fingerprintUtil.bIsConnected;
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(ChangeShiftsLoginEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Unsubscribe(ChangeShiftsLoginEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,319 @@
 | 
				
			||||||
 | 
					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 DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class CheckStockWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(CheckStockWindowViewModel));
 | 
				
			||||||
 | 
					        private List<ChannelStock> _channelStocks = new();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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 CheckStockWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (msg.WindowName == "CheckStockWindow")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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 + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                _portUtil.WindowName = "CheckStockWindow";
 | 
				
			||||||
 | 
					                _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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }, () => Status == 0).ObservesProperty(() => Status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _isFinishClick = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 完成按钮
 | 
				
			||||||
 | 
					        public DelegateCommand TakeFinish
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _isFinishClick = true;
 | 
				
			||||||
 | 
					                //List<ChannelStock> record = ChannelStocks.FindAll(it => it.Quantity != it.CheckQuantity).ToList();
 | 
				
			||||||
 | 
					                List<ChannelStock> record = ChannelStocks;
 | 
				
			||||||
 | 
					                if (record.Count > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    string InvoiceId = "CHECK_" + 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.CheckQuantity,
 | 
				
			||||||
 | 
					                                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.CheckQuantity - it.Quantity,
 | 
				
			||||||
 | 
					                                Type = 4,
 | 
				
			||||||
 | 
					                                InvoiceId = InvoiceId,
 | 
				
			||||||
 | 
					                                StockQuantity = nowChannels.Sum(it => it.Quantity),
 | 
				
			||||||
 | 
					                                CheckQuantity = it.CheckQuantity,
 | 
				
			||||||
 | 
					                                ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            logger.Info($"库存盘点->库位【{it.DrawerNo}-{it.ColNo}】药品【{it.DrugInfo.DrugName}】盘点前库存【{it.Quantity}】,更改后【{it.CheckQuantity}】");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        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.CheckQuantity);
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        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);
 | 
				
			||||||
 | 
					                    Status = 0;
 | 
				
			||||||
 | 
					                    _isFinishClick = false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }, () => Status == 3 && !_isFinishClick).ObservesProperty(() => Status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 取消按钮
 | 
				
			||||||
 | 
					        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 = 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)
 | 
				
			||||||
 | 
					                .Where(cs => cs.DrawerNo == DrawerNo)
 | 
				
			||||||
 | 
					                .Where(cs => cs.DrugId != null)
 | 
				
			||||||
 | 
					                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
				
			||||||
 | 
					                .OrderBy(cs => cs.ColNo)
 | 
				
			||||||
 | 
					                .ToList();
 | 
				
			||||||
 | 
					            ChannelStocks = queryData.Select(it => { it.CheckQuantity = it.Quantity; return it; }).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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,6 @@
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class CollectionViewGroupInternal
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,392 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using Prism.Services.Dialogs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 string _pzh;
 | 
				
			||||||
 | 
					        public string PZH { get => _pzh; set { SetProperty(ref _pzh, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock>? _channelStocks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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 ObservableCollection<ChannelStock> _obChannelStock=new ObservableCollection<ChannelStock>();
 | 
				
			||||||
 | 
					        //public ObservableCollection<ChannelStock> obChannelStock
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _obChannelStock;
 | 
				
			||||||
 | 
					        //    set=>SetProperty(ref _obChannelStock, value);
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static readonly DateTime Jan1st1970 = new DateTime
 | 
				
			||||||
 | 
					    (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        public DrawerAddDrugWindowViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = DialogService;
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        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 == "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;
 | 
				
			||||||
 | 
					                _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    List<ChannelStock> singleChannels = ChannelStocks.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;
 | 
				
			||||||
 | 
					                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
 | 
				
			||||||
 | 
					                    if (record.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //string InvoiceId = "DRAWER_" + CurrentTimeMillis();
 | 
				
			||||||
 | 
					                        string InvoiceId = PZH;
 | 
				
			||||||
 | 
					                        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,
 | 
				
			||||||
 | 
					                                    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)
 | 
				
			||||||
 | 
					                                }).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.AddQuantity);
 | 
				
			||||||
 | 
					                                });
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            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 DelegateCommand ComboboxSelected
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                ChannelStocks.Where(it => it.Location == "").Select(it => it.ManuNo = "12").ToList();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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<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();
 | 
				
			||||||
 | 
					             //obChannelStock = new ObservableCollection<ChannelStock>(ChannelStocks);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,334 @@
 | 
				
			||||||
 | 
					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 + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    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.Stocks = singleChannels.Select(it => it.Quantity).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),
 | 
				
			||||||
 | 
					                                    ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                                }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                logger.Info($"抽屉取药保存->库位【{it.DrawerNo}-{it.ColNo}】取出药品【{it.DrugInfo.DrugName}】个数【{it.TakeQuantity}】,取药前库存【{it.Quantity}】");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            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);
 | 
				
			||||||
 | 
					                                });
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            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 = 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)
 | 
				
			||||||
 | 
					                .Where(cs => cs.DrawerNo == DrawerNo)
 | 
				
			||||||
 | 
					                .Where(cs => cs.DrugId != null)
 | 
				
			||||||
 | 
					                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
				
			||||||
 | 
					                .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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,283 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        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
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //SelectedDrug.DrugId = 0;
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(SelectedDrug).ExecuteCommand();
 | 
				
			||||||
 | 
					                    RequestData();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ILog logger = LogManager.GetLogger(typeof(DrugListWindowViewModel));
 | 
				
			||||||
 | 
					                    logger.Info($"添加数据异常:{ex.ToString()}");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand EditDrugCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Updateable(SelectedDrug).UpdateColumns(d => new { d.DrugName, d.Manufactory, d.PyCode, d.PackUnit, d.MaxStock, d.DrugSpec }).ExecuteCommand();
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand AddManuCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!string.IsNullOrEmpty(SelectedManuno.EffDate) && !string.IsNullOrEmpty(SelectedManuno.ManuNo))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SelectedManuno.Id = Guid.NewGuid().ToString();
 | 
				
			||||||
 | 
					                    SelectedManuno.DrugId = SelectedDrug.DrugId.ToString();
 | 
				
			||||||
 | 
					                    SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(SelectedManuno).ExecuteCommand();
 | 
				
			||||||
 | 
					                    GetManuNos();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand EditManuCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Updateable(SelectedManuno).UpdateColumns(m => new { m.ManuNo, m.EffDate }).ExecuteCommand();
 | 
				
			||||||
 | 
					                GetManuNos();
 | 
				
			||||||
 | 
					            }, () => !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>()
 | 
				
			||||||
 | 
					                .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)
 | 
				
			||||||
 | 
					            ;
 | 
				
			||||||
 | 
					            TotalCount = totalCount;
 | 
				
			||||||
 | 
					            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,210 @@
 | 
				
			||||||
 | 
					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.Windows;
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class EditUserDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public EditUserDialogViewModel(FingerprintUtil fingerprintUtil, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private UserList _userList = new UserList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public UserList UserList
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _userList;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _userList, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<RoleDm> Roles { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _oldPass;
 | 
				
			||||||
 | 
					        public string OldPass
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _oldPass;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (string.IsNullOrEmpty(value))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    throw new ArgumentException("请输入原密码");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (!MD5.GetMD5Hash(value).ToLower().Equals(UserList.PassWord.ToLower()))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    throw new ArgumentException("旧密码错误");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                SetProperty(ref _oldPass, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private string _newPass;
 | 
				
			||||||
 | 
					        public string NewPass
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _newPass; set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (string.IsNullOrEmpty(value))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    throw new ArgumentNullException("请输入新密码");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                SetProperty(ref _newPass, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _onlyPassword = false;
 | 
				
			||||||
 | 
					        private bool _editUser = true;
 | 
				
			||||||
 | 
					        public bool OnlyPassword { get => _onlyPassword; set => SetProperty(ref _onlyPassword, value); }
 | 
				
			||||||
 | 
					        public bool EditUser { get => _editUser; set => SetProperty(ref _editUser, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _title = "编辑用户";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string Title
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _title;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _title, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand SaveUser
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // 修改密码
 | 
				
			||||||
 | 
					                    if (OnlyPassword)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (MD5.GetMD5Hash(OldPass).ToLower().Equals(UserList.PassWord.ToLower()))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            // 旧密码输入正确
 | 
				
			||||||
 | 
					                            UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.PassWord }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            // 关闭当前窗口
 | 
				
			||||||
 | 
					                            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    // 保存用户
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (UserList.Id > 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            // 更新
 | 
				
			||||||
 | 
					                            // 没有写密码
 | 
				
			||||||
 | 
					                            if (string.IsNullOrEmpty(NewPass))
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.UserBarcode, u.RoleId }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            // 更改了密码
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
				
			||||||
 | 
					                            UserList.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
				
			||||||
 | 
					                            // 插入
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Insertable<UserList>(UserList).InsertColumns(u => new { u.Id, u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId, u.MachineId }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = $"保存用户信息异常{ex.Message}",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void GetAllRole()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Roles = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).OrderBy(r => r.Id).ToList();
 | 
				
			||||||
 | 
					            RaisePropertyChanged("Roles");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand CancelCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 关闭当前窗口
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (parameters.ContainsKey("EditPass"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                UserList = parameters.GetValue<UserList>("User");
 | 
				
			||||||
 | 
					                OnlyPassword = parameters.GetValue<bool>("EditPass");
 | 
				
			||||||
 | 
					                EditUser = false;
 | 
				
			||||||
 | 
					                Title = "修改密码";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (parameters.ContainsKey("User"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    UserList = parameters.GetValue<UserList>("User");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (UserList.Id == null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Title = "添加用户";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                GetAllRole();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,133 @@
 | 
				
			||||||
 | 
					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.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class FingerprintDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(FingerprintDialogViewModel));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					        EventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public FingerprintDialogViewModel(FingerprintUtil fingerprintUtil, EventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public UserList UserList { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Dictionary<string, int> FingerIndexs
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Dictionary<string, int> l = new Dictionary<string, int>();
 | 
				
			||||||
 | 
					                l.Add("左小拇指", 0);
 | 
				
			||||||
 | 
					                l.Add("左无名指", 1);
 | 
				
			||||||
 | 
					                l.Add("左中指", 2);
 | 
				
			||||||
 | 
					                l.Add("左食指", 3);
 | 
				
			||||||
 | 
					                l.Add("左大拇指", 4);
 | 
				
			||||||
 | 
					                l.Add("右小拇指", 5);
 | 
				
			||||||
 | 
					                l.Add("右无名指", 6);
 | 
				
			||||||
 | 
					                l.Add("右中指", 7);
 | 
				
			||||||
 | 
					                l.Add("右食指", 8);
 | 
				
			||||||
 | 
					                l.Add("右大拇指", 9);
 | 
				
			||||||
 | 
					                return l;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _fingerIndex = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int FingerIndex
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _fingerIndex;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _fingerIndex, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Status
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _status;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _status, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string Title => "录入指纹";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand StartInsert
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => {
 | 
				
			||||||
 | 
					                Status = 1;
 | 
				
			||||||
 | 
					                _fingerprintUtil.SaveUser(UserList);
 | 
				
			||||||
 | 
					                _fingerprintUtil.SaveFingerprint(UserList.Id, FingerIndex);
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
 | 
					            }, () => Status == 0).ObservesProperty(() => Status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand CancelCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 关闭当前窗口
 | 
				
			||||||
 | 
					                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Unsubscribe(RegEvent1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            UserList = parameters.GetValue<UserList>("User");
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(RegEvent1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void RegEvent1(FingerprintMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info(msg.ToString()); ;
 | 
				
			||||||
 | 
					            if (Status == 1)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (msg.Message.Equals("INS_FINGER"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (msg.Result)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Status = 0;
 | 
				
			||||||
 | 
					                        // 关闭当前窗口
 | 
				
			||||||
 | 
					                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,316 @@
 | 
				
			||||||
 | 
					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.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Controls;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using DM_Weight.Views;
 | 
				
			||||||
 | 
					using System.Timers;
 | 
				
			||||||
 | 
					using Unity;
 | 
				
			||||||
 | 
					using System.Windows.Threading;
 | 
				
			||||||
 | 
					using Newtonsoft.Json.Linq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class HomeWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindowViewModel));
 | 
				
			||||||
 | 
					        private readonly IDialogService _dialogService;
 | 
				
			||||||
 | 
					        private UserList? _userList;
 | 
				
			||||||
 | 
					        private UserList? _userList2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
 | 
				
			||||||
 | 
					        public bool MultiLogin
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => loginMode == 2;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PremissionDm? _selectedMenu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PremissionDm? _selectedChildMenu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<PremissionDm>? _premissionDmList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public PremissionDm? SelectedChildMenu
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selectedChildMenu; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!_portUtil.Operate)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (value != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (value.PremissionPath.Equals("TakeRecordWindow"))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //定义传参变量
 | 
				
			||||||
 | 
					                            NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            //添加参数,键值对格式
 | 
				
			||||||
 | 
					                            keys.Add("Type", 2);
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (value.PremissionPath.Equals("AddRecordWindow"))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //定义传参变量
 | 
				
			||||||
 | 
					                            NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            //添加参数,键值对格式
 | 
				
			||||||
 | 
					                            keys.Add("Type", 1);
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (value.PremissionPath.Equals("ReturnRecordWindow"))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //定义传参变量
 | 
				
			||||||
 | 
					                            NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            //添加参数,键值对格式
 | 
				
			||||||
 | 
					                            keys.Add("Type", 3);
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow"))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //定义传参变量
 | 
				
			||||||
 | 
					                            NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            //添加参数,键值对格式
 | 
				
			||||||
 | 
					                            keys.Add("Type", 3);
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (value.PremissionPath.Equals("CheckRecordWindow"))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //定义传参变量
 | 
				
			||||||
 | 
					                            NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            //添加参数,键值对格式
 | 
				
			||||||
 | 
					                            keys.Add("Type", 4);
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    SetProperty(ref _selectedChildMenu, value);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public PremissionDm? SelectedMenu
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _selectedMenu; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (value != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (value.PremissionName == "退出")
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        logger.Info($"用户【{Operator?.Nickname}】退出登录");
 | 
				
			||||||
 | 
					                        Operator = null;
 | 
				
			||||||
 | 
					                        Reviewer = null;
 | 
				
			||||||
 | 
					                        _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SelectedChildMenu = value.Children[0];
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                SetProperty(ref _selectedMenu, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DelegateCommand<ListBox> _selectionCommon;
 | 
				
			||||||
 | 
					        public DelegateCommand<ListBox> SelectionCommon
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _selectionCommon ?? (_selectionCommon = new DelegateCommand<ListBox>(SelectionMethod));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SelectionMethod(ListBox viewName)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            SelectedMenu = viewName.SelectedItem as PremissionDm;
 | 
				
			||||||
 | 
					            if (SelectedMenu.PremissionName == "退出")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"用户【{Operator?.Nickname}】退出登录");
 | 
				
			||||||
 | 
					                Operator = null;
 | 
				
			||||||
 | 
					                Reviewer = null;
 | 
				
			||||||
 | 
					                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SelectedMenu.Children = SelectedMenu.Children;
 | 
				
			||||||
 | 
					                SelectedChildMenu = SelectedMenu.Children[0];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<PremissionDm> PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public UserList UserList { get { return _userList; } set { SetProperty(ref _userList, value); } }
 | 
				
			||||||
 | 
					        public UserList UserList2 { get { return _userList2; } set { SetProperty(ref _userList2, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static UserList? Operator;
 | 
				
			||||||
 | 
					        public static UserList? Reviewer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IRegionManager _regionManager;
 | 
				
			||||||
 | 
					        IUnityContainer _container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _is16Drawer;
 | 
				
			||||||
 | 
					        public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _regionManager = iRegionManager;
 | 
				
			||||||
 | 
					            _dialogService = dialogService;
 | 
				
			||||||
 | 
					            _container = container;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand<string> OpenFingerDialog
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<string>((string Type) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                dialogParameters.Add("User", Type.Equals("Operator") ? Operator : Reviewer);
 | 
				
			||||||
 | 
					                DialogServiceExtensions.ShowDialogHost(_dialogService, "FingerprintDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand OpenRecoverCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(async () =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _portUtil.WindowName = "HomeWindow";
 | 
				
			||||||
 | 
					                    _portUtil.Operate = true;
 | 
				
			||||||
 | 
					                    await _portUtil.OpenStorage();
 | 
				
			||||||
 | 
					                    _portUtil.ResetData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    logger.Info($"OpenRecoverCommand异常{ex.Message}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand<string> OpenEditPasswordDialog
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<string>((string Type) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                dialogParameters.Add("EditPass", true);
 | 
				
			||||||
 | 
					                dialogParameters.Add("User", Type.Equals("Operator") ? Operator : Reviewer);
 | 
				
			||||||
 | 
					                DialogServiceExtensions.ShowDialogHost(_dialogService, "EditUserDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void DoDialogResult(IDialogResult dialogResult)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 委托   被动执行     被子窗口执行
 | 
				
			||||||
 | 
					            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
				
			||||||
 | 
					            if (dialogResult.Result == ButtonResult.OK)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //交接班
 | 
				
			||||||
 | 
					        public DelegateCommand ShiftsCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(ShiftsAction);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void ShiftsAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _regionManager.RequestNavigate("ContentRegion", "ChangeShiftsWindow");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Is16Drawer = count == 16;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
				
			||||||
 | 
					        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            continuationCallback(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接收导航传过来的参数
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil.dateTime = DateTime.Now;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //取出user
 | 
				
			||||||
 | 
					            UserList = navigationContext.Parameters.GetValue<UserList>("operator");
 | 
				
			||||||
 | 
					            Operator = UserList;
 | 
				
			||||||
 | 
					            logger.Info($"发药人【{Operator.Nickname}】登录");
 | 
				
			||||||
 | 
					            if (navigationContext.Parameters.ContainsKey("reviewer"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                UserList2 = navigationContext.Parameters.GetValue<UserList>("reviewer");
 | 
				
			||||||
 | 
					                Reviewer = UserList2;
 | 
				
			||||||
 | 
					                logger.Info($"审核人【{Reviewer.Nickname}】登录");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            List<PremissionDm> premissions = UserList.Role.Permissions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //SqlSugarHelper.Db.SqlQueryable<PremissionDm>(sql)
 | 
				
			||||||
 | 
					            //.ToTree(pd => pd.Children, pd => pd.ParentId, 0);
 | 
				
			||||||
 | 
					            PremissionDmList = premissions;
 | 
				
			||||||
 | 
					            SelectedMenu = premissions[0];
 | 
				
			||||||
 | 
					            FindDrawerCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
				
			||||||
 | 
					            if (autoExit > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Timer timer = new Timer();
 | 
				
			||||||
 | 
					                timer.Interval = 1000;
 | 
				
			||||||
 | 
					                timer.Elapsed += (sender, e) =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 串口无人操作
 | 
				
			||||||
 | 
					                    if (!_portUtil.Operate)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // 30秒内无人操作鼠标键盘
 | 
				
			||||||
 | 
					                        if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
 | 
				
			||||||
 | 
					                            Operator = null;
 | 
				
			||||||
 | 
					                            Reviewer = null;
 | 
				
			||||||
 | 
					                            Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					                                timer.Stop();
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                timer.Start();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,355 @@
 | 
				
			||||||
 | 
					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.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);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                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);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (_portUtil.DrawerNo != 0 && _portUtil.DrawerNo < 9 && DrawerNo > 8)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Thread.Sleep(50);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            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.Stocks = singleChannels.Select(it => it.Quantity).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),
 | 
				
			||||||
 | 
					                                ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                            }).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.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,384 @@
 | 
				
			||||||
 | 
					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> iChannelStockList = 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;
 | 
				
			||||||
 | 
					                        iChannelStockList.Add(item);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    InOutInvoice copy = TransExpV2<InOutInvoice, InOutInvoice>.Trans(invoice);
 | 
				
			||||||
 | 
					                    InOutInvoices.Add(copy);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            ICollectionView vw = CollectionViewSource.GetDefaultView(iChannelStockList);
 | 
				
			||||||
 | 
					            vw.GroupDescriptions.Add(new PropertyGroupDescription("Invoice"));
 | 
				
			||||||
 | 
					            ChannelStocks = iChannelStockList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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_id = i.in_pharmacy_id");
 | 
				
			||||||
 | 
					            sb.Append(" left join pharmacy_info p2 on p2.pharmacy_id = 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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,270 @@
 | 
				
			||||||
 | 
					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_id = i.in_pharmacy_id");
 | 
				
			||||||
 | 
					            sb.Append(" left join pharmacy_info p2 on p2.pharmacy_id = 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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,424 @@
 | 
				
			||||||
 | 
					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);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                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);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 发送取药数量
 | 
				
			||||||
 | 
					            singleChannels.ForEach(it =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (_portUtil.DrawerNo != 0 && _portUtil.DrawerNo < 9 && DrawerNo > 8)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Thread.Sleep(50);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            _portUtil.WindowName = "InvoiceTakeDrugWindow";
 | 
				
			||||||
 | 
					            _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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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),
 | 
				
			||||||
 | 
					                                    ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                                }).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.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,396 @@
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Core;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Ioc;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.ComponentModel;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using DM_Weight.Views;
 | 
				
			||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using Microsoft.Win32;
 | 
				
			||||||
 | 
					using System.Xml;
 | 
				
			||||||
 | 
					using System.Diagnostics;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using SQLitePCL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class LoginWindowViewModel : BindableBase, IRegionMemberLifetime, IConfirmNavigationRequest
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(LoginWindowViewModel));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string username;
 | 
				
			||||||
 | 
					        private string password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private Boolean _loginBtnEnable = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IRegionManager _regionManager;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
 | 
				
			||||||
 | 
					        private string firstLogin = ConfigurationManager.AppSettings["firstLogin"]?.ToString() ?? "operator";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool SingleLogin
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => ReadAppSetting("loginMode") == "1";
 | 
				
			||||||
 | 
					            //get => loginMode == 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public bool MultiLogin
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //get => loginMode == 2;
 | 
				
			||||||
 | 
					            get => ReadAppSetting("loginMode") == "2";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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 UserList _operator;
 | 
				
			||||||
 | 
					        public UserList Operator { get => _operator; set { SetProperty(ref _operator, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private UserList _reviewer;
 | 
				
			||||||
 | 
					        public UserList Reviewer { get => _reviewer; set { SetProperty(ref _reviewer, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool DrawerPortMsg
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => !_portUtil.drawerSerial.IsOpen;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public bool CanBusPortMsg
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _fingerMsg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool FingerMsg
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _fingerMsg;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _fingerMsg, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
 | 
					        //    _portUtil = portUtil;
 | 
				
			||||||
 | 
					        //    _regionManager = regionManager;
 | 
				
			||||||
 | 
					        //    _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //_fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private DelegateCommand? _loginCommand;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DelegateCommand? _exitCommand;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand LoginCommand =>
 | 
				
			||||||
 | 
					_loginCommand ??= new DelegateCommand(Login);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand ExitCommand =>
 | 
				
			||||||
 | 
					_exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void Login()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            LoginBtnEnable = false;
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (Username.Equals("hkcadmin") && Password.Equals("hkc123"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ObservableCollection<PremissionDm> defaultAll = RoleManagerWindowViewModel.defaultAll;
 | 
				
			||||||
 | 
					                    PremissionDm[] a = new PremissionDm[defaultAll.Count];
 | 
				
			||||||
 | 
					                    Array.Copy(defaultAll.ToArray(), 0, a, 0, defaultAll.Count);
 | 
				
			||||||
 | 
					                    a[4].Children.Add(new PremissionDm()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Id = 54,
 | 
				
			||||||
 | 
					                        PremissionName = "调试页面",
 | 
				
			||||||
 | 
					                        PremissionPath = "DebugWindow",
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    //添加参数,键值对格式
 | 
				
			||||||
 | 
					                    keys.Add("operator", new UserList()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        UserName = Username,
 | 
				
			||||||
 | 
					                        Nickname = "华康测试账号",
 | 
				
			||||||
 | 
					                        Id = 9999,
 | 
				
			||||||
 | 
					                        Role = new RoleDm()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Id = 9999,
 | 
				
			||||||
 | 
					                            RoleName = "hkcadmin",
 | 
				
			||||||
 | 
					                            Permissions = a.ToList()
 | 
				
			||||||
 | 
					                        },
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //                    .Includes<RoleDm>(u => u.Role)
 | 
				
			||||||
 | 
					                    //                    .First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    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 = "";
 | 
				
			||||||
 | 
					                        Password = "";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (userList.Role == null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "用户还未设置权限,请联系管理员",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        Username = "";
 | 
				
			||||||
 | 
					                        Password = "";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (userList.PassWord == MD5.GetMD5Hash(Password))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            SetUser(userList);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Message = "密码错误",
 | 
				
			||||||
 | 
					                                Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                            Password = "";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "请输入账号或密码",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            LoginBtnEnable = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        async void SetUser(UserList user)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 单人登录模式
 | 
				
			||||||
 | 
					            if (SingleLogin)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                App.CurrentFaUserList = user;
 | 
				
			||||||
 | 
					                //添加参数,键值对格式
 | 
				
			||||||
 | 
					                keys.Add("operator", user);
 | 
				
			||||||
 | 
					                //_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
 | 
					                await System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
 | 
					                }));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // 双人登录模式
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 如果已经录入了发药人,已经有一个用户登录
 | 
				
			||||||
 | 
					                if (keys.ContainsKey("operator"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (keys.GetValue<UserList>("operator").Id != user.Id)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        keys.Add("reviewer", user);
 | 
				
			||||||
 | 
					                        Reviewer = user;
 | 
				
			||||||
 | 
					                        //RaisePropertyChanged("Reviewer");
 | 
				
			||||||
 | 
					                        App.CurrentShenUserList = user;
 | 
				
			||||||
 | 
					                        //_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
 | 
					                        await System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
 | 
					                        }));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    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);
 | 
				
			||||||
 | 
					                        Operator = user;
 | 
				
			||||||
 | 
					                        //RaisePropertyChanged("Operator");
 | 
				
			||||||
 | 
					                        App.CurrentFaUserList = user;
 | 
				
			||||||
 | 
					                        _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
 | 
					                        await System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
 | 
					                          {
 | 
				
			||||||
 | 
					                              _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
 | 
					                          }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = "该审核人账号已登录,请输入不同账号",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                // 第一个用户登录
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (firstLogin.Equals("operator"))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        keys.Add("operator", user);
 | 
				
			||||||
 | 
					                        Operator = user;
 | 
				
			||||||
 | 
					                        //RaisePropertyChanged("Operator");
 | 
				
			||||||
 | 
					                        App.CurrentFaUserList = user;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        keys.Add("reviewer", user);
 | 
				
			||||||
 | 
					                        Reviewer = user;
 | 
				
			||||||
 | 
					                        //RaisePropertyChanged("Reviewer");
 | 
				
			||||||
 | 
					                        App.CurrentShenUserList = user;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    Username = string.Empty;
 | 
				
			||||||
 | 
					                    Password = string.Empty;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void Exit()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Process.GetCurrentProcess().Kill();
 | 
				
			||||||
 | 
					            //System.Diagnostics.Process tt = System.Diagnostics.Process.GetProcessById(System.Diagnostics.Process.GetCurrentProcess().Id); 
 | 
				
			||||||
 | 
					            //tt.Kill();
 | 
				
			||||||
 | 
					            Environment.Exit(0);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void LoginEvent(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
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SetUser(userList);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
				
			||||||
 | 
					        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            continuationCallback(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            FingerMsg = false;// !_fingerprintUtil.bIsConnected;
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Unsubscribe(LoginEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
 | 
				
			||||||
 | 
					        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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,302 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					using System.Reflection.PortableExecutable;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class MachineRecordWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static MachineRecordWindowViewModel vm;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        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 DrugInfo? _drugInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DrugInfo? DrugInfo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drugInfo;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _drugInfo, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<DrugInfo>? _drugInfos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<DrugInfo>? DrugInfos
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drugInfos;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _drugInfos, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private List<MachineRecord>? machineRecords;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<MachineRecord>? MachineRecords
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return machineRecords; }
 | 
				
			||||||
 | 
					            set { SetProperty(ref machineRecords, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public MachineRecordWindowViewModel(IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            vm = this;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand SaveCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //保存修改的凭证号
 | 
				
			||||||
 | 
					                UpdatPZHSave();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void UpdatPZHSave()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                for (int i = 0; i < MachineRecords.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 更新数据 库存信息
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Id = MachineRecords[i].Id,
 | 
				
			||||||
 | 
					                        InvoiceId = MachineRecords[i].InvoiceId
 | 
				
			||||||
 | 
					                    }).UpdateColumns(it => new { it.InvoiceId }).WhereColumns(it => new { it.Id }).ExecuteCommand();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            if (f.Data)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        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();
 | 
				
			||||||
 | 
					            GetAllDrugInfos();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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)
 | 
				
			||||||
 | 
					                .WhereIF(DrugInfo != null, (mr) => mr.DrugId == DrugInfo.DrugId)
 | 
				
			||||||
 | 
					                //.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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void GetAllDrugInfos()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            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";
 | 
				
			||||||
 | 
					            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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) || di.DrugId.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,119 @@
 | 
				
			||||||
 | 
					using MaterialDesignThemes.Wpf;
 | 
				
			||||||
 | 
					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.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Media;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.Views;
 | 
				
			||||||
 | 
					using Unity;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using System.Runtime.CompilerServices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class MainWindowViewModel : BindableBase
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private string _title = "Prism App";   //标题
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private SolidColorBrush _colorBrush;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private PortUtil _portUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ScreenUtil _screenUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public SolidColorBrush Background
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _colorBrush;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _colorBrush, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _snackbarMessageQueue;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public string Title
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _title; }
 | 
				
			||||||
 | 
					            set { SetProperty(ref _title, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IEventAggregator eventAggregator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //public MainWindowViewModel(IEventAggregator eventAggregator, PortUtil portUtil, ScreenUtil screenUtil)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    _portUtil = portUtil;
 | 
				
			||||||
 | 
					        //    this.eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        //    this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
 | 
				
			||||||
 | 
					        //    _screenUtil = screenUtil;
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        private FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					        IRegionManager _regionManager;
 | 
				
			||||||
 | 
					        IUnityContainer _container;
 | 
				
			||||||
 | 
					        PortUtil _portUtil;
 | 
				
			||||||
 | 
					        private List<ChannelStock> _channelStocks = new List<ChannelStock>();
 | 
				
			||||||
 | 
					        public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil, PortUtil portUtil)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //_portUtil = portUtil;
 | 
				
			||||||
 | 
					            this.eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					            this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
 | 
				
			||||||
 | 
					            _screenUtil = screenUtil;
 | 
				
			||||||
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
 | 
					            _container = container;
 | 
				
			||||||
 | 
					            _portUtil = portUtil;   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Task.Factory.StartNew(()=>BindStock()); ;       
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                _container.RegisterType<object, LoginWindow>("LoginWindow");
 | 
				
			||||||
 | 
					                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void doMyPrismEvent2(AlertMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            switch (msg.Type)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case MsgType.INFO:
 | 
				
			||||||
 | 
					                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case MsgType.ERROR:
 | 
				
			||||||
 | 
					                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                default:
 | 
				
			||||||
 | 
					                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            SnackbarMessageQueue.Enqueue(msg.Message);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //写标签数量
 | 
				
			||||||
 | 
					        async Task BindStock()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            List<ChannelStock> singleChannels = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.BoardType == 5).Where(cs => cs.DrugId !=null).ToList();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            for (int i = 0; i < singleChannels.Count; i++)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, singleChannels[i].Quantity);
 | 
				
			||||||
 | 
					                await Task.Delay(TimeSpan.FromMilliseconds(20));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,406 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 发送还药数量
 | 
				
			||||||
 | 
					            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 = 2,
 | 
				
			||||||
 | 
					                            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),
 | 
				
			||||||
 | 
					                                ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                            }).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);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,444 @@
 | 
				
			||||||
 | 
					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 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);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                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"] ?? "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.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;
 | 
				
			||||||
 | 
					                // 说明数量足够
 | 
				
			||||||
 | 
					                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);
 | 
				
			||||||
 | 
					            _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);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            if(_portUtil.DrawerNo!=0&& _portUtil.DrawerNo<9&& DrawerNo>8)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Thread.Sleep(50);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            _portUtil.WindowName = "OrderTakeDrugWindow";
 | 
				
			||||||
 | 
					            _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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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),
 | 
				
			||||||
 | 
					                                    ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                                }).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));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,265 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					            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.RecvDate.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)
 | 
				
			||||||
 | 
					                .GroupBy(oi => oi.OrderNo)
 | 
				
			||||||
 | 
					                .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;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,36 @@
 | 
				
			||||||
 | 
					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); }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,333 @@
 | 
				
			||||||
 | 
					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.WindowName = WindowName;
 | 
				
			||||||
 | 
					                    _portUtil.BoardType = ChannelStock.BoardType;
 | 
				
			||||||
 | 
					                    _portUtil.ColNos = new int[] { ChannelStock.ColNo };
 | 
				
			||||||
 | 
					                    _portUtil.Stocks = new int[] { ChannelStock.Quantity };
 | 
				
			||||||
 | 
					                    _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),
 | 
				
			||||||
 | 
					                            ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == ChannelStock.ManuNo).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));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }, () => !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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,254 @@
 | 
				
			||||||
 | 
					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"] ?? "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 == 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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,208 @@
 | 
				
			||||||
 | 
					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 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"] ?? "DM1"))
 | 
				
			||||||
 | 
					                //.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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,358 @@
 | 
				
			||||||
 | 
					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 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"] ?? "DM1"))
 | 
				
			||||||
 | 
					                .Where(mr => mr.Type == 2)
 | 
				
			||||||
 | 
					                .Where(mr => mr.Status != 2)
 | 
				
			||||||
 | 
					                .OrderBy(mr => mr.OperationTime)
 | 
				
			||||||
 | 
					                .OrderBy(mr => mr.Id)
 | 
				
			||||||
 | 
					                .ToList();
 | 
				
			||||||
 | 
					            MachineRecords = queryData;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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.Stocks = new int[] { ChannelStock.Quantity }; 
 | 
				
			||||||
 | 
					                            _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.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,
 | 
				
			||||||
 | 
					                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                                Quantity = ReturnQuantity,
 | 
				
			||||||
 | 
					                                Type = 32,
 | 
				
			||||||
 | 
					                                InvoiceId = InvoiceId,
 | 
				
			||||||
 | 
					                                GetId = _MachineRecord.Id,
 | 
				
			||||||
 | 
					                                StockQuantity = nowChannels.Sum(it => it.Quantity),
 | 
				
			||||||
 | 
					                                ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == ChannelStock.ManuNo).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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,134 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        public ReturnEmptyWindowViewModel(IDialogService dialogService)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = dialogService;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    DialogParameters dialogParameters = new DialogParameters();
 | 
				
			||||||
 | 
					                    dialogParameters.Add("channel", Channel);
 | 
				
			||||||
 | 
					                    DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void DoDialogResult(IDialogResult dialogResult)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 委托   被动执行     被子窗口执行
 | 
				
			||||||
 | 
					            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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)
 | 
				
			||||||
 | 
					                .Select((cs, di) => new ChannelStock{
 | 
				
			||||||
 | 
					                    CanReturnQuantity = SqlFunc.Subqueryable<MachineRecord>().Where(mr => mr.DrugId == cs.DrugId).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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,665 @@
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Reflection;
 | 
				
			||||||
 | 
					using System.Runtime.Serialization.Formatters.Binary;
 | 
				
			||||||
 | 
					using System.Runtime.Serialization;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using System.Data;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class RoleManagerWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private List<RoleDm>? _roleList;
 | 
				
			||||||
 | 
					        public List<RoleDm>? RoleList
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _roleList; }
 | 
				
			||||||
 | 
					            set { SetProperty(ref _roleList, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //public RoleManagerWindowViewModel()
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    _allPremissions = Clone<PremissionDm>(defaultAll);
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        public static ObservableCollection<T> Clone<T>(object List)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            using (Stream objectStream = new MemoryStream())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                IFormatter formatter = new BinaryFormatter();
 | 
				
			||||||
 | 
					                formatter.Serialize(objectStream, List);
 | 
				
			||||||
 | 
					                objectStream.Seek(0, SeekOrigin.Begin);
 | 
				
			||||||
 | 
					                return formatter.Deserialize(objectStream) as ObservableCollection<T>;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private RoleDm _role = new RoleDm();
 | 
				
			||||||
 | 
					        public RoleDm Role
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _role; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                CompareList(value);
 | 
				
			||||||
 | 
					                SetProperty(ref _role, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void CompareList(RoleDm Role)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            AllPremissions = Clone<PremissionDm>(defaultAll);
 | 
				
			||||||
 | 
					            RightPremissions.Clear();
 | 
				
			||||||
 | 
					            if (Role != null && Role.Permissions != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                List<PremissionDm> Permissions = Role.Permissions;
 | 
				
			||||||
 | 
					                Permissions.ForEach(it =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 父菜单
 | 
				
			||||||
 | 
					                    PremissionDm p = AllPremissions.ToList().Find(it2 => it2.Id == it.Id);
 | 
				
			||||||
 | 
					                    int index = AllPremissions.ToList().FindIndex(it2 => it2.Id == it.Id);
 | 
				
			||||||
 | 
					                    if (p.Id != 6)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        it.Children.ToList().ForEach(it3 =>
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            int i =p.Children.ToList().FindIndex(it4 => it4.Id == it3.Id);
 | 
				
			||||||
 | 
					                            if (i > 0 && AllPremissions.ElementAt(index).Children.Count > i) 
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                AllPremissions.ElementAt(index).Children.RemoveAt(i);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                        if (p.Children.Count == 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AllPremissions.RemoveAt(index);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AllPremissions.RemoveAt(index);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                RightPremissions = new ObservableCollection<PremissionDm>(Permissions);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string? _searchValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? SearchValue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _searchValue; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _searchValue, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static ObservableCollection<PremissionDm> defaultAll = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        static RoleManagerWindowViewModel()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            #region 取药菜单
 | 
				
			||||||
 | 
					            PremissionDm quyao = new PremissionDm{
 | 
				
			||||||
 | 
					                Id = 1,
 | 
				
			||||||
 | 
					                PremissionName = "取药",
 | 
				
			||||||
 | 
					                PremissionImage = "/Images/TbQyao.png",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					            PremissionDm quyao1 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 11,
 | 
				
			||||||
 | 
					                PremissionName = "处方取药",
 | 
				
			||||||
 | 
					                PremissionPath = "OrderTakeDrugWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm quyao2 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 12,
 | 
				
			||||||
 | 
					                PremissionName = "调拨出库",
 | 
				
			||||||
 | 
					                PremissionPath = "InvoiceOutWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm quyao3 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 13,
 | 
				
			||||||
 | 
					                PremissionName = "抽屉取药",
 | 
				
			||||||
 | 
					                PremissionPath = "DrawerTakeDrugWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm quyao4 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 14,
 | 
				
			||||||
 | 
					                PremissionName = "自选取药",
 | 
				
			||||||
 | 
					                PremissionPath = "SelfTakeDrugWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm quyao5 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 15,
 | 
				
			||||||
 | 
					                PremissionName = "取药记录",
 | 
				
			||||||
 | 
					                PremissionPath = "TakeRecordWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            quyaoChild.Add(quyao1);
 | 
				
			||||||
 | 
					            quyaoChild.Add(quyao2);
 | 
				
			||||||
 | 
					            quyaoChild.Add(quyao3);
 | 
				
			||||||
 | 
					            quyaoChild.Add(quyao4);
 | 
				
			||||||
 | 
					            quyaoChild.Add(quyao5);
 | 
				
			||||||
 | 
					            quyao.Children = quyaoChild;
 | 
				
			||||||
 | 
					            defaultAll.Add(quyao);
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					            #region 加药菜单
 | 
				
			||||||
 | 
					            PremissionDm jiayao = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 2,
 | 
				
			||||||
 | 
					                PremissionName = "加药",
 | 
				
			||||||
 | 
					                PremissionImage = "/Images/TbJiay.png",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            ObservableCollection<PremissionDm> jiayaoChild = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					            PremissionDm jiayao1 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 21,
 | 
				
			||||||
 | 
					                PremissionName = "自选加药",
 | 
				
			||||||
 | 
					                PremissionPath = "SelfAddWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm jiayao2 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 22,
 | 
				
			||||||
 | 
					                PremissionName = "调拨入库",
 | 
				
			||||||
 | 
					                PremissionPath = "InvoiceInWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm jiayao3 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 23,
 | 
				
			||||||
 | 
					                PremissionName = "抽屉加药",
 | 
				
			||||||
 | 
					                PremissionPath = "DrawerAddDrugWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm jiayao4 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 25,
 | 
				
			||||||
 | 
					                PremissionName = "加药记录",
 | 
				
			||||||
 | 
					                PremissionPath = "AddRecordWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm jiayao5 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 24,
 | 
				
			||||||
 | 
					                PremissionName = "多批次抽屉加药",
 | 
				
			||||||
 | 
					                PremissionPath = "AddDrugControl",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            jiayaoChild.Add(jiayao1);
 | 
				
			||||||
 | 
					            jiayaoChild.Add(jiayao2);
 | 
				
			||||||
 | 
					            jiayaoChild.Add(jiayao3);
 | 
				
			||||||
 | 
					            jiayaoChild.Add(jiayao5);
 | 
				
			||||||
 | 
					            jiayaoChild.Add(jiayao4);
 | 
				
			||||||
 | 
					            jiayao.Children = jiayaoChild;
 | 
				
			||||||
 | 
					            defaultAll.Add(jiayao);
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					            #region 还药菜单
 | 
				
			||||||
 | 
					            PremissionDm huanyao = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 3,
 | 
				
			||||||
 | 
					                PremissionName = "还药",
 | 
				
			||||||
 | 
					                PremissionImage = "/Images/TbTuiy.png",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            ObservableCollection<PremissionDm> huanyaoChild = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					            PremissionDm huanyao1 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 31,
 | 
				
			||||||
 | 
					                PremissionName = "归还药品",
 | 
				
			||||||
 | 
					                PremissionPath = "ReturnDrugWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm huanyao11 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 31,
 | 
				
			||||||
 | 
					                PremissionName = "归还药品",
 | 
				
			||||||
 | 
					                PremissionPath = "ReturnDrugWindow2",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm huanyao2 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 32,
 | 
				
			||||||
 | 
					                PremissionName = "归还空瓶",
 | 
				
			||||||
 | 
					                PremissionPath = "ReturnEmptyWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm huanyao3 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 33,
 | 
				
			||||||
 | 
					                PremissionName = "归还记录",
 | 
				
			||||||
 | 
					                PremissionPath = "ReturnRecordWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1? huanyao11:huanyao1);
 | 
				
			||||||
 | 
					            huanyaoChild.Add(huanyao2);
 | 
				
			||||||
 | 
					            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",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            kuguanChild.Add(kuguan1);
 | 
				
			||||||
 | 
					            kuguanChild.Add(kuguan2);
 | 
				
			||||||
 | 
					            kuguanChild.Add(kuguan3);
 | 
				
			||||||
 | 
					            kuguanChild.Add(kuguan4);
 | 
				
			||||||
 | 
					            kuguanChild.Add(kuguan5);
 | 
				
			||||||
 | 
					            kuguan.Children = kuguanChild;
 | 
				
			||||||
 | 
					            defaultAll.Add(kuguan);
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					            #region 系统设置菜单
 | 
				
			||||||
 | 
					            PremissionDm sysset = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 5,
 | 
				
			||||||
 | 
					                PremissionName = "系统设置",
 | 
				
			||||||
 | 
					                PremissionImage = "/Images/TbSet.png",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            ObservableCollection<PremissionDm> syssetChild = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					            PremissionDm sysset1 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 51,
 | 
				
			||||||
 | 
					                PremissionName = "用户管理",
 | 
				
			||||||
 | 
					                PremissionPath = "UserManagerWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm sysset2 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 52,
 | 
				
			||||||
 | 
					                PremissionName = "角色管理",
 | 
				
			||||||
 | 
					                PremissionPath = "RoleManagerWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm sysset3 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 53,
 | 
				
			||||||
 | 
					                PremissionName = "设置",
 | 
				
			||||||
 | 
					                PremissionPath = "SettingWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            syssetChild.Add(sysset1);
 | 
				
			||||||
 | 
					            syssetChild.Add(sysset2);
 | 
				
			||||||
 | 
					            syssetChild.Add(sysset3);
 | 
				
			||||||
 | 
					            sysset.Children = syssetChild;
 | 
				
			||||||
 | 
					            defaultAll.Add(sysset);
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					            #region 退出菜单
 | 
				
			||||||
 | 
					            PremissionDm logout = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 6,
 | 
				
			||||||
 | 
					                PremissionName = "退出",
 | 
				
			||||||
 | 
					                PremissionImage = "/Images/TbExit.png",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            defaultAll.Add(logout);
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ObservableCollection<PremissionDm> _allPremissions = Clone<PremissionDm>(defaultAll);
 | 
				
			||||||
 | 
					        public ObservableCollection<PremissionDm> AllPremissions
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _allPremissions;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _allPremissions, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PremissionDm? _leftPremission ;
 | 
				
			||||||
 | 
					        public PremissionDm? LeftPremission
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _leftPremission;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _leftPremission, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private ObservableCollection<PremissionDm> _rightPremissions = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ObservableCollection<PremissionDm> RightPremissions
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _rightPremissions;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _rightPremissions, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PremissionDm? _rightPremission;
 | 
				
			||||||
 | 
					        public PremissionDm? RightPremission
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _rightPremission;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _rightPremission, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public T DeepCopyByReflect<T>(T obj)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //如果是字符串或值类型则直接返回
 | 
				
			||||||
 | 
					            if (obj == null || (obj is string) || (obj.GetType().IsValueType)) return obj;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            object retval = Activator.CreateInstance(obj.GetType());
 | 
				
			||||||
 | 
					            FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
 | 
				
			||||||
 | 
					            foreach (FieldInfo field in fields)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try { field.SetValue(retval, DeepCopyByReflect(field.GetValue(obj))); }
 | 
				
			||||||
 | 
					                catch { }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return (T)retval;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand Query
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand ToRight => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 说明是父菜单
 | 
				
			||||||
 | 
					            if (LeftPremission.Children != null || LeftPremission.Id == 6)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 右侧有没有此菜单
 | 
				
			||||||
 | 
					                int index = RightPremissions.ToList().FindIndex((it) => it.Id == LeftPremission.Id);
 | 
				
			||||||
 | 
					                // 已经存在
 | 
				
			||||||
 | 
					                if (index > -1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 获取右侧中的菜单
 | 
				
			||||||
 | 
					                    PremissionDm item = RightPremissions.ElementAt(index);
 | 
				
			||||||
 | 
					                    // 向其中添加子菜单
 | 
				
			||||||
 | 
					                    LeftPremission.Children.ToList().ForEach(it =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        int v = it.Id % 10;
 | 
				
			||||||
 | 
					                        if (v > item.Children.Count)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            item.Children.Add(it);
 | 
				
			||||||
 | 
					                        } else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            item.Children.Insert(v-1, it);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    int v = LeftPremission.Id % 10;
 | 
				
			||||||
 | 
					                    if (v > RightPremissions.Count)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        RightPremissions.Add(LeftPremission);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        RightPremissions.Insert(v - 1, LeftPremission);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                   
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                AllPremissions.RemoveAt(AllPremissions.ToList().FindIndex(it => it.Id == LeftPremission.Id));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // 子菜单
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 查找所选子菜单的父菜单
 | 
				
			||||||
 | 
					                PremissionDm item = AllPremissions.ToList().Find(it => (int)(LeftPremission.Id / 10) == it.Id);
 | 
				
			||||||
 | 
					                // 查找父菜单是否在右侧
 | 
				
			||||||
 | 
					                int index = RightPremissions.ToList().FindIndex(it => it.Id == item.Id);
 | 
				
			||||||
 | 
					                // 存在
 | 
				
			||||||
 | 
					                if (index > -1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ObservableCollection<PremissionDm>  a= RightPremissions.ElementAt(index).Children;
 | 
				
			||||||
 | 
					                    int v = LeftPremission.Id % 10;
 | 
				
			||||||
 | 
					                    if (v > a.Count)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        a.Add(LeftPremission);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        a.Insert(v - 1, LeftPremission);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    item.Children.RemoveAt(item.Children.ToList().FindIndex(it => it.Id == LeftPremission.Id));
 | 
				
			||||||
 | 
					                    if (item.Children.Count == 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AllPremissions.RemoveAt(AllPremissions.ToList().FindIndex(it => it.Id == LeftPremission.Id));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                // 不存在
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 拷贝
 | 
				
			||||||
 | 
					                    PremissionDm item2 = DeepCopyByReflect<PremissionDm>(item);
 | 
				
			||||||
 | 
					                    ObservableCollection<PremissionDm> child = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					                    child.Add(LeftPremission);
 | 
				
			||||||
 | 
					                    item2.Children = child;
 | 
				
			||||||
 | 
					                    int v = item2.Id % 10;
 | 
				
			||||||
 | 
					                    if (v > RightPremissions.Count)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        RightPremissions.Add(item2);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        RightPremissions.Insert(v - 1, item2);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    item.Children.RemoveAt(item.Children.ToList().FindIndex(it => it.Id == LeftPremission.Id));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        public DelegateCommand<PremissionDm> LeftSelectedItemChangedCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<PremissionDm>((PremissionDm _selected) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                LeftPremission = _selected;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand<PremissionDm> RightSelectedItemChangedCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<PremissionDm>((PremissionDm _selected) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RightPremission = _selected;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand ToLeft
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 说明是父菜单
 | 
				
			||||||
 | 
					                if (RightPremission.Children != null || RightPremission.Id == 6)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 左侧有没有此菜单
 | 
				
			||||||
 | 
					                    int index = AllPremissions.ToList().FindIndex((it) => it.Id == RightPremission.Id);
 | 
				
			||||||
 | 
					                    // 已经存在
 | 
				
			||||||
 | 
					                    if (index > -1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // 获取左侧中的菜单
 | 
				
			||||||
 | 
					                        PremissionDm item = AllPremissions.ElementAt(index);
 | 
				
			||||||
 | 
					                        // 向其中添加子菜单
 | 
				
			||||||
 | 
					                        RightPremission.Children.ToList().ForEach(it =>
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            int v = it.Id % 10;
 | 
				
			||||||
 | 
					                            if (v > item.Children.Count)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                item.Children.Add(it);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                item.Children.Insert(v - 1, it);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        int v = RightPremission.Id % 10;
 | 
				
			||||||
 | 
					                        if (v > AllPremissions.Count)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AllPremissions.Add(RightPremission);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AllPremissions.Insert(v - 1, RightPremission);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    RightPremissions.RemoveAt(RightPremissions.ToList().FindIndex(it => it.Id == RightPremission.Id));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                // 子菜单
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 查找所选子菜单的父菜单
 | 
				
			||||||
 | 
					                    PremissionDm item = RightPremissions.ToList().Find(it => (int)(RightPremission.Id / 10) == it.Id);
 | 
				
			||||||
 | 
					                    // 查找父菜单是否在左侧
 | 
				
			||||||
 | 
					                    int index = AllPremissions.ToList().FindIndex(it => it.Id == item.Id);
 | 
				
			||||||
 | 
					                    // 存在
 | 
				
			||||||
 | 
					                    if (index > -1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ObservableCollection<PremissionDm> a = AllPremissions.ElementAt(index).Children;
 | 
				
			||||||
 | 
					                        int v = RightPremission.Id % 10;
 | 
				
			||||||
 | 
					                        if (v > a.Count)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            a.Add(RightPremission);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            a.Insert(v - 1, RightPremission);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        item.Children.RemoveAt(item.Children.ToList().FindIndex(it => it.Id == RightPremission.Id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (item.Children.Count == 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            RightPremissions.RemoveAt(RightPremissions.ToList().FindIndex(it => it.Id == RightPremission.Id));
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    // 不存在
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // 拷贝
 | 
				
			||||||
 | 
					                        PremissionDm item2 = DeepCopyByReflect<PremissionDm>(item);
 | 
				
			||||||
 | 
					                        ObservableCollection<PremissionDm> child = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
 | 
					                        child.Add(RightPremission);
 | 
				
			||||||
 | 
					                        item2.Children = child;
 | 
				
			||||||
 | 
					                        int v = item2.Id % 10;
 | 
				
			||||||
 | 
					                        if (v > AllPremissions.Count)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AllPremissions.Add(item2);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            AllPremissions.Insert(v - 1, item2);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        item.Children.RemoveAt(item.Children.ToList().FindIndex(it => it.Id == RightPremission.Id));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand AllToRight
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RightPremissions = Clone<PremissionDm>(defaultAll);
 | 
				
			||||||
 | 
					                AllPremissions.Clear();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand AllToLeft
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                AllPremissions = Clone<PremissionDm>(defaultAll);
 | 
				
			||||||
 | 
					                RightPremissions.Clear();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand AddRole
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Role.Id = 0;
 | 
				
			||||||
 | 
					                Role.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
				
			||||||
 | 
					                Role.Permissions = RightPremissions.ToList();
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Insertable<RoleDm>(Role).ExecuteCommand();
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand EditRole
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Role.Permissions = RightPremissions.ToList();
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Updateable<RoleDm>(Role).ExecuteCommand();
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
				
			||||||
 | 
					        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            continuationCallback(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //接收导航传过来的参数
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //查询表格数据
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            RoleList = SqlSugarHelper.Db.Queryable<RoleDm>()
 | 
				
			||||||
 | 
					                .Where(di => di.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
				
			||||||
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue), (di) => di.RoleName.Contains(SearchValue??""))
 | 
				
			||||||
 | 
					                .Select(r => r)
 | 
				
			||||||
 | 
					                .ToList()
 | 
				
			||||||
 | 
					                ;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //这个方法用于拦截请求
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,348 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class SelfAddDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(SelfAddDialogViewModel));
 | 
				
			||||||
 | 
					        public string Title => "自选加药";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //凭证号
 | 
				
			||||||
 | 
					        private string _pzh;
 | 
				
			||||||
 | 
					        public string PZH { get => _pzh; set { SetProperty(ref _pzh, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                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 + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (_portUtil.DrawerNo != 0 && _portUtil.DrawerNo < 9 && DrawerNo > 8)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Thread.Sleep(50);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            _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)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 发送加药数量
 | 
				
			||||||
 | 
					                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();
 | 
				
			||||||
 | 
					                    string InvoiceId = PZH;
 | 
				
			||||||
 | 
					                    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),
 | 
				
			||||||
 | 
					                                ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                            }).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.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,201 @@
 | 
				
			||||||
 | 
					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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,327 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 = grouping.Key;
 | 
				
			||||||
 | 
					                            if (enumerator.MoveNext())
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
				
			||||||
 | 
					                                int DrawerNoAfter = grouping.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);
 | 
				
			||||||
 | 
					            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //if (_portUtil.DrawerNo != 0 && _portUtil.DrawerNo < 9 && DrawerNo > 8)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					                //Thread.Sleep(50);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            // 发送取药数量
 | 
				
			||||||
 | 
					            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.Stocks = singleChannels.Select(it => it.Quantity).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),
 | 
				
			||||||
 | 
					                                ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                            }).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.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||