Compare commits
	
		
			75 Commits
		
	
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							
							
								
								 | 
						afe1866439 | 
							 | 
					|
| 
							
							
								
								 | 
						e9a3d6467d | 
							 | 
					|
| 
							
							
								
								 | 
						137af9eea4 | 
							 | 
					|
| 
							
							
								
								 | 
						3e2a666159 | 
							 | 
					|
| 
							
							
								
								 | 
						c333cd9e5d | 
							 | 
					|
| 
							
							
								
								 | 
						175013ae84 | 
							 | 
					|
| 
							
							
								
								 | 
						b3c39e6d71 | 
							 | 
					|
| 
							
							
								
								 | 
						79f6ec12fa | 
							 | 
					|
| 
							
							
								
								 | 
						e74cd29702 | 
							 | 
					|
| 
							
							
								
								 | 
						ed9491634c | 
							 | 
					|
| 
							
							
								
								 | 
						2a495becbd | 
							 | 
					|
| 
							
							
								
								 | 
						9f918d8aeb | 
							 | 
					|
| 
							
							
								
								 | 
						4cf2de08e1 | 
							 | 
					|
| 
							
							
								
								 | 
						af6f066719 | 
							 | 
					|
| 
							
							
								
								 | 
						74c688bc07 | 
							 | 
					|
| 
							
							
								
								 | 
						93ed014be3 | 
							 | 
					|
| 
							
							
								
								 | 
						7ea5443f1d | 
							 | 
					|
| 
							
							
								
								 | 
						cb405e27a4 | 
							 | 
					|
| 
							
							
								
								 | 
						0d16348630 | 
							 | 
					|
| 
							
							
								
								 | 
						74829d0382 | 
							 | 
					|
| 
							
							
								
								 | 
						3c6b56f95e | 
							 | 
					|
| 
							
							
								
								 | 
						d582bba6c0 | 
							 | 
					|
| 
							
							
								
								 | 
						a4a745e7b8 | 
							 | 
					|
| 
							
							
								
								 | 
						7988187bcc | 
							 | 
					|
| 
							
							
								
								 | 
						8f4faabf3f | 
							 | 
					|
| 
							
							
								
								 | 
						5e9198cf59 | 
							 | 
					|
| 
							
							
								
								 | 
						21082a6e17 | 
							 | 
					|
| 
							
							
								
								 | 
						cf98e60aa8 | 
							 | 
					|
| 
							
							
								
								 | 
						c800334724 | 
							 | 
					|
| 
							
							
								
								 | 
						9b36ba3feb | 
							 | 
					|
| 
							
							
								
								 | 
						e29e7aa6e3 | 
							 | 
					|
| 
							
							
								
								 | 
						f18655cc80 | 
							 | 
					|
| 
							
							
								
								 | 
						2c4267d100 | 
							 | 
					|
| 
							
							
								
								 | 
						25ec8fb290 | 
							 | 
					|
| 
							
							
								
								 | 
						ece3d477a2 | 
							 | 
					|
| 
							
							
								
								 | 
						85821c040f | 
							 | 
					|
| 
							
							
								
								 | 
						9707453c98 | 
							 | 
					|
| 
							
							
								
								 | 
						f3c8aa5873 | 
							 | 
					|
| 
							
							
								
								 | 
						c186ab48bf | 
							 | 
					|
| 
							
							
								
								 | 
						e48cafb748 | 
							 | 
					|
| 
							
							
								
								 | 
						eb7fc78760 | 
							 | 
					|
| 
							
							
								
								 | 
						bdd640775d | 
							 | 
					|
| 
							
							
								
								 | 
						70e15f7b62 | 
							 | 
					|
| 
							
							
								
								 | 
						b8249a2788 | 
							 | 
					|
| 
							
							
								
								 | 
						6cf9e18963 | 
							 | 
					|
| 
							
							
								
								 | 
						1ec7054a8c | 
							 | 
					|
| 
							
							
								
								 | 
						23c5af868e | 
							 | 
					|
| 
							
							
								
								 | 
						5b33ebd883 | 
							 | 
					|
| 
							
							
								
								 | 
						aa123547ca | 
							 | 
					|
| 
							
							
								
								 | 
						cd77fd6f1b | 
							 | 
					|
| 
							
							
								
								 | 
						8252fba641 | 
							 | 
					|
| 
							
							
								
								 | 
						469b8aebe1 | 
							 | 
					|
| 
							
							
								
								 | 
						0bc3542281 | 
							 | 
					|
| 
							
							
								
								 | 
						5f990b7fa4 | 
							 | 
					|
| 
							
							
								
								 | 
						eed6d5d0e9 | 
							 | 
					|
| 
							
							
								
								 | 
						f1d784a099 | 
							 | 
					|
| 
							
							
								
								 | 
						f9fd4f4dd9 | 
							 | 
					|
| 
							
							
								
								 | 
						0d2d10deab | 
							 | 
					|
| 
							
							
								
								 | 
						17a6ddd0da | 
							 | 
					|
| 
							
							
								
								 | 
						6fd35e569f | 
							 | 
					|
| 
							
							
								
								 | 
						ad5f4d86bb | 
							 | 
					|
| 
							
							
								
								 | 
						702ef1d0ce | 
							 | 
					|
| 
							
							
								
								 | 
						07db386649 | 
							 | 
					|
| 
							
							
								
								 | 
						8fe17f7517 | 
							 | 
					|
| 
							
							
								
								 | 
						3a279d73a0 | 
							 | 
					|
| 
							
							
								
								 | 
						cb09e98cbd | 
							 | 
					|
| 
							
							
								
								 | 
						3a12e3bfee | 
							 | 
					|
| 
							
							
								
								 | 
						1a33934c45 | 
							 | 
					|
| 
							
							
								
								 | 
						33dbcb9b6f | 
							 | 
					|
| 
							
							
								
								 | 
						4654266085 | 
							 | 
					|
| 
							
							
								
								 | 
						e5f3877af5 | 
							 | 
					|
| 
							
							
								
								 | 
						6252aca09a | 
							 | 
					|
| 
							
							
								
								 | 
						9eeae56e0e | 
							 | 
					|
| 
							
							
								
								 | 
						46c767b3d0 | 
							 | 
					|
| 
							
							
								
								 | 
						65cd5f2460 | 
							 | 
					
| 
						 | 
					@ -361,3 +361,4 @@ MigrationBackup/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Fody - auto-generated XML schema
 | 
					# Fody - auto-generated XML schema
 | 
				
			||||||
FodyWeavers.xsd
 | 
					FodyWeavers.xsd
 | 
				
			||||||
 | 
					/win-x64 (2024-11-4_6湘乡交接柜).zip
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					<Project Sdk="Microsoft.NET.Sdk">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <PropertyGroup>
 | 
				
			||||||
 | 
					    <TargetFramework>net6.0-windows</TargetFramework>
 | 
				
			||||||
 | 
					    <Nullable>enable</Nullable>
 | 
				
			||||||
 | 
					    <UseWPF>true</UseWPF>
 | 
				
			||||||
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,75 @@
 | 
				
			||||||
 | 
					using Microsoft.Xaml.Behaviors;
 | 
				
			||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Controls;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Commons.ValidatRules
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ValidationErrorMappingBehavior : Behavior<FrameworkElement>
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        #region Properties
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static readonly DependencyProperty ValidationErrorsProperty =
 | 
				
			||||||
 | 
					            DependencyProperty.Register("ValidationErrors", typeof(ObservableCollection<ValidationError>),
 | 
				
			||||||
 | 
					                typeof(ValidationErrorMappingBehavior), new PropertyMetadata(new ObservableCollection<ValidationError>()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ObservableCollection<ValidationError> ValidationErrors
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return (ObservableCollection<ValidationError>)this.GetValue(ValidationErrorsProperty); }
 | 
				
			||||||
 | 
					            set { this.SetValue(ValidationErrorsProperty, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static readonly DependencyProperty HasValidationErrorProperty = DependencyProperty.Register("HasValidationError",
 | 
				
			||||||
 | 
					            typeof(bool), typeof(ValidationErrorMappingBehavior), new PropertyMetadata(false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool HasValidationError
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return (bool)this.GetValue(HasValidationErrorProperty); }
 | 
				
			||||||
 | 
					            set { this.SetValue(HasValidationErrorProperty, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region Constructors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ValidationErrorMappingBehavior()
 | 
				
			||||||
 | 
					            : base()
 | 
				
			||||||
 | 
					        { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region Events & Event Methods
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void Validation_Error(object sender, ValidationErrorEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (e.Action == ValidationErrorEventAction.Added)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                this.ValidationErrors.Add(e.Error);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                this.ValidationErrors.Remove(e.Error);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            this.HasValidationError = this.ValidationErrors.Count > 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region Support Methods
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        protected override void OnAttached()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            base.OnAttached();
 | 
				
			||||||
 | 
					            Validation.AddErrorHandler(this.AssociatedObject, Validation_Error);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        protected override void OnDetaching()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            base.OnDetaching();
 | 
				
			||||||
 | 
					            Validation.RemoveErrorHandler(this.AssociatedObject, Validation_Error);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -5,16 +5,42 @@ VisualStudioVersion = 17.3.32922.545
 | 
				
			||||||
MinimumVisualStudioVersion = 10.0.40219.1
 | 
					MinimumVisualStudioVersion = 10.0.40219.1
 | 
				
			||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DM_Weight", "DM_Weight\DM_Weight.csproj", "{439FA76B-F874-40DB-BAF2-E3647CD55B10}"
 | 
					Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DM_Weight", "DM_Weight\DM_Weight.csproj", "{439FA76B-F874-40DB-BAF2-E3647CD55B10}"
 | 
				
			||||||
EndProject
 | 
					EndProject
 | 
				
			||||||
 | 
					Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DM_Weight.Commons", "DM_Weight.Commons\DM_Weight.Commons.csproj", "{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}"
 | 
				
			||||||
 | 
					EndProject
 | 
				
			||||||
Global
 | 
					Global
 | 
				
			||||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
						GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
				
			||||||
		Debug|Any CPU = Debug|Any CPU
 | 
							Debug|Any CPU = Debug|Any CPU
 | 
				
			||||||
 | 
							Debug|x64 = Debug|x64
 | 
				
			||||||
 | 
							Debug|x86 = Debug|x86
 | 
				
			||||||
		Release|Any CPU = Release|Any CPU
 | 
							Release|Any CPU = Release|Any CPU
 | 
				
			||||||
 | 
							Release|x64 = Release|x64
 | 
				
			||||||
 | 
							Release|x86 = Release|x86
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
						GlobalSection(ProjectConfigurationPlatforms) = postSolution
 | 
				
			||||||
		{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
							{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}.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}.Debug|x64.ActiveCfg = Debug|x64
 | 
				
			||||||
		{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Debug|x64.Build.0 = Debug|x64
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Debug|x86.ActiveCfg = Debug|x86
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Debug|x86.Build.0 = Debug|x86
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|x64.ActiveCfg = Release|x64
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|x64.Build.0 = Release|x64
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|x86.ActiveCfg = Debug|x86
 | 
				
			||||||
 | 
							{439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|x86.Build.0 = Debug|x86
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Debug|x64.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Debug|x64.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Debug|x86.ActiveCfg = Debug|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Debug|x86.Build.0 = Debug|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Release|x64.ActiveCfg = Release|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Release|x64.Build.0 = Release|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Release|x86.ActiveCfg = Release|Any CPU
 | 
				
			||||||
 | 
							{7F9FA18B-5C28-476E-97D4-B5504B8DEB9B}.Release|x86.Build.0 = Release|Any CPU
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
	GlobalSection(SolutionProperties) = preSolution
 | 
						GlobalSection(SolutionProperties) = preSolution
 | 
				
			||||||
		HideSolutionNode = FALSE
 | 
							HideSolutionNode = FALSE
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
  <connectionStrings>
 | 
					  <connectionStrings>
 | 
				
			||||||
	<!-- 数据库连接字符串 -->
 | 
						<!-- 数据库连接字符串 -->
 | 
				
			||||||
	<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
 | 
						<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
 | 
				
			||||||
	<add name="database" connectionString="server=127.0.0.1;port=3306;database=hkcdb;userid=root;password=root" />
 | 
						<add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangtan_mazuike_xx;userid=root;password=root" />
 | 
				
			||||||
  </connectionStrings>
 | 
					  </connectionStrings>
 | 
				
			||||||
	<!--<runtime>
 | 
						<!--<runtime>
 | 
				
			||||||
		--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
							--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,22 @@
 | 
				
			||||||
	<appSettings>
 | 
						<appSettings>
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		<!-- 设备id -->
 | 
							<!-- 设备id -->
 | 
				
			||||||
		<add key="machineId" value="DM1" />
 | 
							<add key="machineId" value="DM5" />
 | 
				
			||||||
 | 
							<!-- 毒麻设备id -->
 | 
				
			||||||
 | 
							<add key="dm_machineId" value="DM3" />
 | 
				
			||||||
 | 
							<!--请领药库-->
 | 
				
			||||||
 | 
							<add key="colloctedId" value="住院,DM2,门诊,DM22" />
 | 
				
			||||||
 | 
							<!-- 供应单位 -->
 | 
				
			||||||
 | 
							<add key="supplierDept" value="药库" />
 | 
				
			||||||
 | 
							<!-- 领用部门 -->
 | 
				
			||||||
 | 
							<add key="receiveDept" value="麻精药房" />
 | 
				
			||||||
 | 
							<!--部门-->
 | 
				
			||||||
 | 
							<add key="department" value="急诊药房"/>
 | 
				
			||||||
 | 
						    
 | 
				
			||||||
 | 
							<!--登录人 0全部用户可登录;1仅当班人、审核人可登录-->
 | 
				
			||||||
 | 
							<add key="loginUser" value="0"/>
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		<!--2023/7/13 药房代码 有则写无则空 -->
 | 
							<!--2023/7/13 药房代码 有则写无则空 -->
 | 
				
			||||||
		<add key="storage" value="" />
 | 
							<add key="storage" value="" />
 | 
				
			||||||
		<!-- 登录模式 1单人登录2双人登录 -->
 | 
							<!-- 登录模式 1单人登录2双人登录 -->
 | 
				
			||||||
| 
						 | 
					@ -20,11 +35,14 @@
 | 
				
			||||||
		<!-- 登录顺序,指定先登录的人的名称有效值,只有在登录模式等于2时才会生效; 发药人:【operator】审核人:【reviewer】 -->
 | 
							<!-- 登录顺序,指定先登录的人的名称有效值,只有在登录模式等于2时才会生效; 发药人:【operator】审核人:【reviewer】 -->
 | 
				
			||||||
		<add key="firstLogin" value="operator" />
 | 
							<add key="firstLogin" value="operator" />
 | 
				
			||||||
		<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
 | 
							<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
 | 
				
			||||||
		<add key="returnDrugMode" value="1" />
 | 
							<add key="returnDrugMode" value="2" />
 | 
				
			||||||
		<!-- 自动退出时间,单位秒,为0时不自动退出 -->
 | 
							<!-- 自动退出时间,单位秒,为0时不自动退出 -->
 | 
				
			||||||
		<add key="autoExit" value="0"/>
 | 
							<add key="autoExit" value="0"/>
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		<add key="gridConnectionString" value="MYSQL; Database=hkcdb; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
 | 
							<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
 | 
				
			||||||
 | 
							<add key="stopRecord" value="180"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<add key="gridConnectionString" value="MYSQL; Database=xiangxiang; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
 | 
				
			||||||
		<!-- 查询处方是orderNo还是orderGroupNo -->
 | 
							<!-- 查询处方是orderNo还是orderGroupNo -->
 | 
				
			||||||
		<add key="OrderNoName" value="orderNo" />
 | 
							<add key="OrderNoName" value="orderNo" />
 | 
				
			||||||
		<!-- 后门耗材板地址 没有则填写0-->
 | 
							<!-- 后门耗材板地址 没有则填写0-->
 | 
				
			||||||
| 
						 | 
					@ -36,11 +54,38 @@
 | 
				
			||||||
		<!-- 抽屉串口使用的协议232或者485 -->
 | 
							<!-- 抽屉串口使用的协议232或者485 -->
 | 
				
			||||||
		<add key="DrawerProtocol" value="485" />
 | 
							<add key="DrawerProtocol" value="485" />
 | 
				
			||||||
		<!-- 抽屉串口的串口号 -->
 | 
							<!-- 抽屉串口的串口号 -->
 | 
				
			||||||
		<add key="DrawerPortPath" value="COM1" />
 | 
							<add key="DrawerPortPath" value="COM11" />
 | 
				
			||||||
		<!-- can总线串口的串口号 -->
 | 
							<!-- can总线串口的串口号 -->
 | 
				
			||||||
		<add key="CanBusPortPath" value="COM3" />
 | 
							<add key="CanBusPortPath" value="COM3" />
 | 
				
			||||||
		<!-- 条码枪串口的串口号 -->
 | 
							<!-- 条码枪串口的串口号 -->
 | 
				
			||||||
		<add key="ScanCodePortPath" value="COM8" />
 | 
							<add key="ScanCodePortPath" value="COM8" />
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							<!--是否有冰箱抽屉0无,1有一个,2两个-->
 | 
				
			||||||
 | 
							<add key="hasFridge" value="0"/>
 | 
				
			||||||
 | 
							<!-- 冰箱的串口号 -->
 | 
				
			||||||
 | 
							<add key="FridgePortPath" value="COM7" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<!--冰箱抽屉温度区间-->
 | 
				
			||||||
 | 
							<add key="temperatureRange" value="2-8"/>
 | 
				
			||||||
 | 
							<!--冰箱抽屉温度-->
 | 
				
			||||||
 | 
							<add key="temperatureValue" value="3.2"/>
 | 
				
			||||||
 | 
							<!--温度查询定时执行时间-->
 | 
				
			||||||
 | 
							<add key="Interval" value="60000"/>
 | 
				
			||||||
 | 
							<!--冰箱状态1关闭;0打开-->
 | 
				
			||||||
 | 
							<add key="FridgeState" value="0"/>
 | 
				
			||||||
 | 
							<!--报警状态1关闭;0打开-->
 | 
				
			||||||
 | 
							<add key="AlarmState" value="0"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<!--冰箱2抽屉温度区间-->
 | 
				
			||||||
 | 
							<add key="temperatureRange2" value="2-8"/>
 | 
				
			||||||
 | 
							<!--冰箱2状态1关闭;0打开-->
 | 
				
			||||||
 | 
							<add key="FridgeState2" value="0"/>
 | 
				
			||||||
 | 
							<!--冰箱2报警状态1关闭;0打开-->
 | 
				
			||||||
 | 
							<add key="AlarmState2" value="0"/>
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		<!-- 抽屉串口的串口号 --><!--
 | 
							<!-- 抽屉串口的串口号 --><!--
 | 
				
			||||||
		<add key="DrawerPortPath" value="COM11" />
 | 
							<add key="DrawerPortPath" value="COM11" />
 | 
				
			||||||
		--><!-- can总线串口的串口号 --><!--
 | 
							--><!-- can总线串口的串口号 --><!--
 | 
				
			||||||
| 
						 | 
					@ -54,13 +99,13 @@
 | 
				
			||||||
		<!-- 指纹机号码 -->
 | 
							<!-- 指纹机号码 -->
 | 
				
			||||||
		<add  key="machineNumber" value="1"/>
 | 
							<add  key="machineNumber" value="1"/>
 | 
				
			||||||
		<!-- 指纹机ip -->
 | 
							<!-- 指纹机ip -->
 | 
				
			||||||
		<add  key="fingerIp" value="192.168.1.201"/>
 | 
							<add  key="fingerIp" value="192.168.50.201"/>
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		<!-- 多处方取药 0:不启用 1:启用-->
 | 
							<!-- 多处方取药 0:不启用 1:启用-->
 | 
				
			||||||
		<add  key="MultiOrder" value="1"/>
 | 
							<add  key="MultiOrder" value="1"/>
 | 
				
			||||||
		<!-- 多批次抽屉加药 0:不启用 1:启用
 | 
							<!-- 多批次抽屉加药 0:不启用 1:启用
 | 
				
			||||||
		     启用channel_list记录库位信息 -->
 | 
							     启用channel_list记录库位信息 -->
 | 
				
			||||||
		<add  key="MultiBatch" value="1"/>
 | 
							<add  key="MultiBatch" value="0"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<!--海康威视IP-->
 | 
							<!--海康威视IP-->
 | 
				
			||||||
		<add key="HIKIP" value="192.168.1.15"/>
 | 
							<add key="HIKIP" value="192.168.1.15"/>
 | 
				
			||||||
| 
						 | 
					@ -71,5 +116,14 @@
 | 
				
			||||||
		<!--海康威视密码-->
 | 
							<!--海康威视密码-->
 | 
				
			||||||
		<add key="HIKPassword" value="HKC123456"/>
 | 
							<add key="HIKPassword" value="HKC123456"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<!--交接柜网口地址及端口-->
 | 
				
			||||||
 | 
							<add key="modbusIp" value="127.0.0.1"/>
 | 
				
			||||||
 | 
							<add key="modbusPort" value="4002"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							<!--温湿度串口-->
 | 
				
			||||||
 | 
							<add key="wsdSerialPort" value="COM1"/>
 | 
				
			||||||
 | 
							<!--温度查询定时执行时间-->
 | 
				
			||||||
 | 
							<add key="Interval" value="60000"/>
 | 
				
			||||||
 | 
							<add key="test" value="Y"/>
 | 
				
			||||||
	</appSettings>
 | 
						</appSettings>
 | 
				
			||||||
</configuration>
 | 
					</configuration>
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@
 | 
				
			||||||
             d1p1:Ignorable="d"
 | 
					             d1p1:Ignorable="d"
 | 
				
			||||||
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
					             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
 | 
				
			||||||
             xmlns:local="clr-namespace:DM_Weight"
 | 
					             xmlns:local="clr-namespace:DM_Weight"
 | 
				
			||||||
             xmlns:prism="http://prismlibrary.com/">
 | 
					             xmlns:prism="http://prismlibrary.com/" Startup="PrismApplication_Startup">
 | 
				
			||||||
    <Application.Resources>
 | 
					    <Application.Resources>
 | 
				
			||||||
        <ResourceDictionary>
 | 
					        <ResourceDictionary>
 | 
				
			||||||
            <ResourceDictionary.MergedDictionaries>
 | 
					            <ResourceDictionary.MergedDictionaries>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,8 @@ using System.Windows.Interop;
 | 
				
			||||||
using System.Windows.Threading;
 | 
					using System.Windows.Threading;
 | 
				
			||||||
using System.Timers;
 | 
					using System.Timers;
 | 
				
			||||||
using DM_Weight.HIKVISION;
 | 
					using DM_Weight.HIKVISION;
 | 
				
			||||||
 | 
					using System.Runtime.InteropServices;
 | 
				
			||||||
 | 
					using System.Diagnostics;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight
 | 
					namespace DM_Weight
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -44,6 +46,7 @@ namespace DM_Weight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected override Window CreateShell()
 | 
					        protected override Window CreateShell()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info("进入APP-CreateShell");
 | 
				
			||||||
            //UI线程未捕获异常处理事件
 | 
					            //UI线程未捕获异常处理事件
 | 
				
			||||||
            this.DispatcherUnhandledException += OnDispatcherUnhandledException;
 | 
					            this.DispatcherUnhandledException += OnDispatcherUnhandledException;
 | 
				
			||||||
            //Task线程内未捕获异常处理事件
 | 
					            //Task线程内未捕获异常处理事件
 | 
				
			||||||
| 
						 | 
					@ -51,6 +54,7 @@ namespace DM_Weight
 | 
				
			||||||
            //多线程异常
 | 
					            //多线程异常
 | 
				
			||||||
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
 | 
					            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info("进入APP-CreateShell-2");
 | 
				
			||||||
            return Container.Resolve<MainWindow>();
 | 
					            return Container.Resolve<MainWindow>();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,6 +90,8 @@ namespace DM_Weight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
 | 
					        protected override void RegisterTypes(IContainerRegistry containerRegistry)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info("进入APP-RegisterTypes");
 | 
				
			||||||
            // 注入日志
 | 
					            // 注入日志
 | 
				
			||||||
            XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
 | 
					            XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
 | 
				
			||||||
            //containerRegistry.RegisterInstance<ILog>(LogManager.GetLogger(""));
 | 
					            //containerRegistry.RegisterInstance<ILog>(LogManager.GetLogger(""));
 | 
				
			||||||
| 
						 | 
					@ -95,9 +101,9 @@ namespace DM_Weight
 | 
				
			||||||
            // 指纹机工具
 | 
					            // 指纹机工具
 | 
				
			||||||
            containerRegistry.RegisterSingleton<FingerprintUtil>();
 | 
					            containerRegistry.RegisterSingleton<FingerprintUtil>();
 | 
				
			||||||
            // 组态屏工具
 | 
					            // 组态屏工具
 | 
				
			||||||
            containerRegistry.RegisterSingleton<ScreenUtil>();
 | 
					            //containerRegistry.RegisterSingleton<ScreenUtil>();
 | 
				
			||||||
            // 录像机
 | 
					            // 录像机
 | 
				
			||||||
            containerRegistry.RegisterSingleton<CHKFunction>();
 | 
					            //containerRegistry.RegisterSingleton<CHKFunction>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            containerRegistry.Register<IDialogService, MaterialDialogService>();
 | 
					            containerRegistry.Register<IDialogService, MaterialDialogService>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -122,81 +128,136 @@ namespace DM_Weight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #region 取药
 | 
					            #region 取药
 | 
				
			||||||
            // 处方取药页面
 | 
					            // 处方取药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<OrderTakeDrugNewWindow, OrderTakeDrugNewWindowViewModel>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<OrderTakeAllDrugDialog, OrderTakeAllDrugDialogViewModel>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<OrderTakeNewDialog, OrderTakeNewDialogViewModel>();
 | 
				
			||||||
 | 
					            ////交接柜补药
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<AddToJiaoJieWindow, AddToJiaoJieWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 处方取药模态框
 | 
					            // 处方取药模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<OrderTakeDialog>();
 | 
					            //containerRegistry.RegisterDialog<OrderTakeDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<OrderTakeDialog, OrderTakeDialogViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<OrderTakeDialog, OrderTakeDialogViewModel>();
 | 
				
			||||||
            // 调拨取药页面
 | 
					            //// 调拨取药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<InvoiceOutWindow, InvoiceOutWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<InvoiceOutWindow, InvoiceOutWindowViewModel>();
 | 
				
			||||||
            // 调拨取药模态框
 | 
					            //// 调拨取药模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<InvoiceTakeDialog>();
 | 
					            //containerRegistry.RegisterDialog<InvoiceTakeDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<InvoiceTakeDialog, InvoiceTakeDialogViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<InvoiceTakeDialog, InvoiceTakeDialogViewModel>();
 | 
				
			||||||
            // 抽屉取药页面
 | 
					            //// 抽屉取药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<DrawerTakeDrugWindow, DrawerTakeDrugWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<DrawerTakeDrugWindow, DrawerTakeDrugWindowViewModel>();
 | 
				
			||||||
            // 自选取药模态框
 | 
					            //// 自选取药模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<SelfTakeDialog>();
 | 
					            //containerRegistry.RegisterDialog<SelfTakeDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<SelfTakeDialog, SelfTakeDialogViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<SelfTakeDialog, SelfTakeDialogViewModel>();
 | 
				
			||||||
            // 自选取药页面
 | 
					            //// 自选取药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<SelfTakeDrugWindow, SelfTakeDrugWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<SelfTakeDrugWindow, SelfTakeDrugWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ////多处方取药
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<MultiOrderTakeDrugWindow, MultiOrderTakeDrugWindowViewModel>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<MultiOrderTakeDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<MultiOrderTakeDialog,MultiOrderTakeDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ////手术排程
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<SurgeryTakeWindow, SurgeryTakeWindowViewModel>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<SurgeryTakeDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<SurgeryTakeDialog, SurgeryTakeDialogViewModel>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<AddSurgeryDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<AddSurgeryDialog, AddSurgeryDialogViewModel>();
 | 
				
			||||||
 | 
					            //开药箱
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<OpenBoxWindow, OpenBoxWindowViewModel>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<OpenBoxNewWindow, OpenBoxNewWindowViewModel>();
 | 
				
			||||||
 | 
					            //交接柜补药
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<AdditionWindow, AdditionWindowViewModel>();
 | 
				
			||||||
 | 
					            //核对处方
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<CheckOrderWindow, CheckOrderWindowViewModel>();
 | 
				
			||||||
 | 
					            //管理员根据药箱进行核对处方
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<CheckOrderNewWindow, CheckOrderNewWindowViewModel>();
 | 
				
			||||||
 | 
					            //麻醉师核对其名下单子
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<CheckSelfOrderWindow, CheckSelfOrderWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //多处方取药
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<MultiOrderTakeDrugWindow, MultiOrderTakeDrugWindowViewModel>();
 | 
					 | 
				
			||||||
            containerRegistry.RegisterDialog<MultiOrderTakeDialog>();
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<MultiOrderTakeDialog,MultiOrderTakeDialogViewModel>();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #region 加药
 | 
					            //#region 加药
 | 
				
			||||||
            // 自选加药页面
 | 
					            // 自选加药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<SelfAddWindow, SelfAddWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<SelfAddWindow, SelfAddWindowViewModel>();
 | 
				
			||||||
            // 调拨加药页面
 | 
					            //// 调拨加药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<InvoiceInWindow, InvoiceInWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<InvoiceInWindow, InvoiceInWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 调拨取药模态框
 | 
					            //// 调拨取药模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<InvoiceAddDialog>();
 | 
					            //containerRegistry.RegisterDialog<InvoiceAddDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<InvoiceAddDialog, InvoiceAddDialogViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<InvoiceAddDialog, InvoiceAddDialogViewModel>();
 | 
				
			||||||
            // 抽屉加药页面
 | 
					            //// 抽屉加药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<DrawerAddDrugWindow, DrawerAddDrugWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<DrawerAddDrugWindow, DrawerAddDrugWindowViewModel>();
 | 
				
			||||||
            // 自选加药模态框
 | 
					            //// 自选加药模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<SelfAddDialog>();
 | 
					            //containerRegistry.RegisterDialog<SelfAddDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<SelfAddDialog, SelfAddDialogViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<SelfAddDialog, SelfAddDialogViewModel>();
 | 
				
			||||||
            //多批次抽屉加药
 | 
					            ////多批次抽屉加药
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<AddDrugControl, AddDrugControlViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<AddDrugControl, AddDrugControlViewModel>();
 | 
				
			||||||
            #endregion
 | 
					            ////药品请领
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<CollectDrugWindow, CollectDrugWindowViewModel>();
 | 
				
			||||||
 | 
					            //// 药品请领模态框
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<CollectDrugDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<CollectDrugDialog, CollectDrugDialogViewModel>(); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #region 还药
 | 
					            ////请领列表
 | 
				
			||||||
            // 还药页面
 | 
					            //containerRegistry.RegisterForNavigation<ApplyListWindow, ApplyListWindowViewModel>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ReturnDrugWindow, ReturnDrugWindowViewModel>();
 | 
					            ////请领入库
 | 
				
			||||||
            // 按记录归还药品模态框
 | 
					            //containerRegistry.RegisterForNavigation<ApplyInStockWindow, ApplyInStockWindowViewModel>();
 | 
				
			||||||
            containerRegistry.RegisterDialog<ReturnDrugDialog>();
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ReturnDrugDialog, ReturnDrugDialogViewModel>();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 还药页面2
 | 
					            //#endregion
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ReturnDrugWindow2, ReturnDrugWindow2ViewModel>();
 | 
					 | 
				
			||||||
            // 按处方归还药品模态框
 | 
					 | 
				
			||||||
            containerRegistry.RegisterDialog<OrderReturnDialog>();
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<OrderReturnDialog, OrderReturnDialogViewModel>();
 | 
					 | 
				
			||||||
            // 还空瓶页面
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ReturnEmptyWindow, ReturnEmptyWindowViewModel>();
 | 
					 | 
				
			||||||
            // 归还空瓶模态框
 | 
					 | 
				
			||||||
            containerRegistry.RegisterDialog<ReturnEmptyDialog>();
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ReturnEmptyDialog, ReturnEmptyDialogViewModel>();
 | 
					 | 
				
			||||||
            #endregion
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #region 库存管理
 | 
					            //#region 还药
 | 
				
			||||||
            // 库存列表页面
 | 
					            //// 还药页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<StockListWindow, StockListWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<ReturnDrugWindow, ReturnDrugWindowViewModel>();
 | 
				
			||||||
            // 库位绑定模态框
 | 
					            //// 按记录归还药品模态框
 | 
				
			||||||
            containerRegistry.RegisterDialog<BindingChannelDialog>();
 | 
					            //containerRegistry.RegisterDialog<ReturnDrugDialog>();
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<BindingChannelDialog, BindingChannelDialogViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<ReturnDrugDialog, ReturnDrugDialogViewModel>();
 | 
				
			||||||
            //同一药品多批次库位绑定
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<BindingChannelNewDialog, BindingChannelNewDialogViewModel>();
 | 
					 | 
				
			||||||
            // 库存盘点页面
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<CheckStockWindow, CheckStockWindowViewModel>();
 | 
					 | 
				
			||||||
            // 药品列表页面
 | 
					 | 
				
			||||||
            containerRegistry.RegisterForNavigation<DrugListWindow, DrugListWindowViewModel>();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #endregion
 | 
					            //// 还药页面2
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<ReturnDrugWindow2, ReturnDrugWindow2ViewModel>();
 | 
				
			||||||
 | 
					            //// 按处方归还药品模态框
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<OrderReturnDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<OrderReturnDialog, OrderReturnDialogViewModel>();
 | 
				
			||||||
 | 
					            //// 还空瓶页面
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<ReturnEmptyWindow, ReturnEmptyWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ////空瓶销毁页面
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<ReturnEmptyDestoryWindow, ReturnEmptyDestoryWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //// 归还空瓶模态框
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<ReturnEmptyDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<ReturnEmptyDialog, ReturnEmptyDialogViewModel>();
 | 
				
			||||||
 | 
					            //// 空瓶销毁模态框
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<DestoryEmptyDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<DestoryEmptyDialog, DestoryEmptyDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //#endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //#region 库存管理
 | 
				
			||||||
 | 
					            //// 库存列表页面
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<StockListWindow, StockListWindowViewModel>();
 | 
				
			||||||
 | 
					            //// 库位绑定模态框
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<BindingChannelDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<BindingChannelDialog, BindingChannelDialogViewModel>();
 | 
				
			||||||
 | 
					            ////同一药品多批次库位绑定
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<BindingChannelNewDialog, BindingChannelNewDialogViewModel>();
 | 
				
			||||||
 | 
					            //// 库存盘点页面
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<CheckStockWindow, CheckStockWindowViewModel>();
 | 
				
			||||||
 | 
					            //// 药品列表页面
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<DrugListWindow, DrugListWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ////交接班记录
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<ChangeShiftsListWindow, ChangeShiftsListWindowViewModel>();
 | 
				
			||||||
 | 
					            ////交接班弹窗
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterDialog<ChangeShiftsDialog>();
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<ChangeShiftsDialog, ChangeShiftsDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
 | 
				
			||||||
 | 
					            //#endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #region 系统设置
 | 
					            #region 系统设置
 | 
				
			||||||
            // 用户管理页面
 | 
					            // 用户管理页面
 | 
				
			||||||
| 
						 | 
					@ -209,15 +270,72 @@ namespace DM_Weight
 | 
				
			||||||
            // 系统设置
 | 
					            // 系统设置
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<SettingWindow, SettingWindowViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<SettingWindow, SettingWindowViewModel>();
 | 
				
			||||||
            // 调试页面
 | 
					            // 调试页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<DebugWindow, DebugWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<DebugWindow, DebugWindowViewModel>();
 | 
				
			||||||
 | 
					            //主设置页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<SettingMainWindow, SettingMainWindowViewModel>();
 | 
				
			||||||
 | 
					            //两个冰箱抽屉设置页面
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<FridgeWindow, FridgeWindowViewModel>();
 | 
				
			||||||
 | 
					            ////只有一个冰箱抽屉设置页面
 | 
				
			||||||
 | 
					            //containerRegistry.RegisterForNavigation<FridgeOnlyWindow, FridgeOnlyWindowViewModel>();
 | 
				
			||||||
 | 
					            //绑定药箱套餐
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<BindBoxPackageWindow, BindBoxPackageWindowViewModel>();
 | 
				
			||||||
 | 
					            //药箱设置
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<SettingBoxWindow, SettingBoxWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //操作记录
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<MachineRecordWindow, MachineRecordWindowViewModel>();
 | 
				
			||||||
 | 
					            //温湿度记录
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<WSDRecordWindow, WSDRecordWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 设备记录页面
 | 
					            // 设备记录页面
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<MachineRecordWindow, MachineRecordWindowViewModel>();
 | 
					            //containerRegistry.RegisterForNavigation<MachineRecordWindow, MachineRecordWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info("结束APP-RegisterTypes");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void PrismApplication_Startup(object sender, StartupEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //获取欲启动程序名
 | 
				
			||||||
 | 
					            string processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
 | 
				
			||||||
 | 
					            logger.Info($"欲启动程序名:{processName}");
 | 
				
			||||||
 | 
					            //检查程序是否已经启动,已经启动则显示提示退出程序
 | 
				
			||||||
 | 
					            if (System.Diagnostics.Process.GetProcessesByName(processName).Length > 1)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"系统在运行!");
 | 
				
			||||||
 | 
					                //系统在运行
 | 
				
			||||||
 | 
					                RaiseOtherProcess();
 | 
				
			||||||
 | 
					                Application.Current.Shutdown();
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private static void RaiseOtherProcess()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Process proc = Process.GetCurrentProcess();
 | 
				
			||||||
 | 
					            foreach (Process otherProc in Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (proc.Id != otherProc.Id)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    IntPtr hWnd = otherProc.MainWindowHandle;
 | 
				
			||||||
 | 
					                    if (IsIconic(hWnd))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ShowWindowAsync(hWnd, 9);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    SetForegroundWindow(hWnd);
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        [DllImport("user32.dll")]
 | 
				
			||||||
 | 
					        private static extern bool SetForegroundWindow(IntPtr hWnd);
 | 
				
			||||||
 | 
					        [DllImport("user32.dll")]
 | 
				
			||||||
 | 
					        private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
 | 
				
			||||||
 | 
					        [DllImport("user32.dll")]
 | 
				
			||||||
 | 
					        private static extern bool IsIconic(IntPtr hWnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,42 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Common
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class CRC16MODBUS
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// Name: CRC-16/MODBUS    x16+x15+x2+1
 | 
				
			||||||
 | 
					        /// Poly: 0x8005
 | 
				
			||||||
 | 
					        /// Init: 0xFFFF
 | 
				
			||||||
 | 
					        /// Refin: true
 | 
				
			||||||
 | 
					        /// Refout: true
 | 
				
			||||||
 | 
					        /// Xorout: 0x0000
 | 
				
			||||||
 | 
					        ///******************************添加数据CRC16MODBUS校验位*******************************************
 | 
				
			||||||
 | 
					        public static byte[] CrcModBus(byte[] buffer, int start = 0, int len = 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (buffer == null || buffer.Length == 0) return null;
 | 
				
			||||||
 | 
					            if (start < 0) return null;
 | 
				
			||||||
 | 
					            if (len == 0) len = buffer.Length - start;
 | 
				
			||||||
 | 
					            int length = start + len;
 | 
				
			||||||
 | 
					            if (length > buffer.Length) return null;
 | 
				
			||||||
 | 
					            ushort crc = 0xFFFF;// Initial value
 | 
				
			||||||
 | 
					            for (int i = start; i < length; i++)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                crc ^= buffer[i];
 | 
				
			||||||
 | 
					                for (int j = 0; j < 8; j++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if ((crc & 1) > 0)
 | 
				
			||||||
 | 
					                        crc = (ushort)((crc >> 1) ^ 0xA001);// 0xA001 = reverse 0x8005
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                        crc = (ushort)(crc >> 1);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            byte[] ret = BitConverter.GetBytes(crc);
 | 
				
			||||||
 | 
					            //Array.Reverse(ret);
 | 
				
			||||||
 | 
					            return ret;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Xml;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Common
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class CommonClass
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
 | 
				
			||||||
 | 
					        public static 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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public static void SaveAppSetting(string key,string value)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
 | 
				
			||||||
 | 
					            _configuration.AppSettings.Settings[key].Value = value;
 | 
				
			||||||
 | 
					            _configuration.Save();
 | 
				
			||||||
 | 
					            ConfigurationManager.RefreshSection(key);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,24 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Common
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class PrismManager
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ///// <summary>
 | 
				
			||||||
 | 
					        ///// 主页面区域,主要呈现登录页及登录后页面
 | 
				
			||||||
 | 
					        ///// </summary>
 | 
				
			||||||
 | 
					        //public static readonly string MainViewRegionName = "MainContent";
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 设置菜单页面跳转,主要呈现设置下子菜单
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public static readonly string SettingViewRegionName = "SettingViewContent";
 | 
				
			||||||
 | 
					        ///// <summary>
 | 
				
			||||||
 | 
					        ///// 主页面各菜单页
 | 
				
			||||||
 | 
					        ///// </summary>
 | 
				
			||||||
 | 
					        //public static readonly string HomeViewRegionName = "HomeViewContent";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,61 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Controls;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Common
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    //设置冰箱温度规则
 | 
				
			||||||
 | 
					    public class TemperatureRangeRule : ValidationRule
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        //冰箱温度设置区间为取自配置文件(2~8度)
 | 
				
			||||||
 | 
					        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            bool flag = false;
 | 
				
			||||||
 | 
					            string tips = string.Empty;
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                string[] rang = value.ToString().Split('-');
 | 
				
			||||||
 | 
					                if (rang.Length >= 2)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool bSRange = int.TryParse(rang[0], out int sRange);
 | 
				
			||||||
 | 
					                    bool bERange = int.TryParse(rang[1], out int eRange);
 | 
				
			||||||
 | 
					                    if (bSRange && bERange)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if ((sRange < 2 || eRange > 8||sRange>8||eRange<2))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            tips = "温度区间设置2-8度,请检查输入";
 | 
				
			||||||
 | 
					                            return new ValidationResult(flag, tips);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            flag = true;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        tips = "请输入正确的数值";
 | 
				
			||||||
 | 
					                        return new ValidationResult(flag, tips);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    tips = "请输入正确的数值";
 | 
				
			||||||
 | 
					                    return new ValidationResult(flag, tips);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return new ValidationResult(flag, tips);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                tips = $"校验异常{ex.ToString()}";
 | 
				
			||||||
 | 
					                return new ValidationResult(flag, tips);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,91 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Collections.ObjectModel;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 请领列表页面状态转换
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public class ApplyListConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //用户名
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("UserId"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int val = int.Parse(value.ToString());
 | 
				
			||||||
 | 
					                if (val <= 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return "";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                string userName = SqlSugarHelper.Db.Queryable<UserList>().Where(ul => ul.Id == val).Select(ul => new { ul.Nickname }).First().Nickname;
 | 
				
			||||||
 | 
					                return userName;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //请领单状态
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("PleaseStatus"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int val = int.Parse(value.ToString());
 | 
				
			||||||
 | 
					                string retStr = "状态:";
 | 
				
			||||||
 | 
					                switch (val)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    case 0:
 | 
				
			||||||
 | 
					                        return retStr + "已创建";
 | 
				
			||||||
 | 
					                    case 1:
 | 
				
			||||||
 | 
					                        return retStr + "审核通过";
 | 
				
			||||||
 | 
					                    case 2:
 | 
				
			||||||
 | 
					                        return retStr + "已出库";
 | 
				
			||||||
 | 
					                    case 3:
 | 
				
			||||||
 | 
					                        return retStr + "已入库";
 | 
				
			||||||
 | 
					                    default:
 | 
				
			||||||
 | 
					                        return retStr + "状态未知";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //处方状态
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("OrderStatus"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int val = int.Parse(value.ToString());
 | 
				
			||||||
 | 
					                switch (val)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    case 0:
 | 
				
			||||||
 | 
					                        return "已申请";
 | 
				
			||||||
 | 
					                    case 1:
 | 
				
			||||||
 | 
					                        return "已接收";
 | 
				
			||||||
 | 
					                    case 2:
 | 
				
			||||||
 | 
					                        return "已退回";
 | 
				
			||||||
 | 
					                    default:
 | 
				
			||||||
 | 
					                        return "状态未知";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //请领药库
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("machineId"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                string val = value.ToString();
 | 
				
			||||||
 | 
					                string[] colloctedId = ConfigurationManager.AppSettings["colloctedId"].Split(',');
 | 
				
			||||||
 | 
					                if (Array.IndexOf(colloctedId, val)>0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return colloctedId[Array.IndexOf(colloctedId, val) - 1].ToString();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return "未知";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return "";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					using SqlSugar.Extensions;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    class BoxNumConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if(parameter==null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return value.ObjToBool();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            string str=value.ToString();
 | 
				
			||||||
 | 
					            return !(str == parameter.ToString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,9 @@ namespace DM_Weight.Converter
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
 | 
					        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            int ButtonDrawerNo = int.Parse(value[0].ToString());
 | 
					            //int iLength = value[0].ToString().Length;
 | 
				
			||||||
 | 
					            int iLength = value[0].ToString().IndexOf("号药箱");
 | 
				
			||||||
 | 
					            int ButtonDrawerNo = int.Parse(value[0].ToString().Substring(0, iLength));
 | 
				
			||||||
            int SelectedDrawerNo = int.Parse(value[1].ToString());
 | 
					            int SelectedDrawerNo = int.Parse(value[1].ToString());
 | 
				
			||||||
            return ButtonDrawerNo == SelectedDrawerNo;
 | 
					            return ButtonDrawerNo == SelectedDrawerNo;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -22,11 +22,11 @@ namespace DM_Weight.Converter
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                foreach (var item in items)
 | 
					                foreach (var item in items)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var de = item as ChannelStock;
 | 
					                    var de = item as OrderDetail;
 | 
				
			||||||
                    total += de.Quantity;
 | 
					                    total += de.Quantity;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return "总库存:" + total;
 | 
					            return "用药总数:" + total;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    class OpenBoxSelectConverter : IMultiValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int ButtonDrawerNo=0;
 | 
				
			||||||
 | 
					            switch (value[0].ToString())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case "开名下药箱":
 | 
				
			||||||
 | 
					                    ButtonDrawerNo = 0;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "开公共药箱":
 | 
				
			||||||
 | 
					                    ButtonDrawerNo = 1;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int SelectedDrawerNo = int.Parse(value[1].ToString());
 | 
				
			||||||
 | 
					            return ButtonDrawerNo == SelectedDrawerNo;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class OpenStatusConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            bool status = bool.Parse(value.ToString());
 | 
				
			||||||
 | 
					                if (status)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            return Visibility.Collapsed;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -64,7 +64,19 @@ namespace DM_Weight.Converter
 | 
				
			||||||
            //取消
 | 
					            //取消
 | 
				
			||||||
            if (parameter.ToString().Equals("CancelBtn"))
 | 
					            if (parameter.ToString().Equals("CancelBtn"))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (status > 0)
 | 
					                if (status ==3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Visibility.Collapsed;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //确认核销、刷新
 | 
				
			||||||
 | 
					            if (parameter.ToString().Equals("ConfirmVsRefresh"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status == 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    return Visibility.Visible;
 | 
					                    return Visibility.Visible;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,46 @@
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class StockStatusConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int status = int.Parse(value.ToString());
 | 
				
			||||||
 | 
					            if (parameter.ToString() == "EnableState")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (parameter.ToString() == "TextState")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (status == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return "未取药";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return "已取药待入库";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return "";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
    <PackageIcon></PackageIcon>
 | 
					    <PackageIcon></PackageIcon>
 | 
				
			||||||
    <Product>毒麻管理程序</Product>
 | 
					    <Product>毒麻管理程序</Product>
 | 
				
			||||||
    <ApplicationIcon>Images\favicon.ico</ApplicationIcon>
 | 
					    <ApplicationIcon>Images\favicon.ico</ApplicationIcon>
 | 
				
			||||||
 | 
					    <Platforms>AnyCPU;x86;x64</Platforms>
 | 
				
			||||||
  </PropertyGroup>
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<ItemGroup>
 | 
						<ItemGroup>
 | 
				
			||||||
| 
						 | 
					@ -69,6 +70,8 @@
 | 
				
			||||||
    <PackageReference Include="log4net" Version="2.0.15" />
 | 
					    <PackageReference Include="log4net" Version="2.0.15" />
 | 
				
			||||||
    <PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
 | 
					    <PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
 | 
				
			||||||
    <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
 | 
					    <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
 | 
				
			||||||
 | 
					    <PackageReference Include="NModbus4.NetCore" Version="2.0.1" />
 | 
				
			||||||
 | 
					    <PackageReference Include="Polly" Version="8.4.1" />
 | 
				
			||||||
    <PackageReference Include="Prism.Unity" Version="8.1.97" />
 | 
					    <PackageReference Include="Prism.Unity" Version="8.1.97" />
 | 
				
			||||||
    <PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
 | 
					    <PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
 | 
				
			||||||
    <PackageReference Include="SuperSimpleTcp" Version="3.0.10" />
 | 
					    <PackageReference Include="SuperSimpleTcp" Version="3.0.10" />
 | 
				
			||||||
| 
						 | 
					@ -96,6 +99,9 @@
 | 
				
			||||||
    <None Update="ReportTemp\account_book_temp.grf">
 | 
					    <None Update="ReportTemp\account_book_temp.grf">
 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
    </None>
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\changeShifts_temp.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
    <None Update="ReportTemp\machine_log_check.grf">
 | 
					    <None Update="ReportTemp\machine_log_check.grf">
 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
    </None>
 | 
					    </None>
 | 
				
			||||||
| 
						 | 
					@ -108,19 +114,23 @@
 | 
				
			||||||
    <None Update="ReportTemp\machine_log_take.grf">
 | 
					    <None Update="ReportTemp\machine_log_take.grf">
 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
    </None>
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\orderUse_template.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
 | 
					    <None Update="ReportTemp\ReturnEmptyDistory_template.grf">
 | 
				
			||||||
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
 | 
					    </None>
 | 
				
			||||||
    <None Update="ReportTemp\stock_template.grf">
 | 
					    <None Update="ReportTemp\stock_template.grf">
 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
				
			||||||
    </None>
 | 
					    </None>
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
    <Page Update="Views\Dialog\InvoiceTakeDialog.xaml">
 | 
					 | 
				
			||||||
      <XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
 | 
					 | 
				
			||||||
    </Page>
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <Folder Include="HIKVISION\" />
 | 
					    <Folder Include="HIKVISION\" />
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <ProjectReference Include="..\DM_Weight.Commons\DM_Weight.Commons.csproj" />
 | 
				
			||||||
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</Project>
 | 
					</Project>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,10 +32,10 @@ namespace DM_Weight.Finger
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
            logger.Info($"进入构造器,开始连接指纹机");
 | 
					            logger.Info($"进入构造器,开始连接指纹机");
 | 
				
			||||||
            Task.Run(() =>
 | 
					           // Task.Run(() =>
 | 
				
			||||||
           {
 | 
					           //{
 | 
				
			||||||
               ConnectionMain();
 | 
					               ConnectionMain();
 | 
				
			||||||
           });
 | 
					           //});
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void ConnectionMain()
 | 
					        public void ConnectionMain()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ using System.Windows.Controls;
 | 
				
			||||||
using System.Windows;
 | 
					using System.Windows;
 | 
				
			||||||
using DM_Weight.Port;
 | 
					using DM_Weight.Port;
 | 
				
			||||||
using log4net;
 | 
					using log4net;
 | 
				
			||||||
 | 
					using System.Runtime.InteropServices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.HIKVISION
 | 
					namespace DM_Weight.HIKVISION
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -24,19 +25,29 @@ namespace DM_Weight.HIKVISION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public CHCNetSDK.NET_DVR_USER_LOGIN_INFO struLogInfo;
 | 
					        public CHCNetSDK.NET_DVR_USER_LOGIN_INFO struLogInfo;
 | 
				
			||||||
        public CHCNetSDK.NET_DVR_DEVICEINFO_V40 DeviceInfo;
 | 
					        public CHCNetSDK.NET_DVR_DEVICEINFO_V40 DeviceInfo;
 | 
				
			||||||
 | 
					        public CHCNetSDK.NET_DVR_TIME m_struTimeCfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private System.ComponentModel.Container components = null;
 | 
					        private System.ComponentModel.Container components = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public CHKFunction()
 | 
					        public CHKFunction()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info("CHKFunction");
 | 
				
			||||||
            HIKInit();
 | 
					            HIKInit();
 | 
				
			||||||
            HIKLogin();
 | 
					            HIKLogin();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool HIKInit()
 | 
					        public bool HIKInit()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info("HIKInit");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                m_bInitSDK = CHCNetSDK.NET_DVR_Init();
 | 
					                m_bInitSDK = CHCNetSDK.NET_DVR_Init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"HIKInit-{m_bInitSDK}");
 | 
				
			||||||
                if (m_bInitSDK == false)
 | 
					                if (m_bInitSDK == false)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    //MessageBox.Show("NET_DVR_Init error!");
 | 
					                    //MessageBox.Show("NET_DVR_Init error!");
 | 
				
			||||||
| 
						 | 
					@ -48,11 +59,19 @@ namespace DM_Weight.HIKVISION
 | 
				
			||||||
                    //保存SDK日志 To save the SDK log
 | 
					                    //保存SDK日志 To save the SDK log
 | 
				
			||||||
                    CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
 | 
					                    CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"HIKInit Exception:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            return m_bInitSDK;
 | 
					            return m_bInitSDK;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public int HIKLogin()
 | 
					        public int HIKLogin()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info("HIKLogin");
 | 
				
			||||||
                string ip = ReadApp.ReadAppSetting("HIKIP");
 | 
					                string ip = ReadApp.ReadAppSetting("HIKIP");
 | 
				
			||||||
                string port = ReadApp.ReadAppSetting("HIKPort");
 | 
					                string port = ReadApp.ReadAppSetting("HIKPort");
 | 
				
			||||||
                string userName = ReadApp.ReadAppSetting("HIKUser");
 | 
					                string userName = ReadApp.ReadAppSetting("HIKUser");
 | 
				
			||||||
| 
						 | 
					@ -121,11 +140,20 @@ namespace DM_Weight.HIKVISION
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    HKUserId = -1;
 | 
					                    HKUserId = -1;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"HIKLogin Exception:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            return HKUserId;
 | 
					            return HKUserId;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void HIKLoginOut()
 | 
					        public void HIKLoginOut()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (m_lRealHandle >= 0)
 | 
					                if (m_lRealHandle >= 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    bool stopRealPlay = CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
 | 
					                    bool stopRealPlay = CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
 | 
				
			||||||
| 
						 | 
					@ -141,21 +169,65 @@ namespace DM_Weight.HIKVISION
 | 
				
			||||||
                    bool cleanUp = CHCNetSDK.NET_DVR_Cleanup();
 | 
					                    bool cleanUp = CHCNetSDK.NET_DVR_Cleanup();
 | 
				
			||||||
                    logger.Info($"录像机NET_DVR_Cleanup接口返回{cleanUp}");
 | 
					                    logger.Info($"录像机NET_DVR_Cleanup接口返回{cleanUp}");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"HIKLoginOut Exception{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool HIKStartDVRRecord()
 | 
					        public bool HIKStartDVRRecord()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            bool isStart= CHCNetSDK.NET_DVR_StartDVRRecord(HKUserId, 0xffff, 0);
 | 
					            bool isStart = false;
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                isStart = CHCNetSDK.NET_DVR_StartDVRRecord(HKUserId, 0xffff, 0);
 | 
				
			||||||
                logger.Info($"录像机NET_DVR_StartDVRRecord接口返回{isStart}");
 | 
					                logger.Info($"录像机NET_DVR_StartDVRRecord接口返回{isStart}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"HIKStartDVRRecord Exception{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            return isStart;
 | 
					            return isStart;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public bool HIKStopDVRRecord()
 | 
					        public bool HIKStopDVRRecord()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            bool isStop = CHCNetSDK.NET_DVR_StopDVRRecord(HKUserId, 0xffff);
 | 
					            bool isStop = false;
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                isStop = CHCNetSDK.NET_DVR_StopDVRRecord(HKUserId, 0xffff);
 | 
				
			||||||
                logger.Info($"录像机NET_DVR_StopDVRRecord接口返回{isStop}");
 | 
					                logger.Info($"录像机NET_DVR_StopDVRRecord接口返回{isStop}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"HIKStopDVRRecord Exception{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            return isStop;
 | 
					            return isStop;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        public void HIK_DVR_TIME()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                UInt32 dwReturn = 0;
 | 
				
			||||||
 | 
					                Int32 nSize = Marshal.SizeOf(m_struTimeCfg);
 | 
				
			||||||
 | 
					                IntPtr ptrTimeCfg = Marshal.AllocHGlobal(nSize);
 | 
				
			||||||
 | 
					                Marshal.StructureToPtr(m_struTimeCfg, ptrTimeCfg, false);
 | 
				
			||||||
 | 
					                if (CHCNetSDK.NET_DVR_GetDVRConfig(HKUserId, CHCNetSDK.NET_DVR_GET_TIMECFG, -1, ptrTimeCfg, (UInt32)nSize, ref dwReturn))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    m_struTimeCfg = (CHCNetSDK.NET_DVR_TIME)Marshal.PtrToStructure(ptrTimeCfg, typeof(CHCNetSDK.NET_DVR_TIME));
 | 
				
			||||||
 | 
					                    logger.Info($"录像机时间接口{Convert.ToString(m_struTimeCfg.dwYear)}- {Convert.ToString(m_struTimeCfg.dwMonth)}- {Convert.ToString(m_struTimeCfg.dwDay)}- {Convert.ToString(m_struTimeCfg.dwHour)}- {Convert.ToString(m_struTimeCfg.dwMinute)}- {Convert.ToString(m_struTimeCfg.dwSecond)}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"HIK_DVR_TIME Exception{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 清理所有正在使用的资源。
 | 
					        /// 清理所有正在使用的资源。
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,152 @@
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("account_book_g2")]
 | 
				
			||||||
 | 
					    public class AccountBookG2
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id",IsPrimaryKey =true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 1领入2发出3日结4总结5转结
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "type")]
 | 
				
			||||||
 | 
					        public int Type { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 科室
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "department")]
 | 
				
			||||||
 | 
					        public string Department { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 设备内记录凭证
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "invoice_no")] 
 | 
				
			||||||
 | 
					        public string InvoiceNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 处方号或凭证号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "order_no")]
 | 
				
			||||||
 | 
					        public string OrderNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 批次
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
 | 
					        public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 效期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "eff_date")]
 | 
				
			||||||
 | 
					        public string EffDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 上日结存
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "yesterday_quantity")]
 | 
				
			||||||
 | 
					        public int YQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 收入
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "add_quantity")]
 | 
				
			||||||
 | 
					        public int AddQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 发出
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "out_quantity")]
 | 
				
			||||||
 | 
					        public int OutQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 批次结存
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_stock")]
 | 
				
			||||||
 | 
					        public int ManuStock { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 总结存
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "total_stock")]
 | 
				
			||||||
 | 
					        public int TotalStock { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  发药领药人id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "user_id1")]
 | 
				
			||||||
 | 
					        public int? UserId1 { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 复核人id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "user_id2")]
 | 
				
			||||||
 | 
					        public int? UserId2 { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 设备id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "create_date")]
 | 
				
			||||||
 | 
					        public string CreateDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 插入更新时间(当前时间戳)
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "create_time")]
 | 
				
			||||||
 | 
					        public DateTime CreateTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public string DrugName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 规格
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string DrugSpec { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 厂家
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string Manufactory { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 发药人
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string OperatorName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 复核人
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string ReviewerName { get;set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 账册类型
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public class AccountType
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 账册类型名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string AccountTypeName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 账册类型值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public int AccountTypeValue { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -58,12 +58,13 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /////</summary>
 | 
					        /////</summary>
 | 
				
			||||||
        //[SugarColumn(ColumnName = "manu_no")]
 | 
					        //[SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
        //public string ManuNo { get; set; }
 | 
					        //public string ManuNo { get; set; }
 | 
				
			||||||
        ///// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /////  
 | 
					        ///  
 | 
				
			||||||
        ///// 默认值: NULL
 | 
					        ///这个值 用于控制柜子使用与未使用的状态
 | 
				
			||||||
        /////</summary>
 | 
					        ///自始至终未使用是空值,打开了则记录当前打开时间,根据时间修改按钮颜色
 | 
				
			||||||
        //[SugarColumn(ColumnName = "eff_date")]
 | 
					        ///</summary>
 | 
				
			||||||
        //public string EffDate { get; set; }
 | 
					        [SugarColumn(ColumnName = "eff_date")]
 | 
				
			||||||
 | 
					        public string EffDate { get; set; }
 | 
				
			||||||
        ///// <summary>
 | 
					        ///// <summary>
 | 
				
			||||||
        /////  
 | 
					        /////  
 | 
				
			||||||
        ///// 默认值: NULL
 | 
					        ///// 默认值: NULL
 | 
				
			||||||
| 
						 | 
					@ -73,20 +74,27 @@ namespace DM_Weight.Models
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: 1
 | 
					        /// 默认值: 1 (公共药箱值为1,归属个人药箱值为0)
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "drawer_type")]
 | 
					        [SugarColumn(ColumnName = "drawer_type")]
 | 
				
			||||||
        public int DrawerType { get; set; }
 | 
					        public int DrawerType { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 药箱状态  1药箱在,0药箱不在;(药箱在时开药箱为:取药箱,药箱不在时开药箱为:还药箱)
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drawer_state")]
 | 
				
			||||||
 | 
					        public int DrawerState { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: 1
 | 
					        /// 默认值: 1
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "board_type")]
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
        public int BoardType { get; set; }
 | 
					        public int BoardType { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: 1
 | 
					        /// 默认值: 1
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        [SugarColumn(ColumnName = "state")]
 | 
					        [SugarColumn(ColumnName = "state")]
 | 
				
			||||||
        public int? State { get; set; }
 | 
					        public int? State { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,6 +109,11 @@ namespace DM_Weight.Models
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => DrawerNo + "-" + ColNo;
 | 
					            get => DrawerNo + "-" + ColNo;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName ="yh_no")]
 | 
				
			||||||
 | 
					        public string BelongUser
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get;set;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        //private int _addQuantity = 0;
 | 
					        //private int _addQuantity = 0;
 | 
				
			||||||
        //[SugarColumn(IsIgnore = true)]
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        //public int AddQuantity
 | 
					        //public int AddQuantity
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -87,7 +87,7 @@ namespace DM_Weight.Models
 | 
				
			||||||
        public int BoardType { get; set; }
 | 
					        public int BoardType { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: 1
 | 
					        /// 默认值: 1(用于标识毒麻柜是否给交接柜补药:0未补,1已补)
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "state")]
 | 
					        [SugarColumn(ColumnName = "state")]
 | 
				
			||||||
        public int? State { get; set; }
 | 
					        public int? State { get; set; }
 | 
				
			||||||
| 
						 | 
					@ -167,6 +167,19 @@ namespace DM_Weight.Models
 | 
				
			||||||
                SetProperty(ref _checkQuantity, value);
 | 
					                SetProperty(ref _checkQuantity, value);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品基数
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private int _baseQuantity = 0;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Check_Quantity")]
 | 
				
			||||||
 | 
					        public int BaseQuantity
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _baseQuantity;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _baseQuantity, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
| 
						 | 
					@ -175,6 +188,7 @@ namespace DM_Weight.Models
 | 
				
			||||||
        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
 | 
				
			||||||
        public DrugInfo DrugInfo { get; set; }
 | 
					        public DrugInfo DrugInfo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public int process { get; set; } = 0;
 | 
					        public int process { get; set; } = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,6 +198,15 @@ namespace DM_Weight.Models
 | 
				
			||||||
        private ChannelList? _channelList;
 | 
					        private ChannelList? _channelList;
 | 
				
			||||||
        [Navigate(NavigateType.ManyToOne, nameof(Chnguid))]
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(Chnguid))]
 | 
				
			||||||
        public ChannelList ChannelLst { get => _channelList; set => SetProperty(ref _channelList, value); }
 | 
					        public ChannelList ChannelLst { get => _channelList; set => SetProperty(ref _channelList, value); }
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public DrugPleaseClaim PleaseClaim { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //dm_machine_record表id值
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int? MachineRecordId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string OrderNos { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,122 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Controls;
 | 
				
			||||||
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 处方、请领单中间表
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    [SugarTable("order_apply")]
 | 
				
			||||||
 | 
					    public class CollectDrug
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 是否选择
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public bool IsSelected { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Applyid")]
 | 
				
			||||||
 | 
					        public int Applyid { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品请领单号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Drug_plase_id")]
 | 
				
			||||||
 | 
					        public string DrugPleaseClaimId { get; set; }
 | 
				
			||||||
 | 
					        /// 处方
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "OrderNo")]
 | 
				
			||||||
 | 
					        public string OrderNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品ID
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Drug_Id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 患者ID
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string PatientId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 姓名
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public string PName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 性别
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public string Sex { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 年龄
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)] 
 | 
				
			||||||
 | 
					        public string Age { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 身份证号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)] 
 | 
				
			||||||
 | 
					        public string IdNumber { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 科室
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)] 
 | 
				
			||||||
 | 
					        public string DeptName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)] 
 | 
				
			||||||
 | 
					        public string DrugName { get;set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 规格
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)] 
 | 
				
			||||||
 | 
					        public string DrugSpec { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 厂家
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)] 
 | 
				
			||||||
 | 
					        public string Manufactory { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Quantity")]
 | 
				
			||||||
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Createdate")]
 | 
				
			||||||
 | 
					        public DateTime Createdate { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 状态
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Status")] 
 | 
				
			||||||
 | 
					        public int Status { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Machine_id")] 
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Current_Machine_id")]
 | 
				
			||||||
 | 
					        public string CurrentMachineId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToOne, nameof(DrugId))]
 | 
				
			||||||
 | 
					        public DrugInfo drugInfo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 请领表
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(DrugPleaseClaimId))]
 | 
				
			||||||
 | 
					        public DrugPleaseClaim drugPleaseClaim { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public List<DrugPleaseManuNo> ManuNoList { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,36 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("destory_detail")]
 | 
				
			||||||
 | 
					    public class DestoryDetail
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int ID { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operatorid")]
 | 
				
			||||||
 | 
					        public int? Operatorid { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "reviewerid")]
 | 
				
			||||||
 | 
					        public int? Reviewerid { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "recordId")]
 | 
				
			||||||
 | 
					        public int RecordId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "orderId")]
 | 
				
			||||||
 | 
					        public int OrderId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 药品基数表
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    [SugarTable("drug_base")]
 | 
				
			||||||
 | 
					    public class DrugBase:BindableBase
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private int _baseId = 0;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "baseid", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } }
 | 
				
			||||||
 | 
					        private string _drugId;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drugid")]
 | 
				
			||||||
 | 
					        public string DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } }
 | 
				
			||||||
 | 
					        private string _machineId = "";
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } }
 | 
				
			||||||
 | 
					        private int _baseQuantity = 0;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "baseQuantity")]
 | 
				
			||||||
 | 
					        public int BaseQuantity { get=>_baseQuantity; set{ SetProperty(ref _baseQuantity, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
using SqlSugar;
 | 
					using SqlSugar;
 | 
				
			||||||
namespace DM_Weight.Models
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -8,7 +9,7 @@ namespace DM_Weight.Models
 | 
				
			||||||
    /// 
 | 
					    /// 
 | 
				
			||||||
    ///</summary>
 | 
					    ///</summary>
 | 
				
			||||||
    [SugarTable("drug_info")]
 | 
					    [SugarTable("drug_info")]
 | 
				
			||||||
    public class DrugInfo
 | 
					    public class DrugInfo:BindableBase
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
| 
						 | 
					@ -19,7 +20,7 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// ҩƷID 
 | 
					        /// ҩƷID 
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
 | 
					        [SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
 | 
				
			||||||
        public long DrugId { get; set; }
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// ƴ 
 | 
					        /// ƴ 
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
| 
						 | 
					@ -71,6 +72,13 @@ namespace DM_Weight.Models
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "max_stock")]
 | 
					        [SugarColumn(ColumnName = "max_stock")]
 | 
				
			||||||
        public int? MaxStock { get; set; }
 | 
					        public int? MaxStock { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品类型
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName ="drug_type")]
 | 
				
			||||||
 | 
					        public string DrugType { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //[SugarColumn(IsIgnore=true)]
 | 
					        //[SugarColumn(IsIgnore=true)]
 | 
				
			||||||
        [Navigate(NavigateType.OneToMany, nameof(ChannelStock.DrugId), nameof(DrugId))]//BookA表中的studenId
 | 
					        [Navigate(NavigateType.OneToMany, nameof(ChannelStock.DrugId), nameof(DrugId))]//BookA表中的studenId
 | 
				
			||||||
        public List<ChannelStock> channelStocks { get; set; }
 | 
					        public List<ChannelStock> channelStocks { get; set; }
 | 
				
			||||||
| 
						 | 
					@ -81,5 +89,17 @@ namespace DM_Weight.Models
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public int? StockQuantity { get; set; }
 | 
					        public int? StockQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private DrugBase _base;
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToOne, nameof(DrugBase.DrugId), nameof(DrugId))]
 | 
				
			||||||
 | 
					        public DrugBase drugBase
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get=> _base;
 | 
				
			||||||
 | 
					            set { SetProperty(ref _base, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public string drug_name_spec { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,130 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 请领申请表
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    [SugarTable("drug_please_claim")]
 | 
				
			||||||
 | 
					    public class DrugPleaseClaim
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id")]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 请领数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "get_quantity")]
 | 
				
			||||||
 | 
					        public int GetQuantity { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 交处方张数
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "return_prescription_quantity")]
 | 
				
			||||||
 | 
					        public int ReturnPrQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 处方用量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "prescription_quantity")]
 | 
				
			||||||
 | 
					        public int PrescriptionQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 空瓶数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "empties_quantity")]
 | 
				
			||||||
 | 
					        public int EmptiesQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 实发数
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "issue_quantity")]
 | 
				
			||||||
 | 
					        public int IssueQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 批次(多条)
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_manu_no")]
 | 
				
			||||||
 | 
					        [JsonProperty("drug_manu_no")]
 | 
				
			||||||
 | 
					        public string _DrugManuNos { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 备注1
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "notes_nn")]
 | 
				
			||||||
 | 
					        public string NotesNN { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 备注2
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "notes_n")]
 | 
				
			||||||
 | 
					        public string NotesN { get;set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 32:三级向二级请领;23:二级向三级退;
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "type")]
 | 
				
			||||||
 | 
					        public int Type { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 0:创建完成;1:二级已授权;2:一级已查阅;3:已关联His
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "state")]
 | 
				
			||||||
 | 
					        public int State { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 凭证号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "voucher")]
 | 
				
			||||||
 | 
					        public string Voucher { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 机器id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 创建时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "do_date")]
 | 
				
			||||||
 | 
					        public DateTime DoDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 申请人
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "apply_user")]
 | 
				
			||||||
 | 
					        public int ApplyUser { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 复核人
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "exp_user")]
 | 
				
			||||||
 | 
					        public int ReviewUser { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "please_no", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public string PleaseNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "department")]
 | 
				
			||||||
 | 
					        public string Department { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "totalQuantity")]
 | 
				
			||||||
 | 
					        public int TotalQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //[Navigate(NavigateType.ManyToMany, nameof(PleaseNo))]
 | 
				
			||||||
 | 
					        //public CollectDrug collectDrug { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToOne, nameof(DrugId))]
 | 
				
			||||||
 | 
					        public DrugInfo DrugInfo { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class DrugPleaseManuNo
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string EffDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Quantity { 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
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class DrugPleaseState
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品请领状态名
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string StateName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  药品请领状态值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public int StateValue { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,14 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class DrugType
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public int TypeValue { get; set; }
 | 
				
			||||||
 | 
					        public string TypeName { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -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; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using SqlSugar;
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
| 
						 | 
					@ -9,7 +10,7 @@ using System.Threading.Tasks;
 | 
				
			||||||
namespace DM_Weight.Models
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    [SugarTable("dm_machine_record")]
 | 
					    [SugarTable("dm_machine_record")]
 | 
				
			||||||
    public class MachineRecord
 | 
					    public class MachineRecord : BindableBase
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 主键 
 | 
					        /// 主键 
 | 
				
			||||||
| 
						 | 
					@ -36,11 +37,11 @@ namespace DM_Weight.Models
 | 
				
			||||||
        public int Quantity { get; set; }
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(ColumnName = "stock_quantity")]
 | 
					        //[SugarColumn(ColumnName = "stock_quantity")]
 | 
				
			||||||
        public int? StockQuantity { get; set; }
 | 
					        //public int? StockQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(ColumnName = "check_quantity")]
 | 
					        //[SugarColumn(ColumnName = "check_quantity")]
 | 
				
			||||||
        public int? CheckQuantity { get; set; }
 | 
					        //public int? CheckQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 批号 
 | 
					        /// 批号 
 | 
				
			||||||
| 
						 | 
					@ -77,6 +78,11 @@ namespace DM_Weight.Models
 | 
				
			||||||
        [SugarColumn(ColumnName = "type")]
 | 
					        [SugarColumn(ColumnName = "type")]
 | 
				
			||||||
        public int Type { get; set; }
 | 
					        public int Type { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///操作类型(1放入药箱;0取走药箱) 
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "option_type")]
 | 
				
			||||||
 | 
					        public int OptionType { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
        /// 出入库调拨单id 
 | 
					        /// 出入库调拨单id 
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "invoice_id")]
 | 
					        [SugarColumn(ColumnName = "invoice_id")]
 | 
				
			||||||
| 
						 | 
					@ -106,14 +112,16 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// 退药量 
 | 
					        /// 退药量 
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private int returnQuantity1;
 | 
				
			||||||
        [SugarColumn(ColumnName = "return_quantity1", IsOnlyIgnoreInsert = true)]
 | 
					        [SugarColumn(ColumnName = "return_quantity1", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
        public int ReturnQuantity1 { get; set; }
 | 
					        public int ReturnQuantity1 { get => returnQuantity1; set => SetProperty(ref returnQuantity1, value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 退空瓶量 
 | 
					        /// 退空瓶量 
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private int returnQuantity2;
 | 
				
			||||||
        [SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true)]
 | 
					        [SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
        public int ReturnQuantity2 { get; set; }
 | 
					        public int ReturnQuantity2 { get => returnQuantity2; set => SetProperty(ref returnQuantity2, value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 取药记录id 
 | 
					        /// 取药记录id 
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
| 
						 | 
					@ -126,6 +134,19 @@ namespace DM_Weight.Models
 | 
				
			||||||
        [SugarColumn(ColumnName = "is_destroy", IsOnlyIgnoreInsert = true)]
 | 
					        [SugarColumn(ColumnName = "is_destroy", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
        public int? IsDestroy { get; set; }
 | 
					        public int? IsDestroy { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 销毁操作人 
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "take_user", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
 | 
					        public string TakeUser { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 销毁审核人 
 | 
				
			||||||
 | 
					        /// 默认值: 0
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "fuzeren", IsOnlyIgnoreInsert = true)]
 | 
				
			||||||
 | 
					        public string DestoryReviewerUser { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
| 
						 | 
					@ -137,5 +158,42 @@ namespace DM_Weight.Models
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public bool IsSelected { get; set; }
 | 
					        public bool IsSelected { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 已核销数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private int hasCheckNum;
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int HasCheckNum
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => hasCheckNum;
 | 
				
			||||||
 | 
					            set => SetProperty(ref hasCheckNum, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int checkQuantity;
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 核销数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
 | 
					        public int CheckQuantity
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => checkQuantity;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (value > Quantity - hasCheckNum)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    throw new ArgumentException("核销数量不能大于取药数量");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //退空瓶
 | 
				
			||||||
 | 
					                ReturnQuantity2 = value + hasCheckNum;
 | 
				
			||||||
 | 
					                //退药量
 | 
				
			||||||
 | 
					                ReturnQuantity1 = Quantity - value - hasCheckNum;
 | 
				
			||||||
 | 
					                SetProperty(ref checkQuantity, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToMany, nameof(SurgicalScheduleDetail.GetRecordId))]
 | 
				
			||||||
 | 
					        public List<SurgicalScheduleDetail> _SurgicalScheduleDetailLst { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,20 +7,20 @@ namespace DM_Weight.Models
 | 
				
			||||||
    /// <summary>
 | 
					    /// <summary>
 | 
				
			||||||
    /// 
 | 
					    /// 
 | 
				
			||||||
    ///</summary>
 | 
					    ///</summary>
 | 
				
			||||||
    [SugarTable("order_detail")]
 | 
					    [SugarTable("order_detail_sm")]
 | 
				
			||||||
    public class OrderDetail
 | 
					    public class OrderDetail
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
 | 
					        //[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
 | 
				
			||||||
        public int Id { get; set; }
 | 
					        //public int Id { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        //[SugarColumn(ColumnName = "order_id")]
 | 
					        [SugarColumn(ColumnName = "order_id", IsPrimaryKey = true)]
 | 
				
			||||||
        //public int? OrderId { get; set; }
 | 
					        public int? OrderId { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
| 
						 | 
					@ -127,5 +127,21 @@ namespace DM_Weight.Models
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "use_dosage")]
 | 
					        [SugarColumn(ColumnName = "use_dosage")]
 | 
				
			||||||
        public string UseDosage { get; set; }
 | 
					        public string UseDosage { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //[Navigate(NavigateType.ManyToOne, nameof(OrderNo))]
 | 
				
			||||||
 | 
					        //public OrderInfo _OrderInfo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string DrawerNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public string ColNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.ManyToOne, nameof(OrderId))]
 | 
				
			||||||
 | 
					        public OrderInfo _OrderInfo { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,164 +1,189 @@
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
using SqlSugar;
 | 
					using SqlSugar;
 | 
				
			||||||
namespace DM_Weight.Models
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /// <summary>
 | 
					    /// <summary>
 | 
				
			||||||
    /// 
 | 
					    /// 
 | 
				
			||||||
    ///</summary>
 | 
					    ///</summary>
 | 
				
			||||||
    [SugarTable("order_info")]
 | 
					    [SugarTable("order_info_sm")]
 | 
				
			||||||
    public class OrderInfo
 | 
					    public class OrderInfo:BindableBase
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 是否选中
 | 
					        /// 是否选中
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private bool _itemIsChecked;
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public bool ItemIsChecked { get; set; }
 | 
					        public bool ItemIsChecked { get=> _itemIsChecked; set=>SetProperty(ref _itemIsChecked,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private int _orderId;
 | 
				
			||||||
        [SugarColumn(ColumnName = "order_id", IsPrimaryKey = true, IsIdentity = true)]
 | 
					        [SugarColumn(ColumnName = "order_id", IsPrimaryKey = true, IsIdentity = true)]
 | 
				
			||||||
        public int OrderId { get; set; }
 | 
					        public int OrderId { get=> _orderId; set=>SetProperty(ref _orderId,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _pharmacy;
 | 
				
			||||||
        [SugarColumn(ColumnName = "pharmacy")]
 | 
					        [SugarColumn(ColumnName = "pharmacy")]
 | 
				
			||||||
        public string Pharmacy { get; set; }
 | 
					        public string Pharmacy { get=>_pharmacy; set=>SetProperty(ref _pharmacy,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _orderNo;
 | 
				
			||||||
        [SugarColumn(ColumnName = "order_no")]
 | 
					        [SugarColumn(ColumnName = "order_no")]
 | 
				
			||||||
        public string OrderNo { get; set; }
 | 
					        public string OrderNo { get=> _orderNo; set=>SetProperty(ref _orderNo,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _patientId;
 | 
				
			||||||
        [SugarColumn(ColumnName = "patient_id")]
 | 
					        [SugarColumn(ColumnName = "patient_id")]
 | 
				
			||||||
        public string PatientId { get; set; }
 | 
					        public string PatientId { get=> _patientId; set=>SetProperty(ref _patientId,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _pName;
 | 
				
			||||||
        [SugarColumn(ColumnName = "p_name")]
 | 
					        [SugarColumn(ColumnName = "p_name")]
 | 
				
			||||||
        public string PName { get; set; }
 | 
					        public string PName { get=> _pName; set=>SetProperty(ref _pName,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _sex;
 | 
				
			||||||
        [SugarColumn(ColumnName = "sex")]
 | 
					        [SugarColumn(ColumnName = "sex")]
 | 
				
			||||||
        public string Sex { get; set; }
 | 
					        public string Sex { get=> _sex; set=>SetProperty(ref _sex,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _age;
 | 
				
			||||||
        [SugarColumn(ColumnName = "age")]
 | 
					        [SugarColumn(ColumnName = "age")]
 | 
				
			||||||
        public string Age { get; set; }
 | 
					        public string Age { get=> _age; set=>SetProperty(ref _age,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _idNumber;
 | 
				
			||||||
        [SugarColumn(ColumnName = "id_number")]
 | 
					        [SugarColumn(ColumnName = "id_number")]
 | 
				
			||||||
        public string IdNumber { get; set; }
 | 
					        public string IdNumber { get=> _idNumber; set=> SetProperty(ref _idNumber, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _patientCard;
 | 
				
			||||||
        [SugarColumn(ColumnName = "patient_card")]
 | 
					        [SugarColumn(ColumnName = "patient_card")]
 | 
				
			||||||
        public string PatientCard { get; set; }
 | 
					        public string PatientCard { get=> _patientCard; set=>SetProperty(ref _patientCard,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _invoiceNo;
 | 
				
			||||||
        [SugarColumn(ColumnName = "invoice_no")]
 | 
					        [SugarColumn(ColumnName = "invoice_no")]
 | 
				
			||||||
        public string InvoiceNo { get; set; }
 | 
					        public string InvoiceNo { get=> _invoiceNo; set=>SetProperty(ref _invoiceNo,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _patientNo;
 | 
				
			||||||
        [SugarColumn(ColumnName = "patient_no")]
 | 
					        [SugarColumn(ColumnName = "patient_no")]
 | 
				
			||||||
        public string PatientNo { get; set; }
 | 
					        public string PatientNo { get=> _patientNo; set=>SetProperty(ref _patientNo,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _doctorName;
 | 
				
			||||||
        [SugarColumn(ColumnName = "doctor_name")]
 | 
					        [SugarColumn(ColumnName = "doctor_name")]
 | 
				
			||||||
        public string DoctorName { get; set; }
 | 
					        public string DoctorName { get=> _doctorName; set=>SetProperty(ref _doctorName,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private DateTime _orderDate;
 | 
				
			||||||
        [SugarColumn(ColumnName = "order_date")]
 | 
					        [SugarColumn(ColumnName = "order_date")]
 | 
				
			||||||
        public DateTime OrderDate { get; set; }
 | 
					        public DateTime OrderDate { get=> _orderDate; set=>SetProperty(ref _orderDate,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private DateTime _chargeDate;
 | 
				
			||||||
        [SugarColumn(ColumnName = "charge_date")]
 | 
					        [SugarColumn(ColumnName = "charge_date")]
 | 
				
			||||||
        public DateTime ChargeDate { get; set; }
 | 
					        public DateTime ChargeDate { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private DateTime _recvDate;
 | 
				
			||||||
        [SugarColumn(ColumnName = "recv_date")]
 | 
					        [SugarColumn(ColumnName = "recv_date")]
 | 
				
			||||||
        public DateTime RecvDate { get; set; }
 | 
					        public DateTime RecvDate { get=> _recvDate; set=>SetProperty(ref _recvDate,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _deptName;
 | 
				
			||||||
        [SugarColumn(ColumnName = "dept_name")]
 | 
					        [SugarColumn(ColumnName = "dept_name")]
 | 
				
			||||||
        public string DeptName { get; set; }
 | 
					        public string DeptName { get=> _deptName; set=>SetProperty(ref _deptName,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _disease;
 | 
				
			||||||
        [SugarColumn(ColumnName = "disease")]
 | 
					        [SugarColumn(ColumnName = "disease")]
 | 
				
			||||||
        public string Disease { get; set; }
 | 
					        public string Disease { get=> _disease; set=>SetProperty(ref _disease,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _orderType;
 | 
				
			||||||
        [SugarColumn(ColumnName = "order_type")]
 | 
					        [SugarColumn(ColumnName = "order_type")]
 | 
				
			||||||
        public string OrderType { get; set; }
 | 
					        public string OrderType { get=> _orderType; set=>SetProperty(ref _orderType,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _chargeType;
 | 
				
			||||||
        [SugarColumn(ColumnName = "charge_type")]
 | 
					        [SugarColumn(ColumnName = "charge_type")]
 | 
				
			||||||
        public string ChargeType { get; set; }
 | 
					        public string ChargeType { get=> _chargeType; set=>SetProperty(ref _chargeType,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private int _state;
 | 
				
			||||||
        [SugarColumn(ColumnName = "state")]
 | 
					        [SugarColumn(ColumnName = "state")]
 | 
				
			||||||
        public int State { get; set; }
 | 
					        public int State { get=> _state; set=>SetProperty(ref _state,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private int? _hisDispFlag;
 | 
				
			||||||
        [SugarColumn(ColumnName = "his_disp_flag")]
 | 
					        [SugarColumn(ColumnName = "his_disp_flag")]
 | 
				
			||||||
        public int? HisDispFlag { get; set; }
 | 
					        public int? HisDispFlag { get=> _hisDispFlag; set=>SetProperty(ref _hisDispFlag,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>]
 | 
				
			||||||
 | 
					        private int? _cancelFlag;
 | 
				
			||||||
        [SugarColumn(ColumnName = "cancel_flag")]
 | 
					        [SugarColumn(ColumnName = "cancel_flag")]
 | 
				
			||||||
        public int? CancelFlag { get; set; }
 | 
					        public int? CancelFlag { get=> _cancelFlag; set=>SetProperty(ref _cancelFlag,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  添加值1药师已确认,2管理已核对处方
 | 
				
			||||||
        /// 默认值: 0
 | 
					        /// 默认值: 0
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private int? _dmStatus;
 | 
				
			||||||
        [SugarColumn(ColumnName = "dm_status")]
 | 
					        [SugarColumn(ColumnName = "dm_status")]
 | 
				
			||||||
        public int? DmStatus { get; set; }
 | 
					        public int? DmStatus { get=> _dmStatus; set=>SetProperty(ref _dmStatus,value); }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
| 
						 | 
					@ -177,6 +202,21 @@ namespace DM_Weight.Models
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        [SugarColumn(ColumnName = "costs")]
 | 
					        [SugarColumn(ColumnName = "costs")]
 | 
				
			||||||
        public decimal? Costs { get; set; }
 | 
					        public decimal? Costs { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品请领状态(0未请领;1已请领)
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "apply_status")]
 | 
				
			||||||
 | 
					        public int ApplyStatus { get;set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "machine_id")]
 | 
				
			||||||
 | 
					        public string MachineId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
| 
						 | 
					@ -198,5 +238,25 @@ namespace DM_Weight.Models
 | 
				
			||||||
        //public string Identity { get; set; }
 | 
					        //public string Identity { get; set; }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToMany, nameof(OrderDetail.OrderId))]
 | 
				
			||||||
 | 
					        public List<OrderDetail> OrderDetailList { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //一个处方对应一种药
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToOne, nameof(OrderDetail.OrderId))]
 | 
				
			||||||
 | 
					        public OrderDetail _OrderDetail { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //处方下药品总数
 | 
				
			||||||
 | 
					        [SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        public int TotalQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //麻醉师工号
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "anaesthetist_code")]
 | 
				
			||||||
 | 
					        public string DoctorCode { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //麻醉师姓名
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "anaesthetist_name")]
 | 
				
			||||||
 | 
					        public string AnaesthetistName { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,102 @@
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("rejection_report")]
 | 
				
			||||||
 | 
					    public class RejectionReport
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 发药时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "SendDate")]
 | 
				
			||||||
 | 
					        public DateTime SendDate { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 发药者
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "SendUser")]
 | 
				
			||||||
 | 
					        public string SendUser { get;set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 领药者
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ReceiveUser")]
 | 
				
			||||||
 | 
					        public string ReceiveUser { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 实发数
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "RealNum")]
 | 
				
			||||||
 | 
					        public int RealNum { get;set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 实物数
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "InfactNum")]
 | 
				
			||||||
 | 
					        public int InfactNum { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 空安瓿
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "EmptyNum")]
 | 
				
			||||||
 | 
					        public int EmptyNum { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 还药时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ReturnTime")]
 | 
				
			||||||
 | 
					        public string ReturnTime { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 还药者
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ReturnUser")]
 | 
				
			||||||
 | 
					        public string ReturnUser { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 接收者
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ReturnReceiveUser")]
 | 
				
			||||||
 | 
					        public string ReturnReceiveUser { get;set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 补充者
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "AddUser")]
 | 
				
			||||||
 | 
					        public string AddUser { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 核对者
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "AddCheckUser")]
 | 
				
			||||||
 | 
					        public string AddCheckUser { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 操作时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "OperationTime")]
 | 
				
			||||||
 | 
					        public DateTime OperationTime { get; set; }
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "DrugId")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "DrugName")]
 | 
				
			||||||
 | 
					        public string DrugName { get; set;}
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品规格
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "DrugSpec")]
 | 
				
			||||||
 | 
					        public string DrugSpec { get;set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 总基数
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "BaseNum")]
 | 
				
			||||||
 | 
					        public string BaseNum { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药箱号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "DrawerNo")]
 | 
				
			||||||
 | 
					        public int DrawerNo { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,56 @@
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("SettingPage")]
 | 
				
			||||||
 | 
					    public class SettingPage
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public string Id { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 页面名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Name")]
 | 
				
			||||||
 | 
					        public string Name { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 页面连接
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Url")]
 | 
				
			||||||
 | 
					        public string Url { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///可用标志
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Flag")]
 | 
				
			||||||
 | 
					        public string Flag { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// view名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ViewName")]
 | 
				
			||||||
 | 
					        public string ViewName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 图标名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "IconName")]
 | 
				
			||||||
 | 
					        public string Icon { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 层级
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Level")]
 | 
				
			||||||
 | 
					        public int Level { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 父级id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "Parentid")]
 | 
				
			||||||
 | 
					        public int Parentid { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 0可用1不可用
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "State")]
 | 
				
			||||||
 | 
					        public int State { 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,176 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("surgical_schedule")]
 | 
				
			||||||
 | 
					    public class SurgicalSchedule
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术ID
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operation_id")]
 | 
				
			||||||
 | 
					        public string OperationId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 患者id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_id")]
 | 
				
			||||||
 | 
					        public string PatientId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 患者姓名
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "patient_name")]
 | 
				
			||||||
 | 
					        public string PName { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 住院号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "hospital_no")]
 | 
				
			||||||
 | 
					        public string HospitalNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 床号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "bed_no")]
 | 
				
			||||||
 | 
					        public string BedNo { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 性别
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "sex")]
 | 
				
			||||||
 | 
					        public string Sex { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 年龄
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "age")]
 | 
				
			||||||
 | 
					        public string Age { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 出生日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "birthday")]
 | 
				
			||||||
 | 
					        public DateTime Birthday { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 身份证号
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id_number")]
 | 
				
			||||||
 | 
					        public string IdNumber { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 住院病区
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ward_code")]
 | 
				
			||||||
 | 
					        public string WardCode { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 联系电话
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "link_tel")]
 | 
				
			||||||
 | 
					        public string LinkTel { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 联系地址
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "link_addr")]
 | 
				
			||||||
 | 
					        public string LinkAddr { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 入院日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "in_date")]
 | 
				
			||||||
 | 
					        public string Indate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 入院诊断
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "in_diagnosis")]
 | 
				
			||||||
 | 
					        public string Indiagnosis { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 医生姓名
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "doctor_name")]
 | 
				
			||||||
 | 
					        public string DoctorName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术间代码
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "op_room_code")]
 | 
				
			||||||
 | 
					        public string OpRoomCode { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术间名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "op_room_name")]
 | 
				
			||||||
 | 
					        public string OpRoomName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 麻醉医生编码
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ana_doctor_code")]
 | 
				
			||||||
 | 
					        public string AnaDoctorCode { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 麻醉医生姓名
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "ana_doctor_name")]
 | 
				
			||||||
 | 
					        public string AnaDoctorName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术开始时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "begin_time")]
 | 
				
			||||||
 | 
					        public DateTime BeginTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术计划开始时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "schedule_time")]
 | 
				
			||||||
 | 
					        public DateTime ScheduleTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术完成时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "end_time")]
 | 
				
			||||||
 | 
					        public DateTime EndTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 数据插入时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "insert_time")]
 | 
				
			||||||
 | 
					        public DateTime InsertTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 最后一次更新时间
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "update_time")]
 | 
				
			||||||
 | 
					        public DateTime UpdateTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// HIS状态1:新开2:作废
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "his_state")]
 | 
				
			||||||
 | 
					        public int HisState { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///取药状态0未取1已取2已还
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "dm_status")]
 | 
				
			||||||
 | 
					        public int DmStatus { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "anaesthesia")]
 | 
				
			||||||
 | 
					        public string Anaesthesia { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Navigate(NavigateType.OneToMany, nameof(SurgicalSchedule.OperationId))]
 | 
				
			||||||
 | 
					        public SurgicalScheduleDetail _SurgicalScheduleDetail { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,68 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [SugarTable("surgical_schedule_detail")]
 | 
				
			||||||
 | 
					    public class SurgicalScheduleDetail
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 主键
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id",IsPrimaryKey =true)]
 | 
				
			||||||
 | 
					        public  int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 手术id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "operation_id")]
 | 
				
			||||||
 | 
					        public string OperationId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 取药记录id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "get_record_id")]
 | 
				
			||||||
 | 
					        public int GetRecordId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 处方数量
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "quantity")]
 | 
				
			||||||
 | 
					        public int Quantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品id
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "drug_id")]
 | 
				
			||||||
 | 
					        public string DrugId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 批次
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "manu_no")]
 | 
				
			||||||
 | 
					        public string ManuNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 效期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "eff_date")]
 | 
				
			||||||
 | 
					        public string EffDate { get;set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 状态
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "status")]
 | 
				
			||||||
 | 
					        public int Status { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 操作人
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "insert_user_id")]
 | 
				
			||||||
 | 
					        public int? InsertUserId { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,32 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 温湿度
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    [SugarTable("temperature_humidity")]
 | 
				
			||||||
 | 
					    public class TemperatureHumidityInfo
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
 | 
				
			||||||
 | 
					        public int ID { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "groupNo")]
 | 
				
			||||||
 | 
					        public string GroupNo { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "temp")]
 | 
				
			||||||
 | 
					        public string Temp { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "humi")]
 | 
				
			||||||
 | 
					        public string Humi { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "addTime")]
 | 
				
			||||||
 | 
					        public DateTime AddTime { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,149 @@
 | 
				
			||||||
 | 
					using DM_Weight.ViewModels;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Modbus.Device;
 | 
				
			||||||
 | 
					using Polly;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Diagnostics;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Net;
 | 
				
			||||||
 | 
					using System.Net.Sockets;
 | 
				
			||||||
 | 
					using System.Runtime.InteropServices;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ModbusHelper
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private ModbusIpMaster master;
 | 
				
			||||||
 | 
					        private Socket socket;
 | 
				
			||||||
 | 
					        private TcpClient client;
 | 
				
			||||||
 | 
					        private static ModbusHelper instance;
 | 
				
			||||||
 | 
					        private static readonly object objLock = new object();
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
 | 
				
			||||||
 | 
					        public ModbusHelper()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (ConfigurationManager.AppSettings["test"] == null || !(ConfigurationManager.AppSettings["test"].ToString().Equals("Y")))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                socket = MakeKeepALiveSocket();
 | 
				
			||||||
 | 
					                client = new TcpClient();
 | 
				
			||||||
 | 
					                client.Client = socket;
 | 
				
			||||||
 | 
					                master = ModbusIpMaster.CreateIp(client);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public static ModbusHelper GetInstance()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (instance == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                lock (objLock)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (instance == null)
 | 
				
			||||||
 | 
					                        instance = new ModbusHelper();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return instance;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SetModusIpMaster()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Debug.WriteLine("SetModusIpMaster");
 | 
				
			||||||
 | 
					            socket = MakeKeepALiveSocket();
 | 
				
			||||||
 | 
					            client = new TcpClient();
 | 
				
			||||||
 | 
					            client.Client = socket;
 | 
				
			||||||
 | 
					            master = ModbusIpMaster.CreateIp(client);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool[] GetAllBoxState()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (ConfigurationManager.AppSettings["test"] != null && ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return new bool[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false };
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            bool[] bools = Policy.Handle<Exception>()
 | 
				
			||||||
 | 
					                .Retry(3, (exception, retryCount) =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    this.Dispose();
 | 
				
			||||||
 | 
					                    //Debug.WriteLine($"获取所有箱子门状态出错,第{retryCount}次重试", exception);
 | 
				
			||||||
 | 
					                    logger.Info($"获取所有箱子门状态出错,第{retryCount}次重试, 异常信息{exception}");
 | 
				
			||||||
 | 
					                    this.SetModusIpMaster();
 | 
				
			||||||
 | 
					                    // return TimeSpan.FromSeconds (1);
 | 
				
			||||||
 | 
					                }).Execute<bool[]>(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool[] flags = new bool[18];
 | 
				
			||||||
 | 
					                    var result = master.ReadInputRegisters(1, 0x0033, 2);
 | 
				
			||||||
 | 
					                    var r1 = Convert.ToString(((int)result[0] >> 14) | ((int)result[1] << 2), 2).PadLeft(18, '0');
 | 
				
			||||||
 | 
					                    var r2 = r1.ToCharArray();
 | 
				
			||||||
 | 
					                    Debug.WriteLine("r2=>" + string.Join(", ", r2));
 | 
				
			||||||
 | 
					                    for (int i = 0; i < 18; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        flags[i] = r2[17 - i] == '1' ? true : false;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    logger.Info($"获取所有箱子门状态返回:{string.Join(',', flags)}");
 | 
				
			||||||
 | 
					                    return flags;
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            return bools;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public bool OpenBoxDoor(int boxNum)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (ConfigurationManager.AppSettings["test"] != null && ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            bool bFlag = false;
 | 
				
			||||||
 | 
					            Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                this.Dispose();
 | 
				
			||||||
 | 
					                //Debug.WriteLine($"打开箱子出错,第{retryCount}次重试", exception);
 | 
				
			||||||
 | 
					                logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
 | 
				
			||||||
 | 
					                this.SetModusIpMaster();
 | 
				
			||||||
 | 
					                //return TimeSpan.FromSeconds (1);
 | 
				
			||||||
 | 
					            })).Execute(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"正在打开{boxNum}号药箱");
 | 
				
			||||||
 | 
					                master.WriteSingleRegister(1, (ushort)boxNum, 14);
 | 
				
			||||||
 | 
					                logger.Info($"开门指令已发送{(ushort)boxNum}");
 | 
				
			||||||
 | 
					                //Console.WriteLine($"开门指令已发送{(ushort)boxNum}");
 | 
				
			||||||
 | 
					                bFlag = true;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            return bFlag;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void Dispose()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            socket.Shutdown(SocketShutdown.Both);
 | 
				
			||||||
 | 
					            socket.Close();
 | 
				
			||||||
 | 
					            client.Close();
 | 
				
			||||||
 | 
					            master.Dispose();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public static Socket MakeKeepALiveSocket()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            uint dummy = 0;
 | 
				
			||||||
 | 
					            byte[] inOptionValues = new byte[Marshal.SizeOf(dummy) * 3];
 | 
				
			||||||
 | 
					            BitConverter.GetBytes((uint)1).CopyTo(inOptionValues, 0);//启用Keep-Alive
 | 
				
			||||||
 | 
					            BitConverter.GetBytes((uint)10000).CopyTo(inOptionValues, Marshal.SizeOf(dummy));//在这个时间间隔内没有数据交互,则发送探测包
 | 
				
			||||||
 | 
					            BitConverter.GetBytes((uint)10000).CopyTo(inOptionValues, Marshal.SizeOf(dummy) * 2);//发探测包时间间隔
 | 
				
			||||||
 | 
					            //IPEndPoint iep = new IPEndPoint(IPAddress.Parse("192.168.1.13"), 502);
 | 
				
			||||||
 | 
					            string modbusIp = ConfigurationManager.AppSettings["modbusIp"].ToString();
 | 
				
			||||||
 | 
					            int modbusPort = Convert.ToInt32(ConfigurationManager.AppSettings["modbusPort"]);
 | 
				
			||||||
 | 
					            IPEndPoint iep = new IPEndPoint(IPAddress.Parse(modbusIp), modbusPort);
 | 
				
			||||||
 | 
					            Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 | 
				
			||||||
 | 
					            _socket = Policy.Handle<Exception>()
 | 
				
			||||||
 | 
					              .Retry(3, (exception, retryCount) =>
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                  Console.WriteLine($"建立Socket,第{retryCount}次重试", exception);
 | 
				
			||||||
 | 
					                  // return TimeSpan.FromSeconds (1);
 | 
				
			||||||
 | 
					              })
 | 
				
			||||||
 | 
					              .Execute<Socket>(() =>
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                  _socket.IOControl(IOControlCode.KeepAliveValues, inOptionValues, null);
 | 
				
			||||||
 | 
					                  _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
 | 
				
			||||||
 | 
					                  _socket.Connect(iep);
 | 
				
			||||||
 | 
					                  return _socket;
 | 
				
			||||||
 | 
					              });
 | 
				
			||||||
 | 
					            return _socket;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -0,0 +1,92 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Modbus.Device;
 | 
				
			||||||
 | 
					using Polly;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.IO.Ports;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class TemperatureHumidityJob
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        public TemperatureHumidityJob()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //try
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    using (SerialPort serialPort = new SerialPort("com1"))
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        serialPort.BaudRate = 9600;
 | 
				
			||||||
 | 
					            //        serialPort.DataBits = 8;
 | 
				
			||||||
 | 
					            //        serialPort.Parity = Parity.None;
 | 
				
			||||||
 | 
					            //        serialPort.StopBits = StopBits.One;
 | 
				
			||||||
 | 
					            //        if (!serialPort.IsOpen)
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            serialPort.Open();
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //        var master = ModbusSerialMaster.CreateRtu(wsdSerial);
 | 
				
			||||||
 | 
					            //        int no = 1;
 | 
				
			||||||
 | 
					            //        switch (Global.CabinetNo)
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            case "1":
 | 
				
			||||||
 | 
					            //                no = 1;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					            //            case "2":
 | 
				
			||||||
 | 
					            //                no = 9;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					            //            case "3":
 | 
				
			||||||
 | 
					            //                no = 5;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					            //            case "4":
 | 
				
			||||||
 | 
					            //                no = 3;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					            //            case "5":
 | 
				
			||||||
 | 
					            //                no = 2;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					            //            case "6":
 | 
				
			||||||
 | 
					            //                no = 6;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					            //            case "7":
 | 
				
			||||||
 | 
					            //                no = 8;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					            //            case "8":
 | 
				
			||||||
 | 
					            //                no = 4;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					            //            case "9":
 | 
				
			||||||
 | 
					            //                no = 7;
 | 
				
			||||||
 | 
					            //                break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //        var r = master.ReadHoldingRegisters((byte)no, 00, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //        if (r != null && r.Length > 0)
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            var result = string.Join("", r);
 | 
				
			||||||
 | 
					            //            var result1 = result.Substring(0, 3);
 | 
				
			||||||
 | 
					            //            var result2 = result.Substring(3, 3);
 | 
				
			||||||
 | 
					            //            float temp = Int32.Parse(result2) / 10.0F;
 | 
				
			||||||
 | 
					            //            float humi = Int32.Parse(result1) / 10.0F;
 | 
				
			||||||
 | 
					            //            TemperatureHumidityInfo temperatureHumidityInfo = new TemperatureHumidityInfo();
 | 
				
			||||||
 | 
					            //            temperatureHumidityInfo.GroupNo = "DM1"
 | 
				
			||||||
 | 
					            //            temperatureHumidityInfo.Temp = temp;
 | 
				
			||||||
 | 
					            //            temperatureHumidityInfo.Humi = humi;
 | 
				
			||||||
 | 
					            //            _temperatureHumidityService.SaveTemperatureAndHumidity(temperatureHumidityInfo);
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //        if (serialPort.IsOpen)
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            serialPort.Close();
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //        master.Dispose();
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //catch (Exception ex)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    logger.LogError(ex.Message);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ using System.Threading.Tasks;
 | 
				
			||||||
using DM_Weight.Models;
 | 
					using DM_Weight.Models;
 | 
				
			||||||
using System.Configuration;
 | 
					using System.Configuration;
 | 
				
			||||||
using DM_Weight.util;
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using System.Diagnostics;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.Report
 | 
					namespace DM_Weight.Report
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -82,7 +83,65 @@ namespace DM_Weight.Report
 | 
				
			||||||
            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
					            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
            Report.PrintPreview(true);
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate, int type, string drug_id)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
 | 
					            GridppReport Report = new GridppReport();
 | 
				
			||||||
 | 
					            // 加载模板文件
 | 
				
			||||||
 | 
					            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "account_book_temp.grf");
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
				
			||||||
 | 
					            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 = $@" SELECT ac.create_date as operationTime, ac.TYPE,
 | 
				
			||||||
 | 
						                     if(ac.type in(1,2),0,ac.yesterday_quantity) as YQuantity,if(ac.type in(3,4),0,ac.add_quantity) as inQuantity,if(ac.type in(3,4),0,ac.out_quantity) as outQuantity,
 | 
				
			||||||
 | 
						                     if(ac.type in(1,2),0,ac.manu_stock) as ManuStock,ac.total_stock AS stockQuantity, -- if(ac.type in(1,2),0,ac.total_stock) as TotalStock,
 | 
				
			||||||
 | 
						                     ac.invoice_no as invoiceId, ac.manu_no as manuNo,ac.eff_date as effDate,di.drug_id,di.drug_name as DrugName,di.drug_spec as DrugSpec,di.manufactory as manufactory,di.pack_unit AS packUnit,di.dosage,u1.user_name as operatorName,u2.user_name as reviewerName
 | 
				
			||||||
 | 
						                     FROM account_book_g2 ac left join drug_info di on ac.drug_id=di.drug_id left join user_list u1 on ac.user_id1=u1.id left join user_list u2 on ac.user_id2=u2.id
 | 
				
			||||||
 | 
					 		                    WHERE ac.machine_id='{p_machine_id}' and create_time>'{p_startDate}' AND create_time<'{p_endDate}' ";
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(drug_id))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SQL += " AND ac.drug_id='" + drug_id + "' ";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (type > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (type == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SQL += " WHERE AddQuantity>0 ";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (type == 2)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SQL += " WHERE OutQuantity>0 ";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (type == 3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SQL += " WHERE type=3 ";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (type == 4)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SQL += " WHERE type=4  ";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            SQL += " ORDER BY di.drug_id,ac.create_date desc";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					            //string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + "account_book_temp.pdf";
 | 
				
			||||||
 | 
					            //if (File.Exists(filePath))
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    try
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //        File.Delete(filePath);
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //    catch (Exception ex)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        FindAndKillProcess();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        public static void PrintReportMechineRecord(int type, DateTime? startDate, DateTime? endDate)
 | 
					        public static void PrintReportMechineRecord(int type, DateTime? startDate, DateTime? endDate)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // 定义Grid++Report报表主对象
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
| 
						 | 
					@ -171,5 +230,140 @@ namespace DM_Weight.Report
 | 
				
			||||||
            Report.ParameterByName("type").AsInteger = 1;
 | 
					            Report.ParameterByName("type").AsInteger = 1;
 | 
				
			||||||
            Report.PrintPreview(true);
 | 
					            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);
 | 
				
			||||||
 | 
					            string filePath = AppDomain.CurrentDomain.BaseDirectory + "ReportTemp//" + "changeShifts_temp.pdf";
 | 
				
			||||||
 | 
					            if (File.Exists(filePath))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    File.Delete(filePath);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    FindAndKillProcess();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            Report.ExportDirect(GRExportType.gretPDF, filePath, false, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public static bool FindAndKillProcess()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            foreach (Process clsProcess in Process.GetProcesses())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (clsProcess.ProcessName.Contains("wps") || clsProcess.ProcessName.Contains("msedge"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    clsProcess.Kill();
 | 
				
			||||||
 | 
					                    //return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //process not found, return false
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 空安瓿回收销毁报表
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="startDate"></param>
 | 
				
			||||||
 | 
					        /// <param name="endDate"></param>
 | 
				
			||||||
 | 
					        public static void PrintEmptyDestoryReport(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.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "ReturnEmptyDistory_template.grf");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            SQL = $@"
 | 
				
			||||||
 | 
					                    SELECT di.drug_id, di.drug_name as drugName,di.dosage,di.drug_spec as drugSpec,di.big_unit,oi.Order_Date, CONCAT(oi.p_name,'/',oi.dept_name) as userDeptName,
 | 
				
			||||||
 | 
					                    od.Quantity,mr.Manu_No,ul.user_name as retuenUser,u2.user_name as returnReviewer,u3.User_name as distoryUser,u4.User_name as distoryRevierer,(od.Quantity-mr.return_quantity2) as needReturnEmptyCount
 | 
				
			||||||
 | 
					                    from order_info oi inner join order_detail od on oi.order_no=od.order_no 
 | 
				
			||||||
 | 
					                    inner join (SELECT id as mrId,manu_no,invoice_id,id,operator,reviewer, sum(return_quantity2) as return_quantity2  FROM dm_machine_record where type=2  and machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}'  GROUP BY invoice_id) mr on oi.order_no=mr.invoice_id 
 | 
				
			||||||
 | 
					                    INNER JOIN drug_info di on od.drug_id=di.drug_id
 | 
				
			||||||
 | 
					                    LEFT JOIN (SELECT manu_no,invoice_id,id,operator,reviewer,get_id  from dm_machine_record where type=32  and machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') re on re.get_id=mr.id 
 | 
				
			||||||
 | 
					                    LEFT JOIN (SELECT recordId,operatorid,reviewerid,machine_id FROM destory_detail WHERE machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') ddl on re.id=ddl.recordId 
 | 
				
			||||||
 | 
					                    -- LEFT JOIN (SELECT User_name,machine_id,id FROM user_list  WHERE machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') ul0 on mr.operator=ul0.id
 | 
				
			||||||
 | 
					                    -- LEFT JOIN (SELECT User_name,machine_id,id FROM user_list  WHERE machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') ul00 on re.reviewer=ul00.id 
 | 
				
			||||||
 | 
					                    LEFT JOIN (SELECT User_name,machine_id,id FROM user_list  WHERE machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') ul on re.operator=ul.id 
 | 
				
			||||||
 | 
					                    LEFT JOIN (SELECT User_name,machine_id,id FROM user_list  WHERE machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') u2 on re.reviewer=u2.id 
 | 
				
			||||||
 | 
					                    LEFT JOIN (SELECT User_name,machine_id,id FROM user_list  WHERE machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') u3 on ddl.operatorid=u3.id 
 | 
				
			||||||
 | 
					                    LEFT JOIN  (SELECT User_name,machine_id,id FROM user_list  WHERE machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') u4 on ddl.reviewerid=u4.id 
 | 
				
			||||||
 | 
					                    WHERE
 | 
				
			||||||
 | 
					                    oi.Pharmacy='{ConfigurationManager.AppSettings["storage"] ?? ""}' and oi.Order_Date>'{startDate}' and oi.Order_Date<'{endDate}' GROUP BY Order_Date";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 发药登记表
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="startDate"></param>
 | 
				
			||||||
 | 
					        /// <param name="endDate"></param>
 | 
				
			||||||
 | 
					        public static void OrderUseReport(DateTime? startDate,DateTime? endDate, string drug_id)
 | 
				
			||||||
 | 
					        { 
 | 
				
			||||||
 | 
					            // 定义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.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "orderUse_template.grf");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            SQL = $@"
 | 
				
			||||||
 | 
					                    SELECT oi.p_name,oi.age,oi.sex,oi.id_number,oi.patientno,oi.disease,od.drug_id,oi.doctor_name,oi.order_no,oi.order_date,
 | 
				
			||||||
 | 
						                    dmr.id,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,U2.`user_name` AS reviewNickname FROM dm_machine_record dmr 
 | 
				
			||||||
 | 
										  
 | 
				
			||||||
 | 
										  INNER JOIN ORDER_INFO oi on dmr.invoice_id=oi.order_no
 | 
				
			||||||
 | 
										  INNER JOIN order_detail od on oi.order_no=od.order_no and oi.order_id=od.order_id
 | 
				
			||||||
 | 
										  
 | 
				
			||||||
 | 
										  LEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`
 | 
				
			||||||
 | 
					                      LEFT JOIN (select id,user_name from user_list where machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') ul ON ul.`id` = dmr.`Operator` 
 | 
				
			||||||
 | 
					                     LEFT JOIN (select id,user_name from user_list where machine_id='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}') U2 ON U2.ID=dmr.reviewer
 | 
				
			||||||
 | 
					                     WHERE  dmr.`type` = 2  and oi.Pharmacy='{ConfigurationManager.AppSettings["storage"] ?? ""}'
 | 
				
			||||||
 | 
					                     AND dmr.`machine_id` ='{ConfigurationManager.AppSettings["machineId"] ?? "DM3"}'   AND oi.`order_date` > '{startDate}'
 | 
				
			||||||
 | 
					                     AND oi.`order_date` < '{endDate}'";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!string.IsNullOrEmpty(drug_id))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SQL += " AND ac.drug_id='" + drug_id + "' ";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
				
			||||||
 | 
					            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,432 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"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":"Order_Date"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"userDeptName",
 | 
				
			||||||
 | 
										"Format":"0"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"Quantity",
 | 
				
			||||||
 | 
										"Type":"Integer"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"Manu_No"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"retuenUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"returnReviewer",
 | 
				
			||||||
 | 
										"Type":"Integer"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"distoryUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"distoryRevierer"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugSpec"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"dosage"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"big_unit"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drug_id"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"needReturnEmptyCount"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"日期",
 | 
				
			||||||
 | 
									"Width":3.175
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"科室/患者",
 | 
				
			||||||
 | 
									"Width":5.3975
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Dept_Name",
 | 
				
			||||||
 | 
									"Width":1.61396
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"批号",
 | 
				
			||||||
 | 
									"Width":2.98979
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"空安瓿回收人",
 | 
				
			||||||
 | 
									"Width":2.98979
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"空安瓿交回人",
 | 
				
			||||||
 | 
									"Width":2.99
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"数量",
 | 
				
			||||||
 | 
									"Width":2
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"空安瓿销毁执行人",
 | 
				
			||||||
 | 
									"Width":2.98979
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"空安瓿销毁审核人",
 | 
				
			||||||
 | 
									"Width":2.99
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":0.79375,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"日期",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"Order_Date"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"科室/患者",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"userDeptName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Dept_Name",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"Quantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"批号",
 | 
				
			||||||
 | 
										"DataField":"Manu_No"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"空安瓿回收人",
 | 
				
			||||||
 | 
										"DataField":"retuenUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"空安瓿交回人",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"returnReviewer"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"distoryUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"空安瓿销毁执行人",
 | 
				
			||||||
 | 
										"DataField":"distoryRevierer"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"空安瓿销毁审核人",
 | 
				
			||||||
 | 
										"DataField":"needReturnEmptyCount"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.7,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnGroupHeaderPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"日期",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"日期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"科室/患者",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"科室/患者"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Dept_Name",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"批号",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"批号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"空安瓿回收人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"空安瓿\r\n回收人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"空安瓿交回人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"空安瓿\r\n交回人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"空安瓿\r\n销毁\r\n执行人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"空安瓿销毁执行人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"空安瓿\r\n销毁\r\n审核人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"空安瓿销毁审核人",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":142500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"待回收\r\n空安瓿\r\n数量"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Group":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Group1",
 | 
				
			||||||
 | 
									"ByFields":"drug_id",
 | 
				
			||||||
 | 
									"GroupHeader":{
 | 
				
			||||||
 | 
										"PrintGridBorder":false,
 | 
				
			||||||
 | 
										"RepeatOnPage":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"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":"drugName"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"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":"dosage"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"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":"FieldBox10",
 | 
				
			||||||
 | 
												"Left":16.5365,
 | 
				
			||||||
 | 
												"Top":0.0529167,
 | 
				
			||||||
 | 
												"Width":2.83104,
 | 
				
			||||||
 | 
												"Height":0.978958,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"DataField":"drugSpec"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"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":"big_unit"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										],
 | 
				
			||||||
 | 
										"NewPageColumn":"Before"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									"GroupFooter":{
 | 
				
			||||||
 | 
										"Height":0.635
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							]
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Parameter":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"machine_id",
 | 
				
			||||||
 | 
								"Value":"DM3"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"ReportHeader":[
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader1",
 | 
				
			||||||
 | 
								"Height":2.40771,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"StaticBox",
 | 
				
			||||||
 | 
										"Name":"StaticBox1",
 | 
				
			||||||
 | 
										"Center":"Horizontal",
 | 
				
			||||||
 | 
										"Left":8.99583,
 | 
				
			||||||
 | 
										"Top":0.608542,
 | 
				
			||||||
 | 
										"Width":9.18104,
 | 
				
			||||||
 | 
										"Height":1.21708,
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":217500,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"回收销毁记录"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	"Version":"6.3.0.1",
 | 
						"Version":"6.8.1.1",
 | 
				
			||||||
	"Font":{
 | 
						"Font":{
 | 
				
			||||||
		"Name":"宋体",
 | 
							"Name":"宋体",
 | 
				
			||||||
		"Size":105000,
 | 
							"Size":105000,
 | 
				
			||||||
| 
						 | 
					@ -75,7 +75,7 @@
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"Name":"单位",
 | 
										"Name":"单位",
 | 
				
			||||||
					"DBFieldName":"packUnit"
 | 
										"DBFieldName":"bigUnit"
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"Name":"剂型",
 | 
										"Name":"剂型",
 | 
				
			||||||
| 
						 | 
					@ -100,10 +100,20 @@
 | 
				
			||||||
					"Type":"Binary"
 | 
										"Type":"Binary"
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"Name":"drugId"
 | 
										"Name":"drugId",
 | 
				
			||||||
 | 
										"DBFieldName":"drug_Id"
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"Name":"Field1"
 | 
										"Name":"凭证号",
 | 
				
			||||||
 | 
										"DBFieldName":"invoiceId"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"供应单位",
 | 
				
			||||||
 | 
										"DBFieldName":"supplierDept"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"领用部门",
 | 
				
			||||||
 | 
										"DBFieldName":"receiveDept"
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			]
 | 
								]
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
| 
						 | 
					@ -113,7 +123,7 @@
 | 
				
			||||||
				"Width":1.77271
 | 
									"Width":1.77271
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				"Name":"操作类型",
 | 
									"Name":"凭证号",
 | 
				
			||||||
				"Width":2.19604
 | 
									"Width":2.19604
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					@ -158,20 +168,14 @@
 | 
				
			||||||
			"ColumnContentCell":[
 | 
								"ColumnContentCell":[
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"Column":"日期",
 | 
										"Column":"日期",
 | 
				
			||||||
 | 
										"WordWrap":true,
 | 
				
			||||||
					"TextAlign":"MiddleCenter",
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"ShrinkFontToFit":true,
 | 
				
			||||||
					"DataField":"日期"
 | 
										"DataField":"日期"
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"Column":"操作类型",
 | 
										"Column":"凭证号",
 | 
				
			||||||
					"FreeCell":true,
 | 
										"DataField":"凭证号"
 | 
				
			||||||
					"Control":[
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
							"Type":"StaticBox",
 | 
					 | 
				
			||||||
							"Name":"StaticBox10",
 | 
					 | 
				
			||||||
							"Dock":"Fill",
 | 
					 | 
				
			||||||
							"TextAlign":"MiddleCenter"
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					]
 | 
					 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"Column":"批号",
 | 
										"Column":"批号",
 | 
				
			||||||
| 
						 | 
					@ -229,11 +233,11 @@
 | 
				
			||||||
					"FreeCell":true,
 | 
										"FreeCell":true,
 | 
				
			||||||
					"Control":[
 | 
										"Control":[
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							"Type":"StaticBox",
 | 
												"Type":"FieldBox",
 | 
				
			||||||
							"Name":"StaticBox6",
 | 
												"Name":"FieldBox14",
 | 
				
			||||||
							"Dock":"Fill",
 | 
												"Dock":"Fill",
 | 
				
			||||||
							"TextAlign":"MiddleCenter",
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
							"Text":"药库"
 | 
												"DataField":"供应单位"
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					]
 | 
										]
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
| 
						 | 
					@ -242,11 +246,11 @@
 | 
				
			||||||
					"FreeCell":true,
 | 
										"FreeCell":true,
 | 
				
			||||||
					"Control":[
 | 
										"Control":[
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							"Type":"StaticBox",
 | 
												"Type":"FieldBox",
 | 
				
			||||||
							"Name":"StaticBox7",
 | 
												"Name":"FieldBox15",
 | 
				
			||||||
							"Dock":"Fill",
 | 
												"Dock":"Fill",
 | 
				
			||||||
							"TextAlign":"MiddleCenter",
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
							"Text":"门诊药房"
 | 
												"DataField":"领用部门"
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
					]
 | 
										]
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -270,7 +274,7 @@
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"GroupTitle":false,
 | 
										"GroupTitle":false,
 | 
				
			||||||
					"Column":"操作类型",
 | 
										"Column":"凭证号",
 | 
				
			||||||
					"Font":{
 | 
										"Font":{
 | 
				
			||||||
						"Name":"宋体",
 | 
											"Name":"宋体",
 | 
				
			||||||
						"Size":105000,
 | 
											"Size":105000,
 | 
				
			||||||
| 
						 | 
					@ -395,6 +399,7 @@
 | 
				
			||||||
				"Name":"Group1",
 | 
									"Name":"Group1",
 | 
				
			||||||
				"ByFields":"drugId",
 | 
									"ByFields":"drugId",
 | 
				
			||||||
				"GroupHeader":{
 | 
									"GroupHeader":{
 | 
				
			||||||
 | 
										"NewPage":"Before",
 | 
				
			||||||
					"PrintGridBorder":false,
 | 
										"PrintGridBorder":false,
 | 
				
			||||||
					"RepeatOnPage":true,
 | 
										"RepeatOnPage":true,
 | 
				
			||||||
					"Control":[
 | 
										"Control":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,345 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"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":"批号",
 | 
				
			||||||
 | 
										"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
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -252,7 +252,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,7 +252,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,7 +252,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,7 +252,7 @@
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,633 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.3.0.1",
 | 
				
			||||||
 | 
						"Font":{
 | 
				
			||||||
 | 
							"Name":"宋体",
 | 
				
			||||||
 | 
							"Size":105000,
 | 
				
			||||||
 | 
							"Weight":400,
 | 
				
			||||||
 | 
							"Charset":134
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"Printer":{
 | 
				
			||||||
 | 
							"Oriention":"Landscape",
 | 
				
			||||||
 | 
							"TopMargin":0.3175,
 | 
				
			||||||
 | 
							"RightMargin":0.8996,
 | 
				
			||||||
 | 
							"BottomMargin":0.3969
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"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":"p_name"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"性别",
 | 
				
			||||||
 | 
										"DBFieldName":"sex"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"年龄",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"age"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"身份证号",
 | 
				
			||||||
 | 
										"DBFieldName":"id_number"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"病历号",
 | 
				
			||||||
 | 
										"DBFieldName":"patientno"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"疾病名称",
 | 
				
			||||||
 | 
										"Format":"yyyy/MM/dd",
 | 
				
			||||||
 | 
										"DBFieldName":"disease"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"药品ID",
 | 
				
			||||||
 | 
										"DBFieldName":"drugId"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"数量",
 | 
				
			||||||
 | 
										"Type":"Integer",
 | 
				
			||||||
 | 
										"DBFieldName":"quantity"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"处方医生",
 | 
				
			||||||
 | 
										"DBFieldName":"doctor_name"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"处方编号",
 | 
				
			||||||
 | 
										"DBFieldName":"order_no"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"处方日期",
 | 
				
			||||||
 | 
										"DBFieldName":"order_date"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"发药人",
 | 
				
			||||||
 | 
										"DBFieldName":"nickname"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"复核人",
 | 
				
			||||||
 | 
										"DBFieldName":"reviewNickname"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"批号",
 | 
				
			||||||
 | 
										"DBFieldName":"manuNo"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"麻醉卡号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"代办人姓名"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"代办人身份证号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"编号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"药品名称",
 | 
				
			||||||
 | 
										"DBFieldName":"drugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"规格",
 | 
				
			||||||
 | 
										"DBFieldName":"drugSpec"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"单位",
 | 
				
			||||||
 | 
										"DBFieldName":"packUnit"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"患者姓名",
 | 
				
			||||||
 | 
									"Width":2.38125
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"性别",
 | 
				
			||||||
 | 
									"Width":1.00542
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"年龄",
 | 
				
			||||||
 | 
									"Width":0.978958
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"身份证号",
 | 
				
			||||||
 | 
									"Width":5.00063
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"病历号",
 | 
				
			||||||
 | 
									"Width":2.77813
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"疾病名称",
 | 
				
			||||||
 | 
									"Width":3.01625
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"药品ID",
 | 
				
			||||||
 | 
									"Width":2.59292
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"数量",
 | 
				
			||||||
 | 
									"Width":1.69333
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"处方医生",
 | 
				
			||||||
 | 
									"Width":2.32833
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"处方编号",
 | 
				
			||||||
 | 
									"Width":2.80458
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"发药人",
 | 
				
			||||||
 | 
									"Width":3.20146
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"复核人",
 | 
				
			||||||
 | 
									"Width":1.69333
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"批号",
 | 
				
			||||||
 | 
									"Width":1.69333
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"麻醉卡号",
 | 
				
			||||||
 | 
									"Width":3.59833
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"代办人姓名",
 | 
				
			||||||
 | 
									"Width":1.69333
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"代办人身份证号",
 | 
				
			||||||
 | 
									"Width":1.69333
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column10",
 | 
				
			||||||
 | 
									"Width":2.14313
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column11",
 | 
				
			||||||
 | 
									"Width":1.69333
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"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":"药品ID",
 | 
				
			||||||
 | 
										"DataField":"药品ID"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"DataField":"数量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"处方医生",
 | 
				
			||||||
 | 
										"DataField":"处方医生"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"处方编号",
 | 
				
			||||||
 | 
										"DataField":"处方编号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"发药人",
 | 
				
			||||||
 | 
										"DataField":"处方日期"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"复核人",
 | 
				
			||||||
 | 
										"DataField":"发药人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"批号",
 | 
				
			||||||
 | 
										"DataField":"复核人"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"麻醉卡号",
 | 
				
			||||||
 | 
										"DataField":"批号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"代办人姓名",
 | 
				
			||||||
 | 
										"DataField":"麻醉卡号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"代办人身份证号",
 | 
				
			||||||
 | 
										"DataField":"代办人姓名"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column10",
 | 
				
			||||||
 | 
										"DataField":"代办人身份证号"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column11"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":1.40229,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnGroupHeaderPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"患者姓名",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"患者\r\n姓名"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"性别",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"性\r\n别"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"年龄",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"年\r\n龄"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"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":"药品ID",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"药品ID"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"数量",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"数\r\n量"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"处方医生",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"处方\r\n医生"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"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":"代办人\r\n姓名"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column10",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"代办人\r\n身份证"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column11",
 | 
				
			||||||
 | 
										"Font":{
 | 
				
			||||||
 | 
											"Name":"宋体",
 | 
				
			||||||
 | 
											"Size":120000,
 | 
				
			||||||
 | 
											"Bold":true,
 | 
				
			||||||
 | 
											"Charset":134
 | 
				
			||||||
 | 
										},
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"编号"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Group":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Group1",
 | 
				
			||||||
 | 
									"ByFields":"药品ID",
 | 
				
			||||||
 | 
									"GroupHeader":{
 | 
				
			||||||
 | 
										"PrintGridBorder":false,
 | 
				
			||||||
 | 
										"RepeatOnPage":true,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"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":"StaticBox15",
 | 
				
			||||||
 | 
												"Left":11.59,
 | 
				
			||||||
 | 
												"Top":0.05,
 | 
				
			||||||
 | 
												"Width":2.01083,
 | 
				
			||||||
 | 
												"Height":0.79375,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"Text":"单位:"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"FieldBox",
 | 
				
			||||||
 | 
												"Name":"FieldBox9",
 | 
				
			||||||
 | 
												"Left":12.78,
 | 
				
			||||||
 | 
												"Top":0.05,
 | 
				
			||||||
 | 
												"Width":1.88,
 | 
				
			||||||
 | 
												"Height":0.98,
 | 
				
			||||||
 | 
												"Font":{
 | 
				
			||||||
 | 
													"Name":"宋体",
 | 
				
			||||||
 | 
													"Size":105000,
 | 
				
			||||||
 | 
													"Bold":true,
 | 
				
			||||||
 | 
													"Charset":134
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"DataField":"单位"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										],
 | 
				
			||||||
 | 
										"NewPageColumn":"Before"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									"GroupFooter":{
 | 
				
			||||||
 | 
										"Height":0.635
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							]
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"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":"DM3"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						],
 | 
				
			||||||
 | 
						"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
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -314,7 +314,7 @@
 | 
				
			||||||
	"Parameter":[
 | 
						"Parameter":[
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"Name":"machine_id",
 | 
								"Name":"machine_id",
 | 
				
			||||||
			"Value":"DM1"
 | 
								"Value":"DM3"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	"ReportHeader":[
 | 
						"ReportHeader":[
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,558 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"Version":"6.8.1.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,
 | 
				
			||||||
 | 
							"IsCrossTab":true,
 | 
				
			||||||
 | 
							"FixCols":2,
 | 
				
			||||||
 | 
							"AppendBlankRow":true,
 | 
				
			||||||
 | 
							"Recordset":{
 | 
				
			||||||
 | 
								"Field":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"DMYear"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"DMMonth"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"DMDay"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"TotalBaseNum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"OperationTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"SendUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"ReceiveUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"SendNum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"InfactNum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"EmptyNum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"ReturnTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"ReturnUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"ReturnReceiveUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"AddUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"AddCheckUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugId"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugName"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Name":"drugSpec"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Column":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column4"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column6"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column31"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column14"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column19"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column20"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column22"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column23"
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Column24"
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"ColumnContent":{
 | 
				
			||||||
 | 
								"Height":2.19604,
 | 
				
			||||||
 | 
								"ColumnContentCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column4",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"OperationTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column6",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"SendUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column31",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"ReceiveUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column14",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"SendNum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column19",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"InfactNum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column20",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"EmptyNum"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column22",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"ReturnTime"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column23",
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"DataField":"ReturnUser"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Column":"Column24",
 | 
				
			||||||
 | 
										"DataField":"ReturnReceiveUser"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"ColumnTitle":{
 | 
				
			||||||
 | 
								"Height":3.96875,
 | 
				
			||||||
 | 
								"RepeatStyle":"OnGroupHeaderPage",
 | 
				
			||||||
 | 
								"ColumnTitleCell":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":true,
 | 
				
			||||||
 | 
										"Name":"Column3",
 | 
				
			||||||
 | 
										"ColumnTitleCell":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"GroupTitle":true,
 | 
				
			||||||
 | 
												"Name":"Column12",
 | 
				
			||||||
 | 
												"ColumnTitleCell":[
 | 
				
			||||||
 | 
													{
 | 
				
			||||||
 | 
														"GroupTitle":true,
 | 
				
			||||||
 | 
														"Name":"Column25",
 | 
				
			||||||
 | 
														"ColumnTitleCell":[
 | 
				
			||||||
 | 
															{
 | 
				
			||||||
 | 
																"GroupTitle":true,
 | 
				
			||||||
 | 
																"Name":"Column26",
 | 
				
			||||||
 | 
																"ColumnTitleCell":[
 | 
				
			||||||
 | 
																	{
 | 
				
			||||||
 | 
																		"GroupTitle":false,
 | 
				
			||||||
 | 
																		"Column":"Column4",
 | 
				
			||||||
 | 
																		"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
																		"Text":"发药时间"
 | 
				
			||||||
 | 
																	},
 | 
				
			||||||
 | 
																	{
 | 
				
			||||||
 | 
																		"GroupTitle":false,
 | 
				
			||||||
 | 
																		"Column":"Column6",
 | 
				
			||||||
 | 
																		"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
																		"Text":"发药者"
 | 
				
			||||||
 | 
																	}
 | 
				
			||||||
 | 
																],
 | 
				
			||||||
 | 
																"TextAlign":"MiddleRight",
 | 
				
			||||||
 | 
																"Text":"交接状态",
 | 
				
			||||||
 | 
																"BorderCustom":true,
 | 
				
			||||||
 | 
																"Border":{
 | 
				
			||||||
 | 
																	"Styles":"[DrawBottom]"
 | 
				
			||||||
 | 
																}
 | 
				
			||||||
 | 
															}
 | 
				
			||||||
 | 
														]
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
												],
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"药品信息",
 | 
				
			||||||
 | 
												"BorderCustom":true,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										],
 | 
				
			||||||
 | 
										"BorderCustom":true,
 | 
				
			||||||
 | 
										"Border":{
 | 
				
			||||||
 | 
											"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":true,
 | 
				
			||||||
 | 
										"Name":"Column27",
 | 
				
			||||||
 | 
										"ColumnTitleCell":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"GroupTitle":true,
 | 
				
			||||||
 | 
												"Name":"Column28",
 | 
				
			||||||
 | 
												"ColumnTitleCell":[
 | 
				
			||||||
 | 
													{
 | 
				
			||||||
 | 
														"GroupTitle":true,
 | 
				
			||||||
 | 
														"Name":"Column29",
 | 
				
			||||||
 | 
														"ColumnTitleCell":[
 | 
				
			||||||
 | 
															{
 | 
				
			||||||
 | 
																"GroupTitle":true,
 | 
				
			||||||
 | 
																"Name":"Column30",
 | 
				
			||||||
 | 
																"ColumnTitleCell":[
 | 
				
			||||||
 | 
																	{
 | 
				
			||||||
 | 
																		"GroupTitle":false,
 | 
				
			||||||
 | 
																		"Column":"Column31",
 | 
				
			||||||
 | 
																		"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
																		"Text":"领药者"
 | 
				
			||||||
 | 
																	}
 | 
				
			||||||
 | 
																]
 | 
				
			||||||
 | 
															}
 | 
				
			||||||
 | 
														],
 | 
				
			||||||
 | 
														"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
														"Text":"总基数"
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
												],
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"规格"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										],
 | 
				
			||||||
 | 
										"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
										"Text":"品名"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":true,
 | 
				
			||||||
 | 
										"Name":"Column32",
 | 
				
			||||||
 | 
										"ColumnTitleCell":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"GroupTitle":true,
 | 
				
			||||||
 | 
												"Name":"Column33",
 | 
				
			||||||
 | 
												"ColumnTitleCell":[
 | 
				
			||||||
 | 
													{
 | 
				
			||||||
 | 
														"GroupTitle":true,
 | 
				
			||||||
 | 
														"Name":"Column34",
 | 
				
			||||||
 | 
														"ColumnTitleCell":[
 | 
				
			||||||
 | 
															{
 | 
				
			||||||
 | 
																"GroupTitle":true,
 | 
				
			||||||
 | 
																"Name":"Column35",
 | 
				
			||||||
 | 
																"ColumnTitleCell":[
 | 
				
			||||||
 | 
																	{
 | 
				
			||||||
 | 
																		"GroupTitle":false,
 | 
				
			||||||
 | 
																		"Column":"Column14",
 | 
				
			||||||
 | 
																		"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
																		"Text":"实发数"
 | 
				
			||||||
 | 
																	},
 | 
				
			||||||
 | 
																	{
 | 
				
			||||||
 | 
																		"GroupTitle":false,
 | 
				
			||||||
 | 
																		"Column":"Column19",
 | 
				
			||||||
 | 
																		"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
																		"Text":"实物数"
 | 
				
			||||||
 | 
																	},
 | 
				
			||||||
 | 
																	{
 | 
				
			||||||
 | 
																		"GroupTitle":false,
 | 
				
			||||||
 | 
																		"Column":"Column20",
 | 
				
			||||||
 | 
																		"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
																		"Text":"空安瓿"
 | 
				
			||||||
 | 
																	}
 | 
				
			||||||
 | 
																],
 | 
				
			||||||
 | 
																"FreeCell":true,
 | 
				
			||||||
 | 
																"Control":[
 | 
				
			||||||
 | 
																	{
 | 
				
			||||||
 | 
																		"Type":"StaticBox",
 | 
				
			||||||
 | 
																		"Name":"StaticBox1",
 | 
				
			||||||
 | 
																		"Width":2.98979,
 | 
				
			||||||
 | 
																		"Height":1.00542,
 | 
				
			||||||
 | 
																		"Border":{
 | 
				
			||||||
 | 
																			"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
																		},
 | 
				
			||||||
 | 
																		"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
																		"Text":"发药"
 | 
				
			||||||
 | 
																	},
 | 
				
			||||||
 | 
																	{
 | 
				
			||||||
 | 
																		"Type":"StaticBox",
 | 
				
			||||||
 | 
																		"Name":"StaticBox2",
 | 
				
			||||||
 | 
																		"Left":2.98979,
 | 
				
			||||||
 | 
																		"Width":6.00604,
 | 
				
			||||||
 | 
																		"Height":1.00542,
 | 
				
			||||||
 | 
																		"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
																		"Text":"还药"
 | 
				
			||||||
 | 
																	}
 | 
				
			||||||
 | 
																]
 | 
				
			||||||
 | 
															}
 | 
				
			||||||
 | 
														],
 | 
				
			||||||
 | 
														"Text":"[#TotalNum#]"
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
												],
 | 
				
			||||||
 | 
												"Text":"[#drugSpec#]"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										],
 | 
				
			||||||
 | 
										"Text":"[drugName]"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column22",
 | 
				
			||||||
 | 
										"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
										"Text":"还药时间"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column23",
 | 
				
			||||||
 | 
										"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
										"Text":"还药者"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"GroupTitle":false,
 | 
				
			||||||
 | 
										"Column":"Column24",
 | 
				
			||||||
 | 
										"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
										"Text":"接收者"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							"Group":[
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									"Name":"Group1",
 | 
				
			||||||
 | 
									"ByFields":"drugId",
 | 
				
			||||||
 | 
									"GroupHeader":{
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									"GroupFooter":{
 | 
				
			||||||
 | 
										"Height":2.40771,
 | 
				
			||||||
 | 
										"Control":[
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox4",
 | 
				
			||||||
 | 
												"AlignColumn":"Column31",
 | 
				
			||||||
 | 
												"AlignColumnEx":"Column4",
 | 
				
			||||||
 | 
												"Width":8.96938,
 | 
				
			||||||
 | 
												"Height":2,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"日消耗总计(支)"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox5",
 | 
				
			||||||
 | 
												"AlignColumn":"Column14",
 | 
				
			||||||
 | 
												"Left":8.96938,
 | 
				
			||||||
 | 
												"Width":2.98979,
 | 
				
			||||||
 | 
												"Height":1,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight|DrawBottom]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
												"Text":"安瓿"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox6",
 | 
				
			||||||
 | 
												"AlignColumn":"Column19",
 | 
				
			||||||
 | 
												"Left":11.9592,
 | 
				
			||||||
 | 
												"Width":2.99,
 | 
				
			||||||
 | 
												"Height":1,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight|DrawBottom]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
												"Text":"处方"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox7",
 | 
				
			||||||
 | 
												"AlignColumn":"Column20",
 | 
				
			||||||
 | 
												"Left":14.949,
 | 
				
			||||||
 | 
												"Width":2.99,
 | 
				
			||||||
 | 
												"Height":1,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight|DrawBottom]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
												"Text":"补充"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox2",
 | 
				
			||||||
 | 
												"AlignColumn":"Column14",
 | 
				
			||||||
 | 
												"Left":8.96938,
 | 
				
			||||||
 | 
												"Top":1.00542,
 | 
				
			||||||
 | 
												"Width":2.9898,
 | 
				
			||||||
 | 
												"Height":1,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#Sum(EmptyNum)#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox3",
 | 
				
			||||||
 | 
												"AlignColumn":"Column19",
 | 
				
			||||||
 | 
												"Left":11.9592,
 | 
				
			||||||
 | 
												"Top":1.0054,
 | 
				
			||||||
 | 
												"Width":2.98979,
 | 
				
			||||||
 | 
												"Height":1,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#Sum(SendNum-InfactNum)#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox4",
 | 
				
			||||||
 | 
												"AlignColumn":"Column20",
 | 
				
			||||||
 | 
												"Left":14.949,
 | 
				
			||||||
 | 
												"Top":1.0054,
 | 
				
			||||||
 | 
												"Width":2.98979,
 | 
				
			||||||
 | 
												"Height":1,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#Sum(SendNum-InfactNum)#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox8",
 | 
				
			||||||
 | 
												"AlignColumn":"Column22",
 | 
				
			||||||
 | 
												"AlignColumnEx":"Column23",
 | 
				
			||||||
 | 
												"Left":17.9388,
 | 
				
			||||||
 | 
												"Width":5.97958,
 | 
				
			||||||
 | 
												"Height":1,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight|DrawBottom]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
												"Text":"补充者"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"StaticBox",
 | 
				
			||||||
 | 
												"Name":"StaticBox9",
 | 
				
			||||||
 | 
												"AlignColumn":"Column24",
 | 
				
			||||||
 | 
												"Left":23.9183,
 | 
				
			||||||
 | 
												"Width":2.98979,
 | 
				
			||||||
 | 
												"Height":1,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight|DrawBottom]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"BottomCenter",
 | 
				
			||||||
 | 
												"Text":"核对者"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox5",
 | 
				
			||||||
 | 
												"AlignColumn":"Column22",
 | 
				
			||||||
 | 
												"AlignColumnEx":"Column23",
 | 
				
			||||||
 | 
												"Left":17.9388,
 | 
				
			||||||
 | 
												"Top":1.0054,
 | 
				
			||||||
 | 
												"Width":5.97958,
 | 
				
			||||||
 | 
												"Height":1.00542,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#AddUser#]"
 | 
				
			||||||
 | 
											},
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"Type":"MemoBox",
 | 
				
			||||||
 | 
												"Name":"MemoBox6",
 | 
				
			||||||
 | 
												"AlignColumn":"Column24",
 | 
				
			||||||
 | 
												"Left":23.9183,
 | 
				
			||||||
 | 
												"Top":1.00542,
 | 
				
			||||||
 | 
												"Width":2.96333,
 | 
				
			||||||
 | 
												"Height":1.00542,
 | 
				
			||||||
 | 
												"Border":{
 | 
				
			||||||
 | 
													"Styles":"[DrawRight]"
 | 
				
			||||||
 | 
												},
 | 
				
			||||||
 | 
												"TextAlign":"MiddleCenter",
 | 
				
			||||||
 | 
												"Text":"[#AddCheckUser#]"
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							],
 | 
				
			||||||
 | 
							"CrossTab":{
 | 
				
			||||||
 | 
								"PercentFormat":"0.##%",
 | 
				
			||||||
 | 
								"HCrossFields":"drugId",
 | 
				
			||||||
 | 
								"VCrossFields":"OperationTime",
 | 
				
			||||||
 | 
								"ListCols":3,
 | 
				
			||||||
 | 
								"TotalCols":3
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						"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":"麻醉科小药箱麻醉、精神药品(注射剂)使用与交接记录([#Year#])年"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"RepeatOnPage":true
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"Name":"ReportHeader2",
 | 
				
			||||||
 | 
								"Height":0.608542,
 | 
				
			||||||
 | 
								"Control":[
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"Type":"StaticBox",
 | 
				
			||||||
 | 
										"Name":"StaticBox3",
 | 
				
			||||||
 | 
										"Left":24.7915,
 | 
				
			||||||
 | 
										"Width":4.81542,
 | 
				
			||||||
 | 
										"Height":0.608542,
 | 
				
			||||||
 | 
										"Text":"[#DMYear#]年[#DMMonth#]月"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,534 +0,0 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Collections.ObjectModel;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Drawing.Printing;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Reflection.PortableExecutable;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows.Documents;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class AddDrugControlViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(DrawerAddDrugWindowViewModel));
 | 
					 | 
				
			||||||
        private List<int> _drawerNoList = new List<int>();
 | 
					 | 
				
			||||||
        public static AddDrugControlViewModel vm;
 | 
					 | 
				
			||||||
        //凭证号
 | 
					 | 
				
			||||||
        //private string _pzh;
 | 
					 | 
				
			||||||
        //public string PZH { get => _pzh; set { SetProperty(ref _pzh, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelList>? _channelLsts;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelList>? ChannelLsts
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelLsts;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelLsts, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        private List<ChannelStock> __channelStocks = new List<ChannelStock>();
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => __channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref __channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private ChannelStock? _channelStock;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ChannelStock? CStock
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStock;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStock, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //private ChannelList? _channelList;
 | 
					 | 
				
			||||||
        //public ChannelList? ChannelLst
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get => _channelList;
 | 
					 | 
				
			||||||
        //    set => SetProperty(ref _channelList, value);
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
    (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
        public AddDrugControlViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
            vm = this;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public DelegateCommand SelectionChangedCommand => new DelegateCommand(selectionAction);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private async void selectionAction()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (CStock != null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 此处延时1毫秒,等待页面渲染
 | 
					 | 
				
			||||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("addManuno", CStock);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "AddManunoDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 委托   被动执行     被子窗口执行
 | 
					 | 
				
			||||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
					 | 
				
			||||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
					 | 
				
			||||||
            //{
 | 
					 | 
				
			||||||
            CStock = null;
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (msg.WindowName == "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,
 | 
					 | 
				
			||||||
                                    Reviewer=HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                    OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                    Quantity = it.AddQuantity,
 | 
					 | 
				
			||||||
                                    Type = 1,
 | 
					 | 
				
			||||||
                                    InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                                    StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                                }).ExecuteCommand();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            return true;
 | 
					 | 
				
			||||||
                        });
 | 
					 | 
				
			||||||
                        ChannelStocks.Clear();
 | 
					 | 
				
			||||||
                        //if (record.Count == repeatList.Count)
 | 
					 | 
				
			||||||
                        if (stockRepeats.Count == record.Count)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Message = $"该抽屉已存在此药品批次{string.Join(',', stockRepeats.Select(r=>r.ManuNo).ToArray())},请选择其他批次",
 | 
					 | 
				
			||||||
                                Type = MsgType.ERROR
 | 
					 | 
				
			||||||
                            };
 | 
					 | 
				
			||||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        else
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            //if (repeatList.Count > 0)
 | 
					 | 
				
			||||||
                            //{
 | 
					 | 
				
			||||||
                            //    AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                            //    {
 | 
					 | 
				
			||||||
                            //        Message = $"该抽屉已存在此药品批次{string.Join(',', repeatList)},请选择其他批次",
 | 
					 | 
				
			||||||
                            //        Type = MsgType.ERROR
 | 
					 | 
				
			||||||
                            //    };
 | 
					 | 
				
			||||||
                            //    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                            //}
 | 
					 | 
				
			||||||
                            if (f.Data)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                string msg = string.Empty;
 | 
					 | 
				
			||||||
                                MsgType type = MsgType.SUCCESS;
 | 
					 | 
				
			||||||
                                //if (repeatList.Count > 0)
 | 
					 | 
				
			||||||
                                if (stockRepeats.Count > 0)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    msg = $"该抽屉下批次{string.Join(',', stockRepeats.Select(r => r.ManuNo).ToArray())}已存在,不可重复添加,其他批次加药完成,库存已更新";
 | 
					 | 
				
			||||||
                                    foreach(var stockRpt in stockRepeats)
 | 
					 | 
				
			||||||
                                    {
 | 
					 | 
				
			||||||
                                        //移除重复的信息,以免更新屏显库存时更新了重复数据
 | 
					 | 
				
			||||||
                                        record.Remove(stockRpt);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                    type = MsgType.WARING;
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                else
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    msg = "抽屉加药完成,库存已更新";
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                // 更新屏显库存
 | 
					 | 
				
			||||||
                                List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
                                if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    singleChannels.ForEach(it =>
 | 
					 | 
				
			||||||
                                    {
 | 
					 | 
				
			||||||
                                        _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
 | 
					 | 
				
			||||||
                                    });
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                RequestData();
 | 
					 | 
				
			||||||
                                AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Message = msg,
 | 
					 | 
				
			||||||
                                    Type = type,
 | 
					 | 
				
			||||||
                                };
 | 
					 | 
				
			||||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Message = "更新库存失败",
 | 
					 | 
				
			||||||
                                    Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                                };
 | 
					 | 
				
			||||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        _isFinishClick = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        //PZH = string.Empty;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        _isFinishClick = false;
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "没有填写加药数量",
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 取消按钮
 | 
					 | 
				
			||||||
        public DelegateCommand CancleTake
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                _portUtil.ResetData();
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //添加批次
 | 
					 | 
				
			||||||
        public void AddAction(ChannelList channelLS)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (channelLS != null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                ChannelStock cls = new ChannelStock();
 | 
					 | 
				
			||||||
                DrugManuNo drugManu = new DrugManuNo();
 | 
					 | 
				
			||||||
                cls.DrugInfo = channelLS.Drug;
 | 
					 | 
				
			||||||
                if (channelLS.channelStocks.Count > 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    //drugManu = channelLS.channelStocks[0].DrugInfo.DrugManuNos[0];
 | 
					 | 
				
			||||||
                    cls.drugManuNo = channelLS.channelStocks[0].drugManuNo;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    //drugManu= cls.DrugInfo.DrugManuNos[0];
 | 
					 | 
				
			||||||
                    if (cls.DrugInfo.DrugManuNos.Count > 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        cls.drugManuNo = cls.DrugInfo.DrugManuNos[0];
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "该药品下没有批次,请先添加批次",
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        return;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                //cls.Id = "";
 | 
					 | 
				
			||||||
                cls.Chnguid = channelLS.Id;
 | 
					 | 
				
			||||||
                cls.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
					 | 
				
			||||||
                cls.DrawerNo = channelLS.DrawerNo;
 | 
					 | 
				
			||||||
                cls.BoardType = channelLS.BoardType;
 | 
					 | 
				
			||||||
                cls.DrawerType = channelLS.DrawerType;
 | 
					 | 
				
			||||||
                cls.ColNo = channelLS.ColNo;
 | 
					 | 
				
			||||||
                cls.DrugId = channelLS.DrugId;
 | 
					 | 
				
			||||||
                cls.AddQuantity = 0;
 | 
					 | 
				
			||||||
                //string sqlStr = @"select drug_id,manu_no,manu_date,eff_date from drug_manu_no where drug_id=@drugId 
 | 
					 | 
				
			||||||
                //    and manu_no not in(select manu_no from channel_stock where drug_id=@drugId) ";
 | 
					 | 
				
			||||||
                //cls.DrugInfo.DrugManuNos=SqlSugarHelper.Db.SqlQueryable<dynamic>(sqlStr).AddParameters(new
 | 
					 | 
				
			||||||
                //{
 | 
					 | 
				
			||||||
                //    drugId = channelLS.DrugId
 | 
					 | 
				
			||||||
                //})
 | 
					 | 
				
			||||||
                //.Select(it => new DrugManuNo()).ToList();
 | 
					 | 
				
			||||||
                List<ChannelStock> stockList = new List<ChannelStock>();
 | 
					 | 
				
			||||||
                stockList.AddRange(channelLS.channelStocks);
 | 
					 | 
				
			||||||
                stockList.Add(cls);
 | 
					 | 
				
			||||||
                channelLS.channelStocks = stockList;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public long CurrentTimeMillis()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void FindDrawerCount()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
					 | 
				
			||||||
            Is8Drawer = count < 9;
 | 
					 | 
				
			||||||
            Is16Drawer = count >= 16;
 | 
					 | 
				
			||||||
            Is17Drawer = count > 16;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            List<ChannelList> queryData = SqlSugarHelper.Db.Queryable<ChannelList>()
 | 
					 | 
				
			||||||
                .Includes(cl => cl.Drug, di => di.DrugManuNos)
 | 
					 | 
				
			||||||
                .Includes(cl => cl.channelStocks, dr => dr.DrugInfo, d => d.DrugManuNos)
 | 
					 | 
				
			||||||
                .Where(cl => cl.DrawerNo == DrawerNo)
 | 
					 | 
				
			||||||
                .Where(cl => cl.DrawerType == 1)
 | 
					 | 
				
			||||||
                .Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                .Where(cl => cl.DrugId != null)
 | 
					 | 
				
			||||||
                .OrderBy(cl => cl.ColNo)
 | 
					 | 
				
			||||||
                .ToList();
 | 
					 | 
				
			||||||
            ChannelLsts = queryData.Select(cl =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                cl.channelStocks = cl.channelStocks.Select(cs =>
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    cs.drugManuNo = cl.Drug.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
 | 
					 | 
				
			||||||
                    return cs;
 | 
					 | 
				
			||||||
                }).ToList();
 | 
					 | 
				
			||||||
                return cl;
 | 
					 | 
				
			||||||
            }).ToList();
 | 
					 | 
				
			||||||
            //ChannelLsts = new ObservableCollection<ChannelList>(queryData);
 | 
					 | 
				
			||||||
            ChannelLsts.ForEach(cl => cl.channelStocks.ForEach(cs => cs.DrugInfo = cl.Drug));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
					 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<AddDrugEvent>().Subscribe(AddAction);
 | 
					 | 
				
			||||||
            FindDrawerCount();
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
					 | 
				
			||||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求
 | 
					 | 
				
			||||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<AddDrugEvent>().Unsubscribe(AddAction);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,221 @@
 | 
				
			||||||
 | 
					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.ComponentModel;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class AdditionWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(AdditionWindowViewModel));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock> channelStocks;
 | 
				
			||||||
 | 
					        public List<ChannelStock> ChannelStocks
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => channelStocks;
 | 
				
			||||||
 | 
					            set => SetProperty(ref channelStocks, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        List<ChannelStock> selectedStock = new List<ChannelStock>();
 | 
				
			||||||
 | 
					        private object _finishStatus = Visibility.Collapsed;
 | 
				
			||||||
 | 
					        public object FinishStatus
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _finishStatus;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _finishStatus, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public AdditionWindowViewModel(IDialogService dialogService, IEventAggregator eventAggregator, PortUtil portUtil)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = dialogService;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<IsSelectedEvent>().Unsubscribe(SetIsSelected);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<IsSelectedEvent>().Subscribe(SetIsSelected);
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                .Includes<ChannelList>(cs => cs.ChannelLst)
 | 
				
			||||||
 | 
					                .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
				
			||||||
 | 
					                .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity)
 | 
				
			||||||
 | 
					                .OrderBy(cs => cs.Chnguid)
 | 
				
			||||||
 | 
					                .OrderBy(cs => cs.DrawerNo)
 | 
				
			||||||
 | 
					                .ToList();
 | 
				
			||||||
 | 
					            ChannelStocks= ChannelStocks.GroupBy(it=>new {it.DrawerNo,it.DrugId})
 | 
				
			||||||
 | 
					                .Select(it=>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var ret = it.First();
 | 
				
			||||||
 | 
					                    ret.Quantity = it.Sum(itx => itx.Quantity);
 | 
				
			||||||
 | 
					                    return ret;
 | 
				
			||||||
 | 
					                }).ToList();
 | 
				
			||||||
 | 
					            ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //开药箱放入药品
 | 
				
			||||||
 | 
					        public DelegateCommand OpenBoxCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                selectedStock = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
 | 
				
			||||||
 | 
					                if (selectedStock != null && selectedStock.Count > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    int drawerNo = 0;
 | 
				
			||||||
 | 
					                    for (int i = 0; i < selectedStock.Count; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (!(drawerNo == selectedStock[i].DrawerNo))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            drawerNo = selectedStock[i].DrawerNo;
 | 
				
			||||||
 | 
					                            _portUtil.SpeakAsync($"正在打开{selectedStock[i].DrawerNo}号药箱");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        ModbusHelper.GetInstance().OpenBoxDoor(selectedStock[i].DrawerNo - 1);
 | 
				
			||||||
 | 
					                        Thread.Sleep(100);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = $"未选择药箱,请先选择药箱",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                FinishStatus = Visibility.Visible;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //完成按钮
 | 
				
			||||||
 | 
					        public DelegateCommand AddFinish
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //更新 交接柜 库存信息
 | 
				
			||||||
 | 
					                    if (selectedStock != null && selectedStock.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        for (int j = 0; j < selectedStock.Count; j++)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            // 更新数据 交接柜 库存信息
 | 
				
			||||||
 | 
					                            ChannelStock jiaojie_it = selectedStock[j];
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                Quantity = jiaojie_it.BaseQuantity,
 | 
				
			||||||
 | 
					                                //ManuNo = it.ManuNo,
 | 
				
			||||||
 | 
					                                //EffDate = it.EffDate,
 | 
				
			||||||
 | 
					                                //Id = jiaojie_it.Id,
 | 
				
			||||||
 | 
					                                DrugId=jiaojie_it.DrugId,
 | 
				
			||||||
 | 
					                                DrawerNo=jiaojie_it.DrawerNo,
 | 
				
			||||||
 | 
					                                MachineId=jiaojie_it.MachineId,
 | 
				
			||||||
 | 
					                            }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).WhereColumns(jiaojie_it=>new { jiaojie_it.DrugId, jiaojie_it.DrawerNo, jiaojie_it.MachineId }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        List<ChannelStock> jiaojie = selectedStock.GroupBy(cs => cs.DrawerNo).Select(cs => cs.FirstOrDefault()).ToList();
 | 
				
			||||||
 | 
					                        if (jiaojie != null && jiaojie.Count > 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            for (int j = 0; j < jiaojie.Count; j++)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                ChannelStock jiaojie_it = jiaojie[j];
 | 
				
			||||||
 | 
					                                ChannelList jiaojieList = new ChannelList();
 | 
				
			||||||
 | 
					                                jiaojieList.State = 0;
 | 
				
			||||||
 | 
					                                jiaojieList.Id = jiaojie_it.ChannelLst.Id;
 | 
				
			||||||
 | 
					                                //更新交接柜状态为 已取药未入库
 | 
				
			||||||
 | 
					                                var result = SqlSugarHelper.Db.Updateable(jiaojieList)
 | 
				
			||||||
 | 
					                                .UpdateColumns(it => new { it.State, it.Id }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                if (f.Data)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    RequestData();
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "操作完成",
 | 
				
			||||||
 | 
					                        Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (!f.IsSuccess)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "操作失败!",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //刷新
 | 
				
			||||||
 | 
					        public DelegateCommand QueryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => RequestData());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //设置选中药箱的复选框状态
 | 
				
			||||||
 | 
					        private void SetIsSelected(ChannelStock channelStock)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (channelStock != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (channelStock.ChannelLst.State == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (channelStock != null && ChannelStocks != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ChannelStocks = ChannelStocks.Select(x =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        for (int i = 0; i < ChannelStocks.Count; i++)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (ChannelStocks[i].DrawerNo == channelStock.DrawerNo)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                ChannelStocks[i].ChannelLst = channelStock.ChannelLst;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return x;
 | 
				
			||||||
 | 
					                    }).ToList();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks);
 | 
				
			||||||
 | 
					                vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst"));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,76 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using Prism.Services.Dialogs;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class BindBoxDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string Title =>"药箱药品绑定";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _drawerNo = 0;
 | 
				
			||||||
 | 
					        public int DrawerNo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drawerNo;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _drawerNo, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private List<DrugInfo>? _drugInfos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<DrugInfo>? DrugInfos
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drugInfos;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _drugInfos, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static BindBoxDialogViewModel vm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public event Action<IDialogResult> RequestClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool CanCloseDialog()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogClosed()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnDialogOpened(IDialogParameters parameters)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (parameters.ContainsKey("DrawerNo"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DrawerNo = parameters.GetValue<int>("DrawerNo");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void UpdateComboBoxItems(string text)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
				
			||||||
 | 
					                        d.manufactory,d.max_stock,CONCAT(drug_name,'  ',drug_spec)as drug_name_spec FROM `drug_info` d";
 | 
				
			||||||
 | 
					            if (string.IsNullOrEmpty(text))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (DrugInfos != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DrugInfos.Clear();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,493 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using MaterialDesignThemes.Wpf;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using Prism.Services.Dialogs;
 | 
				
			||||||
 | 
					using SqlSugar;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Media;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class BindBoxPackageWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static BindBoxPackageWindowViewModel vm;
 | 
				
			||||||
 | 
					        private int _drawerNo = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int DrawerNo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drawerNo;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _drawerNo, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private SolidColorBrush _colorBrush;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public SolidColorBrush SnackbarBackground
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _colorBrush;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _colorBrush, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _snackbarMessageQueue;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<ChannelStock>? _channels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<ChannelStock>? Channels
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _channels;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _channels, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private ChannelStock _channelStock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ChannelStock Channel
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _channelStock; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (value != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    DrugInfo = DrugInfos.Where(di => di.DrugId == value.DrugInfo.DrugId).First();
 | 
				
			||||||
 | 
					                    BaseQuantity = value.BaseQuantity.ToString();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                SetProperty(ref _channelStock, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<DrugInfo>? _drugInfos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<DrugInfo>? DrugInfos
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drugInfos;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _drugInfos, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private DrugInfo? _drugInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DrugInfo? DrugInfo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drugInfo;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _drugInfo, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //药品基数
 | 
				
			||||||
 | 
					        private string _baseQuantity;
 | 
				
			||||||
 | 
					        public string BaseQuantity { get => _baseQuantity; set { SetProperty(ref _baseQuantity, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _isEnable = true;
 | 
				
			||||||
 | 
					        public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); }
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					        public int Status { get => _status; set { SetProperty(ref _status, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					        //抽屉号列表
 | 
				
			||||||
 | 
					        public static List<int> iList = new List<int>();
 | 
				
			||||||
 | 
					        //第几个抽屉号下标
 | 
				
			||||||
 | 
					        //public static int iNumber = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public BindBoxPackageWindowViewModel(IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            vm = this;
 | 
				
			||||||
 | 
					            //_portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Channels?.Clear();
 | 
				
			||||||
 | 
					            BaseQuantity = "";
 | 
				
			||||||
 | 
					            var list = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                //.Includes(cl => cl.channelStocks, cs => cs.DrugInfo,di=>di.drugBase)
 | 
				
			||||||
 | 
					                .Includes(cs => cs.DrugInfo)
 | 
				
			||||||
 | 
					                .Where(cs => cs.MachineId.Equals("DM5"))
 | 
				
			||||||
 | 
					                .Where(cs => cs.DrawerNo == DrawerNo).ToList();
 | 
				
			||||||
 | 
					            if (list != null && list.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Channels = list;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Channels = null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            RequestDrug();
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            //_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DelegateCommand<string> UpdateDrawerNo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<string>((DrawerNo) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void RequestDrug()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
				
			||||||
 | 
					            //DrugInfos = list;
 | 
				
			||||||
 | 
					            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,' / ',manufactory) as drug_name_spec FROM `drug_info` d";
 | 
				
			||||||
 | 
					            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand BindingDrug
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(BindDrugAction);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //绑定
 | 
				
			||||||
 | 
					        private void BindDrugAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (DrugInfo == null || BaseQuantity == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                SnackbarMessageQueue.Enqueue("请选择药品并输入药品基数");
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int baseQuantity;
 | 
				
			||||||
 | 
					            if (!int.TryParse(BaseQuantity, out baseQuantity))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                SnackbarMessageQueue.Enqueue("药品基数请输入正确的整数");
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (Channels != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int iNum = Channels.Where(cs => cs.DrugId == DrugInfo.DrugId.ToString()).Count();
 | 
				
			||||||
 | 
					                if (iNum > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("该药品已在药箱绑定,请选择其他药品");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                string chnguid = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.MachineId == ConfigurationManager.AppSettings["machineId"].ToString() && cs.DrawerNo == DrawerNo).Select(cs => cs.Id).First();
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Insertable(new ChannelStock()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Chnguid = chnguid,
 | 
				
			||||||
 | 
					                    DrawerNo = DrawerNo,
 | 
				
			||||||
 | 
					                    DrugId = DrugInfo.DrugId.ToString(),
 | 
				
			||||||
 | 
					                    BaseQuantity = baseQuantity,
 | 
				
			||||||
 | 
					                    Id = Guid.NewGuid().ToString(),
 | 
				
			||||||
 | 
					                    MachineId = "DM5"
 | 
				
			||||||
 | 
					                }).ExecuteCommand();
 | 
				
			||||||
 | 
					                // 保存数据 入库记录
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    MachineId = "DM5",
 | 
				
			||||||
 | 
					                    DrawerNo = DrawerNo,
 | 
				
			||||||
 | 
					                    DrugId = DrugInfo.DrugId.ToString(),
 | 
				
			||||||
 | 
					                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                    OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                    Quantity = baseQuantity,
 | 
				
			||||||
 | 
					                    Type = 55,
 | 
				
			||||||
 | 
					                    InvoiceId = "绑定药箱",
 | 
				
			||||||
 | 
					                }).ExecuteCommand();
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            if (f.Data)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
				
			||||||
 | 
					                SnackbarMessageQueue.Enqueue("药品已绑定药箱");
 | 
				
			||||||
 | 
					                RequestDrug();
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void UpdateComboBoxItems(string text)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
				
			||||||
 | 
					                        d.manufactory,d.max_stock,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) as drug_name_spec FROM `drug_info` d";
 | 
				
			||||||
 | 
					            if (string.IsNullOrEmpty(text))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (DrugInfos != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DrugInfos.Clear();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //解绑
 | 
				
			||||||
 | 
					        public DelegateCommand RemoveBinding
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => RemoveBindingAction());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void RemoveBindingAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (Channels == null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("所选药箱中无可解绑药品");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (Channel != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //解绑选定行的单个药品
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Deleteable(Channel).ExecuteCommand();
 | 
				
			||||||
 | 
					                    // 保存数据 入库记录
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        DrawerNo = DrawerNo,
 | 
				
			||||||
 | 
					                        DrugId = Channel.DrugId.ToString(),
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Quantity = Channel.Quantity,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = "解绑药箱单个药品",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //解绑药箱下的所有药品
 | 
				
			||||||
 | 
					                    Channels.ForEach(item =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Deleteable(item).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        // 保存数据 入库记录
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            MachineId = "DM5",
 | 
				
			||||||
 | 
					                            DrawerNo = DrawerNo,
 | 
				
			||||||
 | 
					                            DrugId = item.DrugId.ToString(),
 | 
				
			||||||
 | 
					                            Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                            OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                            Quantity = item.Quantity,
 | 
				
			||||||
 | 
					                            Type = 55,
 | 
				
			||||||
 | 
					                            InvoiceId = "绑定药箱全部药品",
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                RequestDrug();
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                SnackbarMessageQueue.Enqueue("解绑操作异常");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //保存修改的药品基数
 | 
				
			||||||
 | 
					        public DelegateCommand SaveCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (DrugInfo.DrugId != Channel.DrugId)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("只能修改药品基数,不能更换绑定药品!");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                int baseQty = 0;
 | 
				
			||||||
 | 
					                if (int.TryParse(BaseQuantity, out baseQty))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Channel.BaseQuantity = Convert.ToInt32(baseQty);
 | 
				
			||||||
 | 
					                    int iUpdate= SqlSugarHelper.Db.Updateable<ChannelStock>(Channel).ExecuteCommand();
 | 
				
			||||||
 | 
					                    if (iUpdate > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
				
			||||||
 | 
					                        SnackbarMessageQueue.Enqueue("保存修改完成!");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
				
			||||||
 | 
					                        SnackbarMessageQueue.Enqueue("保存修改失败!");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue("药品基数只能是正整数,请检查输入!");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //刷新
 | 
				
			||||||
 | 
					        public DelegateCommand Query
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(RequestData);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //打开全部药箱
 | 
				
			||||||
 | 
					        public DelegateCommand OpenBox
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => OpenBoxAction());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void OpenBoxAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5")
 | 
				
			||||||
 | 
					                .Select(cl => cl.DrawerNo).ToList();
 | 
				
			||||||
 | 
					            if (iList.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                for (int i = 0; i < iList.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //记录开药箱日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        DrawerNo = DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = $"打开{DrawerNo}号药箱",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    IsEnable = false;
 | 
				
			||||||
 | 
					                    Status = 1;
 | 
				
			||||||
 | 
					                    Console.WriteLine($"正在打开{iList[i]}号药箱");
 | 
				
			||||||
 | 
					                    ModbusHelper.GetInstance().OpenBoxDoor(iList[i] - 1);
 | 
				
			||||||
 | 
					                    //iNumber++;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					                if (Status == 2)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Status = 3;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                IsEnable = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            switch (msg.EventType)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 药箱打开
 | 
				
			||||||
 | 
					                case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					                    //记录开药箱日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        //DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = "药箱打开",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //if (iNumber < iList.Count)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    //_portUtil.DrawerNo = iList[iNumber];
 | 
				
			||||||
 | 
					                    //    iNumber++;
 | 
				
			||||||
 | 
					                    //    if (Status == 1)
 | 
				
			||||||
 | 
					                    //    {
 | 
				
			||||||
 | 
					                    //        Status = 2;
 | 
				
			||||||
 | 
					                    //    }
 | 
				
			||||||
 | 
					                    //    //_portUtil.OpenBox();
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                    //else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //iNumber = 0;
 | 
				
			||||||
 | 
					                        //_portUtil.GetBoxStatus();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                // 药箱关闭
 | 
				
			||||||
 | 
					                case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					                    //记录药箱操作日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        //DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = "药箱关闭",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (Status == 2)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Status = 3;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    IsEnable = true;
 | 
				
			||||||
 | 
					                    DrawerNo = -1;
 | 
				
			||||||
 | 
					                    //_portUtil.Operate = false;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                // 打开失败
 | 
				
			||||||
 | 
					                case EventType.OPENERROR:
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = msg.Message,
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    IsEnable = true;
 | 
				
			||||||
 | 
					                    DrawerNo = -1;
 | 
				
			||||||
 | 
					                    Status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //记录药箱操作日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        //DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = "药箱打开失败",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    //_portUtil.Operate = false;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,407 +0,0 @@
 | 
				
			||||||
using MaterialDesignThemes.Wpf;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows.Media;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class BindingChannelDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        public static BindingChannelDialogViewModel vm;
 | 
					 | 
				
			||||||
        public string Title => "库位绑定";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _drawerNo = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private SolidColorBrush _colorBrush;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public SolidColorBrush SnackbarBackground
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _colorBrush;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _colorBrush, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _snackbarMessageQueue;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
        PortUtil _portUtil;
 | 
					 | 
				
			||||||
        //ScreenUtil _screenUtil;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public BindingChannelDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
 | 
					 | 
				
			||||||
            )
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            //_screenUtil = screenUtil;
 | 
					 | 
				
			||||||
            vm = this;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int DrawerNo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drawerNo;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _drawerNo, value);
 | 
					 | 
				
			||||||
                GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private DrugInfo? _drugInfo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DrugInfo? DrugInfo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drugInfo;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _drugInfo, value);
 | 
					 | 
				
			||||||
                if (_drugInfo != null)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    //DrugManuNos = _drugInfo.DrugManuNos;
 | 
					 | 
				
			||||||
                    DrugManuNos = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(m => m.DrugId == _drugInfo.DrugId.ToString()).ToList();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<DrugInfo>? _drugInfos;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<DrugInfo>? DrugInfos
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drugInfos;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _drugInfos, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private DrugManuNo? _drugManuNo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DrugManuNo? DrugManuNo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drugManuNo;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _drugManuNo, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        private List<DrugManuNo>? _drugManuNos;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<DrugManuNo>? DrugManuNos
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drugManuNos;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _drugManuNos, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock>? _channels;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock>? Channels
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channels;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channels, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _totalCount = 0;
 | 
					 | 
				
			||||||
        public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageNum = 1;
 | 
					 | 
				
			||||||
        public int PageNum
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageNum;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageNum, value);
 | 
					 | 
				
			||||||
                GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageCount = 1;
 | 
					 | 
				
			||||||
        public int PageCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageSize = 9;
 | 
					 | 
				
			||||||
        public int PageSize
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageSize;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageSize, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void GetAllDrugInfos()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
					 | 
				
			||||||
            DrugInfos = list;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void GetChannelsByDrawerNo()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Channels?.Clear();
 | 
					 | 
				
			||||||
            int totalCount = 0;
 | 
					 | 
				
			||||||
            var list = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					 | 
				
			||||||
                .WhereIF(DrawerNo > 0, cs => cs.DrawerNo == DrawerNo)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                .OrderBy(cs => cs.DrawerNo)
 | 
					 | 
				
			||||||
                .OrderBy(cs => cs.ColNo)
 | 
					 | 
				
			||||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
					 | 
				
			||||||
            Channels = list;
 | 
					 | 
				
			||||||
            TotalCount = totalCount;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (parameters.ContainsKey("DrawerNo"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                DrawerNo = parameters.GetValue<int>("DrawerNo");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            GetAllDrugInfos();
 | 
					 | 
				
			||||||
            GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public DelegateCommand Query
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BindingDrug
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                var SelectChannels = Channels.FindAll(item => item.IsSelected && item.Quantity == 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (SelectChannels.All(it => it.DrawerType != 1))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    if (SelectChannels.Count == 1)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        if (DrugInfo != null)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
 | 
					 | 
				
			||||||
                            if (count == 0)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                var item = SelectChannels[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    item.PosNo = 0;
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                item.DrugId = DrugInfo.DrugId.ToString();
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                if (item.BoardType == 5)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    _portUtil.WindowName = "BindingChannelDialog";
 | 
					 | 
				
			||||||
                                    // 向显示屏写入库位信息
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                //_screenUtil.SetStockInfo(item, 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                                SnackbarMessageQueue.Enqueue($"药品【{DrugInfo.DrugName}】已经绑定了回收库位不可再次绑定");
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        else
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                            SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品信息");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                        SnackbarMessageQueue.Enqueue("每种药品只能绑定一个回收库位");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    if (DrugInfo != null && DrugManuNo != null)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        var c = SelectChannels.Count;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (c > 0)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            SelectChannels.ForEach(async (item) =>
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    item.PosNo = 0;
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                item.DrugId = DrugInfo.DrugId.ToString();
 | 
					 | 
				
			||||||
                                item.ManuNo = DrugManuNo.ManuNo;
 | 
					 | 
				
			||||||
                                item.DrugInfo = DrugInfo;
 | 
					 | 
				
			||||||
                                item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                if (item.BoardType == 5)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    _portUtil.WindowName = "BindingChannelDialog";
 | 
					 | 
				
			||||||
                                    // 向显示屏写入库位信息
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate), item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                //_screenUtil.SetStockInfo(item, 1);
 | 
					 | 
				
			||||||
                            });
 | 
					 | 
				
			||||||
                            GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        else
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                            SnackbarMessageQueue.Enqueue("所选库位中无可绑定库位【库位还存在药品】");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                        SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品及批次信息");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand RemoveBinding
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                var SelectChannels = Channels.FindAll(item => item.IsSelected && item.Quantity == 0);
 | 
					 | 
				
			||||||
                var c = SelectChannels.Count;
 | 
					 | 
				
			||||||
                if (c > 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SelectChannels.ForEach(async item =>
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        item.DrugId = null;
 | 
					 | 
				
			||||||
                        item.ManuNo = null;
 | 
					 | 
				
			||||||
                        item.EffDate = null;
 | 
					 | 
				
			||||||
                        item.DrugInfo = null;
 | 
					 | 
				
			||||||
                        SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
					 | 
				
			||||||
                        if (item.BoardType == 5)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            // 清除显示屏库位信息
 | 
					 | 
				
			||||||
                            _portUtil.ClearContent(item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                            await Task.Delay(200);
 | 
					 | 
				
			||||||
                            _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        //_screenUtil.SetStockInfo(item, 1);
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                    GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                    SnackbarMessageQueue.Enqueue("所选库位中无可解绑库位【库位还存在药品】");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BtnCloseCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                //DialogParameters parameters = new DialogParameters();
 | 
					 | 
				
			||||||
                //parameters.Add("",);
 | 
					 | 
				
			||||||
                // 关闭当前窗口
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
        string message = string.Empty;
 | 
					 | 
				
			||||||
        private void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (msg.WindowName == "BindingChannelDialog")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        if (message != msg.Message)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            message = msg.Message;
 | 
					 | 
				
			||||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void UpdateComboBoxItems(string text)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
					 | 
				
			||||||
                        d.manufactory,d.max_stock,CONCAT(drug_name,'  ',drug_spec)as drug_name_spec FROM `drug_info` d";
 | 
					 | 
				
			||||||
            if(string.IsNullOrEmpty(text))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
					 | 
				
			||||||
                return;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if(DrugInfos!=null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                DrugInfos.Clear();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,484 +0,0 @@
 | 
				
			||||||
using MaterialDesignThemes.Wpf;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows.Media;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using System.Threading;
 | 
					 | 
				
			||||||
using System.Reflection.Metadata.Ecma335;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class BindingChannelNewDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        public static BindingChannelNewDialogViewModel vm;
 | 
					 | 
				
			||||||
        public string Title => "库位绑定";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _drawerNo = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private SolidColorBrush _colorBrush;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public SolidColorBrush SnackbarBackground
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _colorBrush;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _colorBrush, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ISnackbarMessageQueue SnackbarMessageQueue
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _snackbarMessageQueue;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _snackbarMessageQueue, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
        PortUtil _portUtil;
 | 
					 | 
				
			||||||
        //ScreenUtil _screenUtil;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public BindingChannelNewDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
 | 
					 | 
				
			||||||
            )
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            //_screenUtil = screenUtil;
 | 
					 | 
				
			||||||
            vm = this;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int DrawerNo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drawerNo;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _drawerNo, value);
 | 
					 | 
				
			||||||
                GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private DrugInfo? _drugInfo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DrugInfo? DrugInfo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drugInfo;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _drugInfo, value);
 | 
					 | 
				
			||||||
                //if (_drugInfo != null)
 | 
					 | 
				
			||||||
                //{
 | 
					 | 
				
			||||||
                //    DrugManuNos = _drugInfo.DrugManuNos.OrderByDescending(dm => dm.ManuNo).ToList();
 | 
					 | 
				
			||||||
                //}
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        //拼音码对应药品实体
 | 
					 | 
				
			||||||
        //private DrugInfo? _durgInfo_for_py;
 | 
					 | 
				
			||||||
        //public DrugInfo? DrugInfo_Py
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get => _durgInfo_for_py;
 | 
					 | 
				
			||||||
        //    set
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //        SetProperty(ref _durgInfo_for_py, value);
 | 
					 | 
				
			||||||
        //        if (_durgInfo_for_py != null)
 | 
					 | 
				
			||||||
        //        {
 | 
					 | 
				
			||||||
        //            DrugInfos = GetDrugByDrugPY(_durgInfo_for_py.PyCode);
 | 
					 | 
				
			||||||
        //        }
 | 
					 | 
				
			||||||
        //        else
 | 
					 | 
				
			||||||
        //        {
 | 
					 | 
				
			||||||
        //            DrugInfos = GetDrugByDrugPY("");
 | 
					 | 
				
			||||||
        //        }
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //#region 根据药品拼音码查询药品名称
 | 
					 | 
				
			||||||
        //private List<DrugInfo> GetDrugByDrugPY(string pycode)
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    List<DrugInfo> DrugList = null;
 | 
					 | 
				
			||||||
        //    if (!string.IsNullOrEmpty(pycode))
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //        DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //    else
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //        DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //    return DrugList;
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
        //private List<DrugInfo>? _drugInfos_py;
 | 
					 | 
				
			||||||
        //public List<DrugInfo>? DrugInfos_PY
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get => _drugInfos_py;
 | 
					 | 
				
			||||||
        //    set => SetProperty(ref _drugInfos_py, value);
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
        //#endregion 根据药品拼音码查询药品名称
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<DrugInfo>? _drugInfos;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<DrugInfo>? DrugInfos
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drugInfos;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _drugInfos, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //private DrugManuNo? _drugManuNo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //public DrugManuNo? DrugManuNo
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get => _drugManuNo;
 | 
					 | 
				
			||||||
        //    set => SetProperty(ref _drugManuNo, value);
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
        //private List<DrugManuNo>? _drugManuNos;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //public List<DrugManuNo>? DrugManuNos
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get => _drugManuNos;
 | 
					 | 
				
			||||||
        //    set => SetProperty(ref _drugManuNos, value);
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelList>? _channels;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelList>? Channels
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channels;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channels, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _totalCount = 0;
 | 
					 | 
				
			||||||
        public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageNum = 1;
 | 
					 | 
				
			||||||
        public int PageNum
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageNum;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageNum, value);
 | 
					 | 
				
			||||||
                GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageCount = 1;
 | 
					 | 
				
			||||||
        public int PageCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageSize = 8;
 | 
					 | 
				
			||||||
        public int PageSize
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageSize;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageSize, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void GetAllDrugInfos()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
 | 
					 | 
				
			||||||
            DrugInfos = list;
 | 
					 | 
				
			||||||
            //DrugInfos_PY = list;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void GetChannelsByDrawerNo()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Channels?.Clear();
 | 
					 | 
				
			||||||
            int totalCount = 0;
 | 
					 | 
				
			||||||
            var list = SqlSugarHelper.Db.Queryable<ChannelList>()
 | 
					 | 
				
			||||||
                .Includes<DrugInfo>(cl => cl.Drug)
 | 
					 | 
				
			||||||
                //.Includes<ChannelStock>(cs => cs.channelStock)
 | 
					 | 
				
			||||||
                .WhereIF(DrawerNo > 0, cl => cl.DrawerNo == DrawerNo)
 | 
					 | 
				
			||||||
                .Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                .OrderBy(cl => cl.DrawerNo)
 | 
					 | 
				
			||||||
                .OrderBy(cl => cl.ColNo)
 | 
					 | 
				
			||||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
					 | 
				
			||||||
            Channels = list;
 | 
					 | 
				
			||||||
            TotalCount = totalCount;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (parameters.ContainsKey("DrawerNo"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                DrawerNo = parameters.GetValue<int>("DrawerNo");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            GetAllDrugInfos();
 | 
					 | 
				
			||||||
            GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public DelegateCommand Query
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BindingDrug
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                var SelectChannels = Channels.FindAll(item => item.IsSelected);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (SelectChannels.All(it => it.DrawerType != 1))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    if (SelectChannels.Count == 1)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        if (DrugInfo != null)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
 | 
					 | 
				
			||||||
                            if (count == 0)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                var item = SelectChannels[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    item.PosNo = 0;
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                item.DrugId = DrugInfo.DrugId.ToString();
 | 
					 | 
				
			||||||
                                item.DrugSpec= DrugInfo.DrugSpec.ToString();
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo,it.DrugSpec }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                if (item.BoardType == 5)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    _portUtil.WindowName = "BindingChannelDialog";
 | 
					 | 
				
			||||||
                                    // 向显示屏写入库位信息
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    //_portUtil.WriteChannelInfo(6, DrugManuNo.EffDate==null?"": DrugManuNo.EffDate, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    //await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    //_portUtil.WriteChannelInfo(5, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                    //await Task.Delay(200);
 | 
					 | 
				
			||||||
                                    _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                //_screenUtil.SetStockInfo(item, 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                                SnackbarMessageQueue.Enqueue($"药品【{DrugInfo.DrugName}】已经绑定了回收库位不可再次绑定");
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        else
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                            SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品信息");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                        SnackbarMessageQueue.Enqueue("每种药品只能绑定一个回收库位");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    //if (DrugInfo != null && DrugManuNo != null)
 | 
					 | 
				
			||||||
                    //{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    var c = SelectChannels.Count;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (c > 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        for (int i = 0; i < SelectChannels.Count; i++)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            var item = SelectChannels[i];
 | 
					 | 
				
			||||||
                            var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id&&cs.Quantity>0).ToList();
 | 
					 | 
				
			||||||
                            if(channelStock.Count>0)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                //有库存,不能解绑
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                                SnackbarMessageQueue.Enqueue($"库位{item.DrawerNo}-{item.ColNo}中还存在药品,不能绑定其他药品");
 | 
					 | 
				
			||||||
                                continue;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                item.PosNo = 0;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            item.DrugId = DrugInfo.DrugId.ToString();
 | 
					 | 
				
			||||||
                            //item.ManuNo = DrugManuNo.ManuNo;
 | 
					 | 
				
			||||||
                            item.Drug = DrugInfo;
 | 
					 | 
				
			||||||
                            item.DrugSpec = DrugInfo.DrugSpec.ToString();
 | 
					 | 
				
			||||||
                            //item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
 | 
					 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo,it.DrugSpec }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            if (item.BoardType == 5)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                _portUtil.WindowName = "BindingChannelDialog";
 | 
					 | 
				
			||||||
                                // 向显示屏写入库位信息
 | 
					 | 
				
			||||||
                                _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                //await Task.Delay(200);
 | 
					 | 
				
			||||||
                                Thread.Sleep(200);
 | 
					 | 
				
			||||||
                                _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                //await Task.Delay(200);
 | 
					 | 
				
			||||||
                                Thread.Sleep(200);
 | 
					 | 
				
			||||||
                                _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                //await Task.Delay(200);
 | 
					 | 
				
			||||||
                                Thread.Sleep(200);
 | 
					 | 
				
			||||||
                                //_portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                //await Task.Delay(200);
 | 
					 | 
				
			||||||
                                //Thread.Sleep(200);
 | 
					 | 
				
			||||||
                                //_portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate), item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                                ////await Task.Delay(200);
 | 
					 | 
				
			||||||
                                //Thread.Sleep(200);
 | 
					 | 
				
			||||||
                                _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                        SnackbarMessageQueue.Enqueue("所选库位中无可绑定库位【库位还存在药品】");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    //}
 | 
					 | 
				
			||||||
                    //else
 | 
					 | 
				
			||||||
                    //{
 | 
					 | 
				
			||||||
                    //    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                    //    SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品及批次信息");
 | 
					 | 
				
			||||||
                    //}
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand RemoveBinding
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                var SelectChannels = Channels.FindAll(item => item.IsSelected && item.DrugId != null);
 | 
					 | 
				
			||||||
                var c = SelectChannels.Count;
 | 
					 | 
				
			||||||
                if (c > 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    SelectChannels.ForEach(async item =>
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id && cs.Quantity > 0).ToList();
 | 
					 | 
				
			||||||
                        if (channelStock.Count > 0)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                            SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品【库位还存在药品】");
 | 
					 | 
				
			||||||
                            //该药品下的批次还有库存则不能解绑
 | 
					 | 
				
			||||||
                            return;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        item.DrugId = null;
 | 
					 | 
				
			||||||
                        //item.ManuNo = null;
 | 
					 | 
				
			||||||
                        //item.EffDate = null;
 | 
					 | 
				
			||||||
                        item.Drug = null;
 | 
					 | 
				
			||||||
                        item.DrugSpec = null;
 | 
					 | 
				
			||||||
                        SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId,it.DrugSpec }).ExecuteCommand();
 | 
					 | 
				
			||||||
                        if (item.BoardType == 5)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            // 清除显示屏库位信息
 | 
					 | 
				
			||||||
                            _portUtil.ClearContent(item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                            await Task.Delay(200);
 | 
					 | 
				
			||||||
                            _portUtil.ShowContent(item.DrawerNo, item.ColNo);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        //_screenUtil.SetStockInfo(item, 1);
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                    GetChannelsByDrawerNo();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					 | 
				
			||||||
                    SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BtnCloseCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                //DialogParameters parameters = new DialogParameters();
 | 
					 | 
				
			||||||
                //parameters.Add("",);
 | 
					 | 
				
			||||||
                // 关闭当前窗口
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
        string message = string.Empty;
 | 
					 | 
				
			||||||
        private void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (msg.WindowName == "BindingChannelDialog")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        if (message != msg.Message)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            message = msg.Message;
 | 
					 | 
				
			||||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public void UpdateComboBoxItems(string text)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
 | 
					 | 
				
			||||||
                        d.manufactory,d.max_stock,CONCAT(drug_name,'  ',drug_spec)as drug_name_spec FROM `drug_info` d";
 | 
					 | 
				
			||||||
            if (string.IsNullOrEmpty(text))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
					 | 
				
			||||||
                return;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (DrugInfos != null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                DrugInfos.Clear();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,971 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.select;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using Prism.Services.Dialogs;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Linq.Expressions;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Timers;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Media;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class CheckOrderNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
 | 
				
			||||||
 | 
					        System.Timers.Timer CheckBoxStatusTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _pageNum = 1;
 | 
				
			||||||
 | 
					        public int PageNum
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _pageNum;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _pageNum, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _pageCount = 1;
 | 
				
			||||||
 | 
					        public int PageCount
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _pageCount;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _pageCount, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _pageSize = 10;
 | 
				
			||||||
 | 
					        public int PageSize
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _pageSize;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _pageSize, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _totalCount = 0;
 | 
				
			||||||
 | 
					        public int TotalCount
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _totalCount;
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _totalCount, value);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //所选药箱号
 | 
				
			||||||
 | 
					        private int _drawerNo = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int DrawerNo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drawerNo;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _drawerNo, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件  处方日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string OrderDate
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _orderDate; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!String.IsNullOrEmpty(value))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SetProperty(ref _orderDate, value);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _isEnable = true;
 | 
				
			||||||
 | 
					        public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); }
 | 
				
			||||||
 | 
					        private int _status = 0;
 | 
				
			||||||
 | 
					        public int Status { get => _status; set { SetProperty(ref _status, value); } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<OrderInfo> _ordersList = new List<OrderInfo>();
 | 
				
			||||||
 | 
					        public List<OrderInfo> OrderInfoList
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _ordersList;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _ordersList, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private List<TotalDrug>? _totalDrugList = new List<TotalDrug>();
 | 
				
			||||||
 | 
					        public List<TotalDrug>? TotalDrugList
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _totalDrugList;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _totalDrugList, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private OrderInfo _selectOrderInfo;
 | 
				
			||||||
 | 
					        public OrderInfo selectOrderInfo { get => _selectOrderInfo; set => SetProperty(ref _selectOrderInfo, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 18个药箱号的可用状态
 | 
				
			||||||
 | 
					        private bool _IsEnabled1 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled1 { get => _IsEnabled1; set => SetProperty(ref _IsEnabled1, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled2 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled2 { get => _IsEnabled2; set => SetProperty(ref _IsEnabled2, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled3 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled3 { get => _IsEnabled3; set => SetProperty(ref _IsEnabled3, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled4 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled4 { get => _IsEnabled4; set => SetProperty(ref _IsEnabled4, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled5 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled5 { get => _IsEnabled5; set => SetProperty(ref _IsEnabled5, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled6 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled6 { get => _IsEnabled6; set => SetProperty(ref _IsEnabled6, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled7 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled7 { get => _IsEnabled7; set => SetProperty(ref _IsEnabled7, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled8 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled8 { get => _IsEnabled8; set => SetProperty(ref _IsEnabled8, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled9 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled9 { get => _IsEnabled9; set => SetProperty(ref _IsEnabled9, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled10 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled10 { get => _IsEnabled10; set => SetProperty(ref _IsEnabled10, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled11 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled11 { get => _IsEnabled11; set => SetProperty(ref _IsEnabled11, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled12 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled12 { get => _IsEnabled12; set => SetProperty(ref _IsEnabled12, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled13 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled13 { get => _IsEnabled13; set => SetProperty(ref _IsEnabled13, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled14 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled14 { get => _IsEnabled14; set => SetProperty(ref _IsEnabled14, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled15 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled15 { get => _IsEnabled15; set => SetProperty(ref _IsEnabled15, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled16 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled16 { get => _IsEnabled16; set => SetProperty(ref _IsEnabled16, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled17 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled17 { get => _IsEnabled17; set => SetProperty(ref _IsEnabled17, value); }
 | 
				
			||||||
 | 
					        private bool _IsEnabled18 = true;
 | 
				
			||||||
 | 
					        public bool IsEnabled18 { get => _IsEnabled18; set => SetProperty(ref _IsEnabled18, value); }
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 按钮颜色
 | 
				
			||||||
 | 
					        private Brush _button1Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button1Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button1Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button1Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button2Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button2Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button2Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button2Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button3Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button3Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button3Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button3Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button4Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button4Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button4Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button4Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button5Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button5Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button5Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button5Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button6Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button6Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button6Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button6Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button7Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button7Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button7Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button7Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button8Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button8Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button8Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button8Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button9Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button9Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button9Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button9Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button10Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button10Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button10Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button10Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button11Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button11Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button11Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button11Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button12Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button12Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button12Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button12Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button13Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button13Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button13Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button13Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button14Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button14Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button14Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button14Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button15Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button15Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button15Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button15Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button16Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button16Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button16Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button16Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button17Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button17Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button17Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button17Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button18Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button18Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button18Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button18Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        public CheckOrderNewWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string? _searchValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件 查询字段值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? SearchValue
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _searchValue; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SetProperty(ref _searchValue, value);
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int totalCount = 0;
 | 
				
			||||||
 | 
					            if (DrawerNo >= 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //查询当前药箱归属的药师
 | 
				
			||||||
 | 
					                ChannelList currentList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.DrawerNo == DrawerNo + 1 && cl.MachineId == "DM5").First();//.Select(cl => cl.BelongUser).First();
 | 
				
			||||||
 | 
					                string currentDrawerUser = currentList.BelongUser;
 | 
				
			||||||
 | 
					                OrderInfoList = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
				
			||||||
 | 
					                                .Includes(oi => oi.OrderDetailList, od => od.DrugInfo)
 | 
				
			||||||
 | 
					                               //.Includes(cl => cl.channelStocks, cs => cs.DrugInfo,di=>di.drugBase)
 | 
				
			||||||
 | 
					                               //.InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
				
			||||||
 | 
					                               //.InnerJoin<DrugInfo>((oi, od, di) => od.DrugId == di.DrugId.ToString())
 | 
				
			||||||
 | 
					                               .WhereIF(OrderDate != null, oi => oi.RecvDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
				
			||||||
 | 
					                               .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
				
			||||||
 | 
					                               .Where(oi => oi.DmStatus == 1)
 | 
				
			||||||
 | 
					                               .Where(oi => oi.HisDispFlag == 0)
 | 
				
			||||||
 | 
					                               .Where(oi => oi.CancelFlag == 0)
 | 
				
			||||||
 | 
					                               .Where(oi => oi.DoctorCode == currentDrawerUser)
 | 
				
			||||||
 | 
					                               .OrderBy(oi => oi.OrderId)
 | 
				
			||||||
 | 
					                               .ToPageList(PageNum, PageSize, ref totalCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (OrderInfoList != null && OrderInfoList.Count() > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    OrderInfoList.ForEach(oi => oi.ItemIsChecked = true);
 | 
				
			||||||
 | 
					                    OrderInfoList.ForEach(oi => oi.OrderDetailList.ForEach(od => od.DrugInfo = od.DrugInfo ?? new DrugInfo()));
 | 
				
			||||||
 | 
					                    //TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).GroupBy(oi => oi.OrderDetailList.DrugInfo.DrugName).Select(oi => new TotalDrug { DrugName = oi.Key, TotalCount = oi.Sum(item => item.OrderDetailList.Quantity) }).ToList();
 | 
				
			||||||
 | 
					                    TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).SelectMany(OrderDetailList => OrderDetailList.OrderDetailList).GroupBy(item => item.DrugInfo.DrugName).Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    TotalDrugList = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                TotalCount = totalCount;
 | 
				
			||||||
 | 
					                PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
				
			||||||
 | 
					                if (Convert.ToDateTime(currentList.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    switch (DrawerNo)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        case 1:
 | 
				
			||||||
 | 
					                            _button1Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 2:
 | 
				
			||||||
 | 
					                            _button2Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 3:
 | 
				
			||||||
 | 
					                            _button3Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 4:
 | 
				
			||||||
 | 
					                            _button4Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 5:
 | 
				
			||||||
 | 
					                            _button5Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 6:
 | 
				
			||||||
 | 
					                            _button6Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 7:
 | 
				
			||||||
 | 
					                            _button7Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 8:
 | 
				
			||||||
 | 
					                            _button8Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 9:
 | 
				
			||||||
 | 
					                            _button9Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 10:
 | 
				
			||||||
 | 
					                            _button10Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 11:
 | 
				
			||||||
 | 
					                            _button11Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 12:
 | 
				
			||||||
 | 
					                            _button12Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 13:
 | 
				
			||||||
 | 
					                            _button13Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 14:
 | 
				
			||||||
 | 
					                            _button14Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 15:
 | 
				
			||||||
 | 
					                            _button15Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 16:
 | 
				
			||||||
 | 
					                            _button16Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 17:
 | 
				
			||||||
 | 
					                            _button17Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case 18:
 | 
				
			||||||
 | 
					                            _button18Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        default:
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            List<ChannelList> chlList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5").ToList();//.Select(cl => cl.BelongUser).First();
 | 
				
			||||||
 | 
					            if (chlList != null && chlList.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                for (int i = 0; i < chlList.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ChannelList chl = chlList[i];
 | 
				
			||||||
 | 
					                    if (Convert.ToDateTime(chl.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        switch (chl.DrawerNo)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            case 1:
 | 
				
			||||||
 | 
					                                Button1Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 2:
 | 
				
			||||||
 | 
					                                Button2Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 3:
 | 
				
			||||||
 | 
					                                Button3Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 4:
 | 
				
			||||||
 | 
					                                Button4Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 5:
 | 
				
			||||||
 | 
					                                Button5Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 6:
 | 
				
			||||||
 | 
					                                Button6Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 7:
 | 
				
			||||||
 | 
					                                Button7Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 8:
 | 
				
			||||||
 | 
					                                Button8Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 9:
 | 
				
			||||||
 | 
					                                Button9Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 10:
 | 
				
			||||||
 | 
					                                Button10Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 11:
 | 
				
			||||||
 | 
					                                Button11Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 12:
 | 
				
			||||||
 | 
					                                Button12Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 13:
 | 
				
			||||||
 | 
					                                Button13Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 14:
 | 
				
			||||||
 | 
					                                Button14Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 15:
 | 
				
			||||||
 | 
					                                Button15Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 16:
 | 
				
			||||||
 | 
					                                Button16Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 17:
 | 
				
			||||||
 | 
					                                Button17Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            case 18:
 | 
				
			||||||
 | 
					                                Button18Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                            default:
 | 
				
			||||||
 | 
					                                break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand RowSelected
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (selectOrderInfo != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    OrderInfoList = OrderInfoList.Select(x =>
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (x.OrderNo == selectOrderInfo.OrderNo)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            x.ItemIsChecked = !x.ItemIsChecked;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return x;
 | 
				
			||||||
 | 
					                    }).ToList();
 | 
				
			||||||
 | 
					                    if (OrderInfoList != null && OrderInfoList.Count() > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).GroupBy(oi => oi._OrderDetail.DrugInfo.DrugName).Select(oi => new TotalDrug { DrugName = oi.Key, TotalCount = oi.Sum(item => item._OrderDetail.Quantity) }).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).SelectMany(OrderDetailList => OrderDetailList.OrderDetailList).GroupBy(item => item.DrugInfo.DrugName).Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand Query
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //确认
 | 
				
			||||||
 | 
					        public DelegateCommand CheckOrder
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                CheckOrderAction();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void CheckOrderAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var confirmData = OrderInfoList.Where(oi => oi.ItemIsChecked == true).ToList();
 | 
				
			||||||
 | 
					            if (confirmData.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    string empChannelStock = string.Empty;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    for (int i = 0; i < confirmData.Count; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        OrderInfo oi = confirmData[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        //更新处方状态
 | 
				
			||||||
 | 
					                        if (oi.DmStatus == 1)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                DmStatus = 2,
 | 
				
			||||||
 | 
					                                OrderNo = oi.OrderNo
 | 
				
			||||||
 | 
					                            }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                OrderNo = oi.OrderNo,
 | 
				
			||||||
 | 
					                                PatientId = oi.PatientId,
 | 
				
			||||||
 | 
					                                Pharmacy = oi.Pharmacy,
 | 
				
			||||||
 | 
					                                State = 2,
 | 
				
			||||||
 | 
					                                Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        //Expression<Func<ChannelStock, bool>> updateExp = it => it.ManuNo == oi._OrderDetail.SetManuNo && it.EffDate == oi._OrderDetail.SetEffDate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        for (int j = 0; j < oi.OrderDetailList.Count; j++)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            oi._OrderDetail = oi.OrderDetailList[j];
 | 
				
			||||||
 | 
					                            int drawerNo = DrawerNo + 1;
 | 
				
			||||||
 | 
					                            ChannelStock cs = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
				
			||||||
 | 
					                                             .Where(cs => cs.DrugId == oi._OrderDetail.DrugId
 | 
				
			||||||
 | 
					                                                    && cs.ManuNo == oi._OrderDetail.SetManuNo
 | 
				
			||||||
 | 
					                                                   // && cs.EffDate == oi._OrderDetail.SetEffDate
 | 
				
			||||||
 | 
					                                                    && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM5")
 | 
				
			||||||
 | 
					                                                    && cs.DrawerNo == drawerNo
 | 
				
			||||||
 | 
					                                                    &&cs.Quantity>=oi._OrderDetail.Quantity).First();
 | 
				
			||||||
 | 
					                            if (cs == null)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo},{oi._OrderDetail.SetEffDate};";
 | 
				
			||||||
 | 
					                                continue;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity;
 | 
				
			||||||
 | 
					                            // 更新数据 库存信息
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (cs != null)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
 | 
				
			||||||
 | 
					                                    DrawerNo = cs.DrawerNo,
 | 
				
			||||||
 | 
					                                    ColNo = cs.ColNo,
 | 
				
			||||||
 | 
					                                    DrugId = cs.DrugId,
 | 
				
			||||||
 | 
					                                    ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                    EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
				
			||||||
 | 
					                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                    OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                                    Quantity = oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                                    Type = 2,
 | 
				
			||||||
 | 
					                                    InvoiceId = oi.OrderNo
 | 
				
			||||||
 | 
					                                    //, StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                                }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                #region 记录 注射剂使用与交接记录报表
 | 
				
			||||||
 | 
					                                //查询发药时间
 | 
				
			||||||
 | 
					                                //MachineRecord SendMachineRecord = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 2)
 | 
				
			||||||
 | 
					                                //.OrderByDescending(mr => mr.OperationTime)
 | 
				
			||||||
 | 
					                                //.First();
 | 
				
			||||||
 | 
					                                //string retUser = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cl.DrawerNo == cs.DrawerNo)
 | 
				
			||||||
 | 
					                                //.Select(cl => cl.BelongUser).First();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable<RejectionReport>().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp => rp.SendDate).First();
 | 
				
			||||||
 | 
					                                if (rejectionReport != null)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    //发药信息
 | 
				
			||||||
 | 
					                                    //RejectionReport rejectionReport = new RejectionReport();
 | 
				
			||||||
 | 
					                                    //rejectionReport.SendDate = SendMachineRecord.OperationTime;
 | 
				
			||||||
 | 
					                                    //rejectionReport.SendUser = SendMachineRecord.Operator.ToString();
 | 
				
			||||||
 | 
					                                    //rejectionReport.ReceiveUser = retUser;
 | 
				
			||||||
 | 
					                                    rejectionReport.RealNum = cs.BaseQuantity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    //还药信息
 | 
				
			||||||
 | 
					                                    rejectionReport.InfactNum = cs.BaseQuantity - oi._OrderDetail.Quantity;
 | 
				
			||||||
 | 
					                                    rejectionReport.EmptyNum = oi._OrderDetail.Quantity;
 | 
				
			||||||
 | 
					                                    rejectionReport.ReturnTime = DateTime.Now.ToString();
 | 
				
			||||||
 | 
					                                    rejectionReport.ReturnUser = rejectionReport.SendUser;
 | 
				
			||||||
 | 
					                                    rejectionReport.ReturnReceiveUser = rejectionReport.ReceiveUser;// SendMachineRecord.Operator.ToString();
 | 
				
			||||||
 | 
					                                    rejectionReport.DrugId = oi._OrderDetail.DrugId;
 | 
				
			||||||
 | 
					                                    rejectionReport.DrugName = oi._OrderDetail.DrugInfo.DrugName;
 | 
				
			||||||
 | 
					                                    rejectionReport.DrugSpec = oi._OrderDetail.DrugInfo.DrugSpec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    rejectionReport.OperationTime = DateTime.Now;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    int iRejectionReport = SqlSugarHelper.Db.Updateable(rejectionReport).ExecuteCommand();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            //保存账册
 | 
				
			||||||
 | 
					                            int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                DrugId = oi._OrderDetail.DrugId,
 | 
				
			||||||
 | 
					                                Type = 2,
 | 
				
			||||||
 | 
					                                Department = oi.DeptName,
 | 
				
			||||||
 | 
					                                OrderNo = oi.OrderNo,
 | 
				
			||||||
 | 
					                                ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                EffDate = cs.EffDate,
 | 
				
			||||||
 | 
					                                OutQuantity = oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
 | 
				
			||||||
 | 
					                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                                CreateTime = DateTime.Now,
 | 
				
			||||||
 | 
					                                InvoiceNo = oi.OrderNo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
 | 
					                            AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                            .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
				
			||||||
 | 
					                            .Where(ab => ab.Type == 3)
 | 
				
			||||||
 | 
					                            .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
				
			||||||
 | 
					                            .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
				
			||||||
 | 
					                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                            if (accountBookG2Day != null)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - oi._OrderDetail.Quantity;
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
				
			||||||
 | 
					                                int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    DrugId = oi._OrderDetail.DrugId,
 | 
				
			||||||
 | 
					                                    Type = 3,
 | 
				
			||||||
 | 
					                                    ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                    EffDate = cs.EffDate,
 | 
				
			||||||
 | 
					                                    YQuantity = 0,
 | 
				
			||||||
 | 
					                                    ManuStock = oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                                    TotalStock = oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                    MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
 | 
				
			||||||
 | 
					                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                                    InvoiceNo = "日结存"
 | 
				
			||||||
 | 
					                                }).ExecuteCommand();
 | 
				
			||||||
 | 
					                                if (iDayResult <= 0)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    logger.Info($"未写入日结存数据{oi._OrderDetail.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
 | 
					                            AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                            .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString()))
 | 
				
			||||||
 | 
					                            .Where(ab => ab.Type == 4)
 | 
				
			||||||
 | 
					                            .Where(ab => ab.DrugId == oi._OrderDetail.DrugId)
 | 
				
			||||||
 | 
					                            .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                            if (accountBookG2Total != null)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - oi._OrderDetail.Quantity;
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
				
			||||||
 | 
					                                int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    DrugId = oi._OrderDetail.DrugId,
 | 
				
			||||||
 | 
					                                    Type = 4,
 | 
				
			||||||
 | 
					                                    YQuantity = 0,
 | 
				
			||||||
 | 
					                                    ManuStock = oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                                    TotalStock = oi._OrderDetail.Quantity,
 | 
				
			||||||
 | 
					                                    UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                    UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                    MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(),
 | 
				
			||||||
 | 
					                                    CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                                    InvoiceNo = "总结存"
 | 
				
			||||||
 | 
					                                }).ExecuteCommand();
 | 
				
			||||||
 | 
					                                if (iTotalResult <= 0)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    logger.Info($"未写入总结存数据{oi._OrderDetail.DrugId}-{oi._OrderDetail.Quantity}");
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (!string.IsNullOrEmpty(empChannelStock))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = $"所选单子中对应药品批次效期无效{empChannelStock}",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        logger.Info($"所选单子对应药品批次效期无效{empChannelStock}");
 | 
				
			||||||
 | 
					                        throw new Exception("事务回滚");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                if (f.Data)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    RequestData();
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "所选单子已核对完成",
 | 
				
			||||||
 | 
					                        Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    RequestData();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (!f.IsSuccess)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "核对失败!",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                Status = 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "请勾选要核对单数据",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 选择药箱,打开药箱
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand<string> UpdateDrawerNo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<string>(OpenBoxAction);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public async void OpenBoxAction(string strDrawerNo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            DrawerNo = Convert.ToInt32(strDrawerNo);
 | 
				
			||||||
 | 
					            MachineRecord machineRecord = new MachineRecord();
 | 
				
			||||||
 | 
					            machineRecord.MachineId = "DM5";
 | 
				
			||||||
 | 
					            machineRecord.DrawerNo = DrawerNo + 1;
 | 
				
			||||||
 | 
					            machineRecord.Operator = HomeWindowViewModel.Operator?.Id;
 | 
				
			||||||
 | 
					            machineRecord.OperationTime = DateTime.Now;
 | 
				
			||||||
 | 
					            machineRecord.Type = 55;
 | 
				
			||||||
 | 
					            machineRecord.InvoiceId = $"打开{DrawerNo + 1}号药箱";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (DrawerNo > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					                Status = 1;
 | 
				
			||||||
 | 
					                _portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
 | 
				
			||||||
 | 
					                //logger.Info($"正在打开{DrawerNo + 1}号药箱");
 | 
				
			||||||
 | 
					                //记录开药箱日志
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
 | 
				
			||||||
 | 
					                ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
 | 
				
			||||||
 | 
					                //设置对应药箱按钮可用状态
 | 
				
			||||||
 | 
					                SetIsEnableStatus(DrawerNo, false);
 | 
				
			||||||
 | 
					                //_eventAggregator.GetEvent<BoxOpenStatusEvent>().Publish();
 | 
				
			||||||
 | 
					                if (CheckBoxStatusTimer is null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    CheckBoxStatusTimer = new System.Timers.Timer();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (!CheckBoxStatusTimer.Enabled)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState);
 | 
				
			||||||
 | 
					                    CheckBoxStatusTimer.Interval = 3000;
 | 
				
			||||||
 | 
					                    CheckBoxStatusTimer.Start();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //设置对应药箱按钮可用状态
 | 
				
			||||||
 | 
					                //SetIsEnableStatus(DrawerNo, false);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SetIsEnableStatus(int drawerNO, bool status)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            switch (drawerNO)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case 0:
 | 
				
			||||||
 | 
					                    IsEnabled1 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 1:
 | 
				
			||||||
 | 
					                    IsEnabled2 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 2:
 | 
				
			||||||
 | 
					                    IsEnabled3 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 3:
 | 
				
			||||||
 | 
					                    IsEnabled4 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 4:
 | 
				
			||||||
 | 
					                    IsEnabled5 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 5:
 | 
				
			||||||
 | 
					                    IsEnabled6 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 6:
 | 
				
			||||||
 | 
					                    IsEnabled7 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 7:
 | 
				
			||||||
 | 
					                    IsEnabled8 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 8:
 | 
				
			||||||
 | 
					                    IsEnabled9 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 9:
 | 
				
			||||||
 | 
					                    IsEnabled10 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 10:
 | 
				
			||||||
 | 
					                    IsEnabled11 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 11:
 | 
				
			||||||
 | 
					                    IsEnabled12 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 12:
 | 
				
			||||||
 | 
					                    IsEnabled13 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 13:
 | 
				
			||||||
 | 
					                    IsEnabled14 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 14:
 | 
				
			||||||
 | 
					                    IsEnabled15 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 15:
 | 
				
			||||||
 | 
					                    IsEnabled16 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 16:
 | 
				
			||||||
 | 
					                    IsEnabled17 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 17:
 | 
				
			||||||
 | 
					                    IsEnabled18 = status;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void GetAllBoxState(object sender, ElapsedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //查询药箱是否关闭,如果已经关闭则按钮可用,可继续开该编号的药箱
 | 
				
			||||||
 | 
					            if (DrawerNo >= 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                bool[] boolArrs =  ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					                bool allFalse = Array.TrueForAll(boolArrs, b => b == false);
 | 
				
			||||||
 | 
					                if (allFalse)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (CheckBoxStatusTimer.Enabled)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        CheckBoxStatusTimer.Stop();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                for (int i = 0; i < boolArrs.Length; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //设置对应药箱按钮可用状态
 | 
				
			||||||
 | 
					                    SetIsEnableStatus(i, !boolArrs[i]);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    switch (msg.EventType)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        // 药箱打开
 | 
				
			||||||
 | 
					        //        case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					        //            if (Status == 1)
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                Status = 2;
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            //记录开药箱日志
 | 
				
			||||||
 | 
					        //            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                MachineId = "DM5",
 | 
				
			||||||
 | 
					        //                DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					        //                Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					        //                OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					        //                Type = 55,
 | 
				
			||||||
 | 
					        //                InvoiceId = $"打开{DrawerNo}号药箱",
 | 
				
			||||||
 | 
					        //            }).ExecuteCommand();
 | 
				
			||||||
 | 
					        //            _portUtil.GetBoxStatus();
 | 
				
			||||||
 | 
					        //            break;
 | 
				
			||||||
 | 
					        //        // 药箱关闭
 | 
				
			||||||
 | 
					        //        case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					        //            //记录药箱操作日志
 | 
				
			||||||
 | 
					        //            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                MachineId = "DM5",
 | 
				
			||||||
 | 
					        //                DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					        //                Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					        //                OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					        //                Type = 55,
 | 
				
			||||||
 | 
					        //                InvoiceId = "药箱关闭",
 | 
				
			||||||
 | 
					        //            }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            if (Status == 2)
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                Status = 3;
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            _portUtil.Operate = false;
 | 
				
			||||||
 | 
					        //            break;
 | 
				
			||||||
 | 
					        //        // 打开失败
 | 
				
			||||||
 | 
					        //        case EventType.OPENERROR:
 | 
				
			||||||
 | 
					        //            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                Message = msg.Message,
 | 
				
			||||||
 | 
					        //                Type = MsgType.ERROR
 | 
				
			||||||
 | 
					        //            };
 | 
				
			||||||
 | 
					        //            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            Status = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            //记录药箱操作日志
 | 
				
			||||||
 | 
					        //            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                MachineId = "DM5",
 | 
				
			||||||
 | 
					        //                DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					        //                Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					        //                OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					        //                Type = 55,
 | 
				
			||||||
 | 
					        //                InvoiceId = "药箱打开失败",
 | 
				
			||||||
 | 
					        //            }).ExecuteCommand();
 | 
				
			||||||
 | 
					        //            _portUtil.Operate = false;
 | 
				
			||||||
 | 
					        //            break;
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public class TotalDrug
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string DrugName { get; set; }
 | 
				
			||||||
 | 
					        public int TotalCount { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -1,326 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using 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.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();
 | 
					 | 
				
			||||||
                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
 | 
					 | 
				
			||||||
                            }).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 = 0;
 | 
					 | 
				
			||||||
            if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            Is8Drawer = count < 9;
 | 
					 | 
				
			||||||
            Is16Drawer = count >= 16;
 | 
					 | 
				
			||||||
            Is17Drawer = count > 16;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                .Includes(cs => cs.DrugInfo)
 | 
					 | 
				
			||||||
                .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);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,6 +0,0 @@
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    internal class CollectionViewGroupInternal
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,40 +0,0 @@
 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class DebugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,331 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows.Threading;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class DrawerAddDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(DrawerAddDrugWindowViewModel));
 | 
					 | 
				
			||||||
        private List<int> _drawerNoList = new List<int>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock>? _channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock>? ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
    (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DrawerAddDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (msg.WindowName == "DrawerAddDrugWindow")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 2;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 2)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 3;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 2)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            ChannelStocks.ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _drawerNo = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int DrawerNo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drawerNo;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _drawerNo, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _is8Drawer = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool Is8Drawer { get => _is8Drawer; set => SetProperty(ref _is8Drawer, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _is16Drawer = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _is17Drawer = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
 | 
					 | 
				
			||||||
        public DelegateCommand<string> UpdateDrawerNo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand<string>((DrawerNo) =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }, (DrawerNo) => Status == 0
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public DelegateCommand OpenDrawer
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Status = 1;
 | 
					 | 
				
			||||||
                _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.DrawerNo = DrawerNo;
 | 
					 | 
				
			||||||
                    _portUtil.Start();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch (Exception ex)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    logger.Info($"OpenDrawer异常:{ex.Message}");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }, () => Status == 0).ObservesProperty(() => Status);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isFinishClick = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 完成按钮
 | 
					 | 
				
			||||||
        public DelegateCommand TakeFinish
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!_isFinishClick)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _isFinishClick = true;
 | 
					 | 
				
			||||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
 | 
					 | 
				
			||||||
                    if (record.Count > 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        string InvoiceId = "DRAWER_" + CurrentTimeMillis();
 | 
					 | 
				
			||||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            for (int i = 0; i < record.Count; i++)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                ChannelStock it = record[i];
 | 
					 | 
				
			||||||
                                it.ManuNo = it.drugManuNo.ManuNo;
 | 
					 | 
				
			||||||
                                it.EffDate = it.drugManuNo.EffDate;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                // 更新数据 库存信息
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Quantity = it.Quantity + it.AddQuantity,
 | 
					 | 
				
			||||||
                                    ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = it.EffDate,
 | 
					 | 
				
			||||||
                                    Id = it.Id,
 | 
					 | 
				
			||||||
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                // 获取更新完库存后的药品库存
 | 
					 | 
				
			||||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                                    .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                // 保存数据 入库记录
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    MachineId = it.MachineId,
 | 
					 | 
				
			||||||
                                    DrawerNo = it.DrawerNo,
 | 
					 | 
				
			||||||
                                    ColNo = it.ColNo,
 | 
					 | 
				
			||||||
                                    DrugId = it.DrugId,
 | 
					 | 
				
			||||||
                                    ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
					 | 
				
			||||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                                    Reviewer=HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                    OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                    Quantity = it.AddQuantity,
 | 
					 | 
				
			||||||
                                    Type = 1,
 | 
					 | 
				
			||||||
                                    InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                                    StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                                }).ExecuteCommand();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            return true;
 | 
					 | 
				
			||||||
                        });
 | 
					 | 
				
			||||||
                        if (f.Data)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            RequestData();
 | 
					 | 
				
			||||||
                            AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Message = "抽屉加药完成,库存已更新",
 | 
					 | 
				
			||||||
                                Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                            };
 | 
					 | 
				
			||||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        else
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Message = "更新库存失败",
 | 
					 | 
				
			||||||
                                Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                            };
 | 
					 | 
				
			||||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        _isFinishClick = false;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        _isFinishClick = false;
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "没有填写加药数量",
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 取消按钮
 | 
					 | 
				
			||||||
        public DelegateCommand CancleTake
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                _portUtil.ResetData();
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public long CurrentTimeMillis()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void FindDrawerCount()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            int count = 0;
 | 
					 | 
				
			||||||
            if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            { 
 | 
					 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            Is8Drawer = count < 9;
 | 
					 | 
				
			||||||
            Is16Drawer = count >= 16;
 | 
					 | 
				
			||||||
            Is17Drawer = count > 16;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
               .Includes(cs => cs.DrugInfo, di => di.DrugManuNos)
 | 
					 | 
				
			||||||
               .Where(cs => cs.DrawerNo == DrawerNo)
 | 
					 | 
				
			||||||
               .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
               .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
               .Where(cs => cs.DrugId != null)
 | 
					 | 
				
			||||||
               .OrderBy(cs => cs.ColNo)
 | 
					 | 
				
			||||||
               .ToList();
 | 
					 | 
				
			||||||
            ChannelStocks = queryData.Select(cs =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                cs.drugManuNo = cs.DrugInfo.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
 | 
					 | 
				
			||||||
                return cs;
 | 
					 | 
				
			||||||
            }).ToList();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
					 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            FindDrawerCount();
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
					 | 
				
			||||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求
 | 
					 | 
				
			||||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,332 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using System.Windows.Threading;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using Newtonsoft.Json;
 | 
					 | 
				
			||||||
using System.Text.RegularExpressions;
 | 
					 | 
				
			||||||
using System.Windows.Controls;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class DrawerTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(DrawerTakeDrugWindowViewModel));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks = new List<ChannelStock>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
    (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DrawerTakeDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (msg.WindowName == "DrawerTakeDrugWindow")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 2;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 2)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 3;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 2)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            ChannelStocks.ForEach(it => it.TakeQuantity = msg.Quantitys[it.ColNo - 1]);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _drawerNo = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int DrawerNo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _drawerNo;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _drawerNo, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _is8Drawer = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool Is8Drawer { get => _is8Drawer; set => SetProperty(ref _is8Drawer, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _is16Drawer = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _is17Drawer = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
 | 
					 | 
				
			||||||
        public DelegateCommand<string> UpdateDrawerNo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand<string>((DrawerNo) =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                this.DrawerNo = Convert.ToInt32(DrawerNo);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }, (DrawerNo) => Status == 0
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand OpenDrawer
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status == 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    Status = 1;
 | 
					 | 
				
			||||||
                    _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    _portUtil.WindowName = "DrawerTakeDrugWindow";
 | 
					 | 
				
			||||||
                    _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
					 | 
				
			||||||
                    _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
					 | 
				
			||||||
                    _portUtil.DrawerNo = DrawerNo;
 | 
					 | 
				
			||||||
                    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start())
 | 
					 | 
				
			||||||
                    ;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isFinishClick = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 完成按钮
 | 
					 | 
				
			||||||
        public DelegateCommand TakeFinish
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!_isFinishClick)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _isFinishClick = true;
 | 
					 | 
				
			||||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity != 0).ToList();
 | 
					 | 
				
			||||||
                    logger.Info("点击完成按钮,库位数据:" + JsonConvert.SerializeObject(record));
 | 
					 | 
				
			||||||
                    if (record.Count > 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        string InvoiceId = "DRAWER_" + CurrentTimeMillis();
 | 
					 | 
				
			||||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            for (int i = 0; i < record.Count; i++)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                ChannelStock it = record[i];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                // 更新数据 库存信息
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
					 | 
				
			||||||
                                    ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = it.EffDate,
 | 
					 | 
				
			||||||
                                    Id = it.Id,
 | 
					 | 
				
			||||||
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                // 获取更新完库存后的药品库存
 | 
					 | 
				
			||||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                                    .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                // 保存数据 出库记录
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    MachineId = it.MachineId,
 | 
					 | 
				
			||||||
                                    DrawerNo = it.DrawerNo,
 | 
					 | 
				
			||||||
                                    ColNo = it.ColNo,
 | 
					 | 
				
			||||||
                                    DrugId = it.DrugId,
 | 
					 | 
				
			||||||
                                    ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
					 | 
				
			||||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                    OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                    Quantity = it.TakeQuantity,
 | 
					 | 
				
			||||||
                                    Type = 2,
 | 
					 | 
				
			||||||
                                    InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                                    StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                                }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                logger.Info($"抽屉取药保存->库位【{it.DrawerNo}-{it.ColNo}】取出药品【{it.DrugInfo.DrugName}】个数【{it.TakeQuantity}】,取药前库存【{it.Quantity}】");
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            return true;
 | 
					 | 
				
			||||||
                        });
 | 
					 | 
				
			||||||
                        if (f.Data)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            RequestData();
 | 
					 | 
				
			||||||
                            AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Message = "抽屉取药完成,库存已更新",
 | 
					 | 
				
			||||||
                                Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                            };
 | 
					 | 
				
			||||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        if (!f.IsSuccess)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Message = "抽屉取药完成,库存更新失败!",
 | 
					 | 
				
			||||||
                                Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                            };
 | 
					 | 
				
			||||||
                            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        _isFinishClick = false;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        _isFinishClick = false;
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "没有填写取药数量",
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 取消按钮
 | 
					 | 
				
			||||||
        public DelegateCommand CancleTake
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                _portUtil.ResetData();
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public long CurrentTimeMillis()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void FindDrawerCount()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            int count = 0;
 | 
					 | 
				
			||||||
            if (ConfigurationManager.AppSettings["MultiBatch"].ToString().Equals("1"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            Is8Drawer = count < 9;
 | 
					 | 
				
			||||||
            Is16Drawer = count >= 16;
 | 
					 | 
				
			||||||
            Is17Drawer = count > 16;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                .Includes(cs => cs.DrugInfo)
 | 
					 | 
				
			||||||
                .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,12 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class DrugBaseWindowViewModel
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,283 +0,0 @@
 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using log4net.Repository.Hierarchy;
 | 
					 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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 > 0).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 > 0).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)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -36,6 +36,9 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            set => SetProperty(ref _userList, value);
 | 
					            set => SetProperty(ref _userList, value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public UserList DMUserList=new UserList();
 | 
				
			||||||
 | 
					        private string UserName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public List<RoleDm> Roles { get; set; }
 | 
					        public List<RoleDm> Roles { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private string _oldPass;
 | 
					        private string _oldPass;
 | 
				
			||||||
| 
						 | 
					@ -94,15 +97,29 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if(string.IsNullOrEmpty(UserList.UserBarcode))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = $"工号不能为空",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        return;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    // 修改密码
 | 
					                    // 修改密码
 | 
				
			||||||
                    if (OnlyPassword)
 | 
					                    if (OnlyPassword)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
 | 
					                        DMUserList = SqlSugarHelper.Db.Queryable<UserList>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["dm_machineId"]??"DM3") && r.UserName == UserName).OrderBy(r => r.Id).First();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (MD5.GetMD5Hash(OldPass).ToLower().Equals(UserList.PassWord.ToLower()))
 | 
					                        if (MD5.GetMD5Hash(OldPass).ToLower().Equals(UserList.PassWord.ToLower()))
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            // 旧密码输入正确
 | 
					                            // 旧密码输入正确
 | 
				
			||||||
                            UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
					                            UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.PassWord }).ExecuteCommand();
 | 
					                            SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.PassWord }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            //修改交接柜用户密码
 | 
				
			||||||
 | 
					                            DMUserList.PassWord = UserList.PassWord;
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable<UserList>(DMUserList).UpdateColumns(u => new { u.PassWord }).ExecuteCommand();
 | 
				
			||||||
                            // 关闭当前窗口
 | 
					                            // 关闭当前窗口
 | 
				
			||||||
                            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
					                            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
| 
						 | 
					@ -116,25 +133,49 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if (UserList.Id > 0)
 | 
					                        if (UserList.Id > 0)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
 | 
					                            DMUserList = SqlSugarHelper.Db.Queryable<UserList>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["dm_machineId"]??"DM3") && r.UserName == UserName).OrderBy(r => r.Id).First();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            // 更新
 | 
					                            // 更新
 | 
				
			||||||
                            // 没有写密码
 | 
					                            // 没有写密码
 | 
				
			||||||
                            if (string.IsNullOrEmpty(NewPass))
 | 
					                            if (string.IsNullOrEmpty(NewPass))
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.UserBarcode, u.RoleId }).ExecuteCommand();
 | 
					                                SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.UserBarcode, u.RoleId }).ExecuteCommand();
 | 
				
			||||||
 | 
					                                //更新交接柜用户
 | 
				
			||||||
 | 
					                                DMUserList.Nickname = UserList.Nickname;
 | 
				
			||||||
 | 
					                                DMUserList.UserName = UserList.UserName;
 | 
				
			||||||
 | 
					                                DMUserList.UserBarcode = UserList.UserBarcode;
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable<UserList>(DMUserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.UserBarcode, u.RoleId }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            // 更改了密码
 | 
					                            // 更改了密码
 | 
				
			||||||
                            else
 | 
					                            else
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
					                                UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId }).ExecuteCommand();
 | 
					                                SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                DMUserList.PassWord = UserList.PassWord;
 | 
				
			||||||
 | 
					                                DMUserList.Nickname= UserList.Nickname;
 | 
				
			||||||
 | 
					                                DMUserList.UserName= UserList.UserName;
 | 
				
			||||||
 | 
					                                DMUserList.UserBarcode= UserList.UserBarcode;
 | 
				
			||||||
 | 
					                                SqlSugarHelper.Db.Updateable<UserList>(DMUserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        else
 | 
					                        else
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
					                            UserList.PassWord = MD5.GetMD5Hash(NewPass);
 | 
				
			||||||
                            UserList.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
					                            UserList.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM5";
 | 
				
			||||||
                            // 插入
 | 
					                            // 插入
 | 
				
			||||||
                            SqlSugarHelper.Db.Insertable<UserList>(UserList).InsertColumns(u => new { u.Id, u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId, u.MachineId }).ExecuteCommand();
 | 
					                            SqlSugarHelper.Db.Insertable<UserList>(UserList).InsertColumns(u => new { u.Id, u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId, u.MachineId }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            // 插入交接柜用户
 | 
				
			||||||
 | 
					                            int? roleId = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["dm_machineId"]??"DM3")).OrderBy(r => r.Id).Select(r => r.Id).First();
 | 
				
			||||||
 | 
					                            DMUserList = UserList;
 | 
				
			||||||
 | 
					                            DMUserList.MachineId =  ConfigurationManager.AppSettings["dm_machineId"] ?? "DM3";
 | 
				
			||||||
 | 
					                            DMUserList.RoleId = roleId;
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Insertable<UserList>(DMUserList).InsertColumns(u => new { u.Id, u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId, u.MachineId }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
					                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
| 
						 | 
					@ -154,7 +195,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void GetAllRole()
 | 
					        void GetAllRole()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Roles = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).OrderBy(r => r.Id).ToList();
 | 
					            Roles = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM3")).OrderBy(r => r.Id).ToList();
 | 
				
			||||||
            RaisePropertyChanged("Roles");
 | 
					            RaisePropertyChanged("Roles");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -189,12 +230,14 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                OnlyPassword = parameters.GetValue<bool>("EditPass");
 | 
					                OnlyPassword = parameters.GetValue<bool>("EditPass");
 | 
				
			||||||
                EditUser = false;
 | 
					                EditUser = false;
 | 
				
			||||||
                Title = "修改密码";
 | 
					                Title = "修改密码";
 | 
				
			||||||
 | 
					                UserName = UserList.UserName;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (parameters.ContainsKey("User"))
 | 
					                if (parameters.ContainsKey("User"))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    UserList = parameters.GetValue<UserList>("User");
 | 
					                    UserList = parameters.GetValue<UserList>("User");
 | 
				
			||||||
 | 
					                    UserName = UserList.UserName;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (UserList.Id == null)
 | 
					                if (UserList.Id == null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,6 +23,8 @@ using System.Windows.Threading;
 | 
				
			||||||
using Newtonsoft.Json.Linq;
 | 
					using Newtonsoft.Json.Linq;
 | 
				
			||||||
using DM_Weight.msg;
 | 
					using DM_Weight.msg;
 | 
				
			||||||
using DM_Weight.HIKVISION;
 | 
					using DM_Weight.HIKVISION;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Diagnostics;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -34,6 +36,22 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        private UserList? _userList;
 | 
					        private UserList? _userList;
 | 
				
			||||||
        private UserList? _userList2;
 | 
					        private UserList? _userList2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 冰箱温度
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private string _wd = "恒温冷藏抽屉当前温度2.8(非真实数据)";
 | 
				
			||||||
 | 
					        public string WD { get => _wd; set => SetProperty(ref _wd, value); }
 | 
				
			||||||
 | 
					        System.Timers.Timer WDTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        System.Timers.Timer WSDTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 是否有冰箱抽屉
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private string hasFridge = ConfigurationManager.AppSettings["hasFridge"].ToString().Equals("1") ? "Visible" : "Collapsed";
 | 
				
			||||||
 | 
					        public string HasFridge { get => hasFridge; set => SetProperty(ref hasFridge, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
 | 
					        private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
 | 
				
			||||||
        public bool MultiLogin
 | 
					        public bool MultiLogin
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -51,11 +69,96 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            get { return _selectedChildMenu; }
 | 
					            get { return _selectedChildMenu; }
 | 
				
			||||||
            set
 | 
					            set
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (!_portUtil.Operate)
 | 
					                //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
 | 
				
			||||||
 | 
					                //        {
 | 
				
			||||||
 | 
					                //            if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2"))
 | 
				
			||||||
 | 
					                //            {
 | 
				
			||||||
 | 
					                //                if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
 | 
				
			||||||
 | 
					                //                {
 | 
				
			||||||
 | 
					                //                    _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
 | 
				
			||||||
 | 
					                //                }
 | 
				
			||||||
 | 
					                //                else
 | 
				
			||||||
 | 
					                //                {
 | 
				
			||||||
 | 
					                //                    _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
 | 
				
			||||||
 | 
					                //                }
 | 
				
			||||||
 | 
					                //            }
 | 
				
			||||||
 | 
					                //            else if (value.PremissionPath.Equals("SettingMainWindow") || value.PremissionPath.Equals("SettingWindow"))
 | 
				
			||||||
 | 
					                //            {
 | 
				
			||||||
 | 
					                //                if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
 | 
				
			||||||
 | 
					                //                {
 | 
				
			||||||
 | 
					                //                    _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
 | 
				
			||||||
 | 
					                //                }
 | 
				
			||||||
 | 
					                //                else
 | 
				
			||||||
 | 
					                //                {
 | 
				
			||||||
 | 
					                //                    _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
 | 
				
			||||||
 | 
					                //                }
 | 
				
			||||||
 | 
					                //            }
 | 
				
			||||||
 | 
					                //            else
 | 
				
			||||||
 | 
					                //            {
 | 
				
			||||||
 | 
					                //                _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
 | 
				
			||||||
 | 
					                //            }
 | 
				
			||||||
 | 
					                //        }
 | 
				
			||||||
 | 
					                //    }
 | 
				
			||||||
 | 
					                    SetProperty(ref _selectedChildMenu, value);
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SelectChildNavigate(PremissionDm SelectedChildMenu)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
                    if (value != null)
 | 
					            //if (!_portUtil.Operate)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					                if (SelectedChildMenu != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                        if (value.PremissionPath.Equals("TakeRecordWindow"))
 | 
					                    if (SelectedChildMenu.PremissionPath.Equals("TakeRecordWindow"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        //定义传参变量
 | 
					                        //定义传参变量
 | 
				
			||||||
                        NavigationParameters keys = new NavigationParameters();
 | 
					                        NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
| 
						 | 
					@ -64,7 +167,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        keys.Add("Type", 2);
 | 
					                        keys.Add("Type", 2);
 | 
				
			||||||
                        _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
					                        _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                        else if (value.PremissionPath.Equals("AddRecordWindow"))
 | 
					                    else if (SelectedChildMenu.PremissionPath.Equals("AddRecordWindow"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        //定义传参变量
 | 
					                        //定义传参变量
 | 
				
			||||||
                        NavigationParameters keys = new NavigationParameters();
 | 
					                        NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
| 
						 | 
					@ -73,7 +176,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        keys.Add("Type", 1);
 | 
					                        keys.Add("Type", 1);
 | 
				
			||||||
                        _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
					                        _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                        else if (value.PremissionPath.Equals("ReturnRecordWindow"))
 | 
					                    else if (SelectedChildMenu.PremissionPath.Equals("ReturnRecordWindow"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        //定义传参变量
 | 
					                        //定义传参变量
 | 
				
			||||||
                        NavigationParameters keys = new NavigationParameters();
 | 
					                        NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
| 
						 | 
					@ -82,16 +185,16 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        keys.Add("Type", 3);
 | 
					                        keys.Add("Type", 3);
 | 
				
			||||||
                        _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
					                        _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                        else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow"))
 | 
					                    else if (SelectedChildMenu.PremissionPath.Equals("RetrunEmptyRecordWindow"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        //定义传参变量
 | 
					                        //定义传参变量
 | 
				
			||||||
                        NavigationParameters keys = new NavigationParameters();
 | 
					                        NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        //添加参数,键值对格式
 | 
					                        //添加参数,键值对格式
 | 
				
			||||||
                        keys.Add("Type", 3);
 | 
					                        keys.Add("Type", 3);
 | 
				
			||||||
                            _regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys);
 | 
					                        _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath, keys);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                        else if (value.PremissionPath.Equals("CheckRecordWindow"))
 | 
					                    else if (SelectedChildMenu.PremissionPath.Equals("CheckRecordWindow"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        //定义传参变量
 | 
					                        //定义传参变量
 | 
				
			||||||
                        NavigationParameters keys = new NavigationParameters();
 | 
					                        NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
| 
						 | 
					@ -102,7 +205,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                            if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2"))
 | 
					                        if (SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow") || SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow2"))
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
 | 
					                            if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
| 
						 | 
					@ -113,15 +216,24 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
 | 
					                                _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow"))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                            else
 | 
					                            else
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
 | 
					                                _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                    SetProperty(ref _selectedChildMenu, value);
 | 
					            //}
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public PremissionDm? SelectedMenu
 | 
					        public PremissionDm? SelectedMenu
 | 
				
			||||||
| 
						 | 
					@ -147,30 +259,76 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private DelegateCommand<ListBox> _selectionCommon;
 | 
					        private DelegateCommand _selectionCommon;
 | 
				
			||||||
        public DelegateCommand<ListBox> SelectionCommon
 | 
					        public DelegateCommand SelectionCommon
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => _selectionCommon ?? (_selectionCommon = new DelegateCommand<ListBox>(SelectionMethod));
 | 
					            get => _selectionCommon ?? (_selectionCommon = new DelegateCommand(SelectionMethod));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private void SelectionMethod(ListBox viewName)
 | 
					        private void SelectionMethod()
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            SelectedMenu = viewName.SelectedItem as PremissionDm;
 | 
					 | 
				
			||||||
            if (SelectedMenu.PremissionName == "退出")
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            //SelectedMenu = viewName.SelectedItem as PremissionDm;
 | 
				
			||||||
 | 
					            //if (SelectedMenu.PremissionName == "退出")
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                _chkFunction.HIKStopDVRRecord();
 | 
					            //    _chkFunction.HIKStopDVRRecord();
 | 
				
			||||||
 | 
					            //    logger.Info($"用户【{Operator?.Nickname}】退出登录");
 | 
				
			||||||
 | 
					            //    Operator = null;
 | 
				
			||||||
 | 
					            //    Reviewer = null;
 | 
				
			||||||
 | 
					            //    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //else
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    //SelectedMenu.Children = SelectedMenu.Children;
 | 
				
			||||||
 | 
					            //    //  SelectedChildMenu = SelectedMenu.Children[0];
 | 
				
			||||||
 | 
					            //    if (!_portUtil.Operate)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        _regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            if (SelectedMenu != null && SelectedMenu.PremissionName == "退出")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					                bool allTrue = Array.TrueForAll(boolArrs, b => b);
 | 
				
			||||||
 | 
					                //false是关着,true是开着
 | 
				
			||||||
 | 
					                if (!allTrue)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    logger.Info($"用户【{Operator?.Nickname}】退出登录");
 | 
					                    logger.Info($"用户【{Operator?.Nickname}】退出登录");
 | 
				
			||||||
                    Operator = null;
 | 
					                    Operator = null;
 | 
				
			||||||
                    Reviewer = null;
 | 
					                    Reviewer = null;
 | 
				
			||||||
                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //还有药箱开着不能退出
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "请关闭药箱后再退出系统",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //SelectedMenu.Children = SelectedMenu.Children;
 | 
					                //SelectedMenu.Children = SelectedMenu.Children;
 | 
				
			||||||
                SelectedChildMenu = SelectedMenu.Children[0];
 | 
					                //SelectedChildMenu = SelectedMenu.Children[0];
 | 
				
			||||||
 | 
					                //if (!_portUtil.Operate)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                    _regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        #region 子菜单点击
 | 
				
			||||||
 | 
					        private DelegateCommand _selectionChildCommon;
 | 
				
			||||||
 | 
					        public DelegateCommand SelectionChildCommon
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _selectionChildCommon ?? (_selectionChildCommon = new DelegateCommand(SelectionChildMethod));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SelectionChildMethod()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            SelectChildNavigate(SelectedChildMenu);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
        public List<PremissionDm> PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } }
 | 
					        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 UserList { get { return _userList; } set { SetProperty(ref _userList, value); } }
 | 
				
			||||||
| 
						 | 
					@ -186,16 +344,16 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
 | 
					        public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
        private CHKFunction _chkFunction;
 | 
					        //private CHKFunction _chkFunction;
 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
        public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator,CHKFunction cHKFunction)
 | 
					        public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _portUtil = portUtil;
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
            _regionManager = iRegionManager;
 | 
					            _regionManager = iRegionManager;
 | 
				
			||||||
            _dialogService = dialogService;
 | 
					            _dialogService = dialogService;
 | 
				
			||||||
            _container = container;
 | 
					            _container = container;
 | 
				
			||||||
            this._eventAggregator = eventAggregator;
 | 
					            this._eventAggregator = eventAggregator;
 | 
				
			||||||
            _chkFunction= cHKFunction;
 | 
					            //_chkFunction = cHKFunction;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DelegateCommand<string> OpenFingerDialog
 | 
					        public DelegateCommand<string> OpenFingerDialog
 | 
				
			||||||
| 
						 | 
					@ -208,24 +366,24 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DelegateCommand OpenRecoverCommand
 | 
					        //public DelegateCommand OpenRecoverCommand
 | 
				
			||||||
        {
 | 
					        //{
 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					        //    get => new DelegateCommand(async () =>
 | 
				
			||||||
            {
 | 
					        //    {
 | 
				
			||||||
                try
 | 
					        //        try
 | 
				
			||||||
                {
 | 
					        //        {
 | 
				
			||||||
                    _portUtil.WindowName = "HomeWindow";
 | 
					        //            _portUtil.WindowName = "HomeWindow";
 | 
				
			||||||
                    _portUtil.Operate = true;
 | 
					        //            _portUtil.Operate = true;
 | 
				
			||||||
                    await _portUtil.OpenStorage();
 | 
					        //            await _portUtil.OpenStorage();
 | 
				
			||||||
                    _portUtil.ResetData();
 | 
					        //            _portUtil.ResetData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					        //        }
 | 
				
			||||||
                catch (Exception ex)
 | 
					        //        catch (Exception ex)
 | 
				
			||||||
                {
 | 
					        //        {
 | 
				
			||||||
                    logger.Info($"OpenRecoverCommand异常{ex.Message}");
 | 
					        //            logger.Info($"OpenRecoverCommand异常{ex.Message}");
 | 
				
			||||||
                }
 | 
					        //        }
 | 
				
			||||||
            });
 | 
					        //    });
 | 
				
			||||||
        }
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DelegateCommand<string> OpenEditPasswordDialog
 | 
					        public DelegateCommand<string> OpenEditPasswordDialog
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -262,6 +420,103 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            Is16Drawer = count == 16;
 | 
					            Is16Drawer = count == 16;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 获取温度信息
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        //private async void GetWD(object sender, ElapsedEventArgs e)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    if (!_portUtil.FridgeOperate)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        string retStr = string.Empty;
 | 
				
			||||||
 | 
					        //        byte[] data = null;
 | 
				
			||||||
 | 
					        //        float retT = await _portUtil.GetFridgeTemperature(1);
 | 
				
			||||||
 | 
					        //        Thread.Sleep(80);
 | 
				
			||||||
 | 
					        //        WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃";
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private async void GetWD()
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    if (!_portUtil.FridgeOperate)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        string retStr = string.Empty;
 | 
				
			||||||
 | 
					        //        byte[] data = null;
 | 
				
			||||||
 | 
					        //        float retT = await _portUtil.GetFridgeTemperature(1);
 | 
				
			||||||
 | 
					        //        Thread.Sleep(80);
 | 
				
			||||||
 | 
					        //        WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃;";
 | 
				
			||||||
 | 
					        //        if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
 | 
				
			||||||
 | 
					        //        {
 | 
				
			||||||
 | 
					        //            float retTemp = await _portUtil.GetFridgeTemperature(2);
 | 
				
			||||||
 | 
					        //            Thread.Sleep(80);
 | 
				
			||||||
 | 
					        //            WD += $"{retTemp}℃";
 | 
				
			||||||
 | 
					        //        }
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        //保存温湿度信息
 | 
				
			||||||
 | 
					        private void GetWSD(object sender, ElapsedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            TemperatureHumidityInfo temp = _portUtil.GetWSD();
 | 
				
			||||||
 | 
					            if (temp != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Insertable(new TemperatureHumidityInfo()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    GroupNo = temp.GroupNo,
 | 
				
			||||||
 | 
					                    Temp = temp.Temp,
 | 
				
			||||||
 | 
					                    Humi = temp.Humi,
 | 
				
			||||||
 | 
					                    AddTime = DateTime.Now
 | 
				
			||||||
 | 
					                }).ExecuteCommand();
 | 
				
			||||||
 | 
					                logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info("温湿度信息返回空");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 将收到的返回转换成具体温度数值
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="receiveData"></param>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public string GetResultWD(string receiveData)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //string newStrWD = receiveData.Substring(10, 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //logger.Info($"截取后数据newStrWD:{newStrWD}");
 | 
				
			||||||
 | 
					                int iWD = Convert.ToInt32(receiveData, 16);
 | 
				
			||||||
 | 
					                logger.Info($"截取后数据iWD:{iWD}");
 | 
				
			||||||
 | 
					                float fWD = 0;
 | 
				
			||||||
 | 
					                if (iWD != 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    fWD = iWD * 1.0f / 10;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"截取后数据fWD:{fWD}");
 | 
				
			||||||
 | 
					                string strRet = $"恒温冷藏抽屉当前温度:{fWD}℃;";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return strRet;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info("GetResultWD异常", new Exception($"{ex.ToString()}"));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return "数据异常";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查看冰箱温度
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        //public DelegateCommand CheckWDCommand { get => new DelegateCommand(CheckAction); }
 | 
				
			||||||
 | 
					        //private void CheckAction()
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    GetWD();
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
				
			||||||
| 
						 | 
					@ -272,6 +527,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        //接收导航传过来的参数
 | 
					        //接收导航传过来的参数
 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<LoginOutEvent>().Subscribe(SetLoginOut);
 | 
				
			||||||
            _portUtil.dateTime = DateTime.Now;
 | 
					            _portUtil.dateTime = DateTime.Now;
 | 
				
			||||||
            //取出user
 | 
					            //取出user
 | 
				
			||||||
            UserList = navigationContext.Parameters.GetValue<UserList>("operator");
 | 
					            UserList = navigationContext.Parameters.GetValue<UserList>("operator");
 | 
				
			||||||
| 
						 | 
					@ -289,16 +546,17 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Operator = null;
 | 
					                Operator = null;
 | 
				
			||||||
                Reviewer = null;
 | 
					                Reviewer = null;
 | 
				
			||||||
                Application.Current.Dispatcher.Invoke(() =>
 | 
					                //Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
                {
 | 
					                //{
 | 
				
			||||||
                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
                });
 | 
					                //});
 | 
				
			||||||
                AlertMsg alertMsg = new AlertMsg
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Message = $"用户{UserList.Nickname}或还未设置权限,请联系管理员",
 | 
					                    Message = $"用户{UserList.Nickname}或还未设置权限,请联系管理员",
 | 
				
			||||||
                    Type = MsgType.ERROR
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            //SqlSugarHelper.Db.SqlQueryable<PremissionDm>(sql)
 | 
					            //SqlSugarHelper.Db.SqlQueryable<PremissionDm>(sql)
 | 
				
			||||||
| 
						 | 
					@ -306,36 +564,84 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            PremissionDmList = premissions;
 | 
					            PremissionDmList = premissions;
 | 
				
			||||||
            SelectedMenu = premissions[0];
 | 
					            SelectedMenu = premissions[0];
 | 
				
			||||||
            SelectedChildMenu = premissions[0].Children[0];
 | 
					            SelectedChildMenu = premissions[0].Children[0];
 | 
				
			||||||
 | 
					            _regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
 | 
				
			||||||
            FindDrawerCount();
 | 
					            FindDrawerCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
					            int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
				
			||||||
            if (autoExit > 0)
 | 
					            int stopRecord = Convert.ToInt32(ConfigurationManager.AppSettings["stopRecord"] ?? "0");
 | 
				
			||||||
 | 
					            //if (autoExit > 0)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    System.Timers.Timer timer = new System.Timers.Timer();
 | 
				
			||||||
 | 
					            //    timer.Interval = 100;
 | 
				
			||||||
 | 
					            //    timer.Elapsed += (sender, e) =>
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        // 串口无人操作
 | 
				
			||||||
 | 
					            //        bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					            //        bool allTrue =  Array.TrueForAll(boolArrs, b => b==false);
 | 
				
			||||||
 | 
					            //        logger.Info($"进入自动退出定时方法{allTrue}");
 | 
				
			||||||
 | 
					            //        //false是关着,true是开着
 | 
				
			||||||
 | 
					            //        if (allTrue)
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            //PerformanceCounter pc = new PerformanceCounter("System", "% Idle Time", true);
 | 
				
			||||||
 | 
					            //            //float systemIdleTime = pc.NextValue();
 | 
				
			||||||
 | 
					            //            //Console.WriteLine($"systemIdleTime:{systemIdleTime}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //            //// 获取系统空闲时间
 | 
				
			||||||
 | 
					            //            //TimeSpan idleTime = SystemInformation.IdleTime;
 | 
				
			||||||
 | 
					            //            //// 打印空闲时间
 | 
				
			||||||
 | 
					            //            //Console.WriteLine("系统空闲时间: " + idleTime.ToString());
 | 
				
			||||||
 | 
					            //            long lTime = CheckComputerFreeState.GetLastInputTime(); 
 | 
				
			||||||
 | 
					            //            logger.Info($"自动退出时间{lTime}");
 | 
				
			||||||
 | 
					            //            // 30秒内无人操作鼠标键盘
 | 
				
			||||||
 | 
					            //            //if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
 | 
				
			||||||
 | 
					            //            if (lTime > autoExit)
 | 
				
			||||||
 | 
					            //            {
 | 
				
			||||||
 | 
					            //                logger.Info($"设备{autoExit}秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
 | 
				
			||||||
 | 
					            //                _chkFunction.HIKStopDVRRecord();
 | 
				
			||||||
 | 
					            //                Operator = null;
 | 
				
			||||||
 | 
					            //                Reviewer = null;
 | 
				
			||||||
 | 
					            //                Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
 | 
					            //                {
 | 
				
			||||||
 | 
					            //                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					            //                    timer.Stop();
 | 
				
			||||||
 | 
					            //                });
 | 
				
			||||||
 | 
					            //            }
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //    };
 | 
				
			||||||
 | 
					            //    timer.Start();
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            #region 温度查询定时
 | 
				
			||||||
 | 
					            int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
 | 
				
			||||||
 | 
					            if (interval > 0)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Timer timer = new Timer();
 | 
					                WSDTimer = new System.Timers.Timer();
 | 
				
			||||||
                timer.Interval = 1000;
 | 
					
 | 
				
			||||||
                timer.Elapsed += (sender, e) =>
 | 
					                WSDTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetWSD);
 | 
				
			||||||
                {
 | 
					                WSDTimer.Interval = interval;
 | 
				
			||||||
                    // 串口无人操作
 | 
					                WSDTimer.Start();
 | 
				
			||||||
                    if (!_portUtil.Operate)
 | 
					                //WDTimer.AutoReset = true;
 | 
				
			||||||
                    {
 | 
					                //WDTimer.Enabled = true;
 | 
				
			||||||
                        // 30秒内无人操作鼠标键盘
 | 
					 | 
				
			||||||
                        if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
 | 
					 | 
				
			||||||
                            _chkFunction.HIKStopDVRRecord();
 | 
					 | 
				
			||||||
                            Operator = null;
 | 
					 | 
				
			||||||
                            Reviewer = null;
 | 
					 | 
				
			||||||
                            Application.Current.Dispatcher.Invoke(() =>
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					 | 
				
			||||||
                                timer.Stop();
 | 
					 | 
				
			||||||
                            });
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
                    }
 | 
					            #endregion
 | 
				
			||||||
                };
 | 
					            //if (stopRecord > 0)
 | 
				
			||||||
                timer.Start();
 | 
					            //{
 | 
				
			||||||
            }
 | 
					            //    System.Timers.Timer timer = new System.Timers.Timer();
 | 
				
			||||||
            _chkFunction.HIKStartDVRRecord();
 | 
					            //    timer.Interval = 1000;
 | 
				
			||||||
 | 
					            //    timer.Elapsed += (sender, e) =>
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //        //指定时间内无人操作鼠标键盘则停止录像
 | 
				
			||||||
 | 
					            //        if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord)
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            _chkFunction.HIKStopDVRRecord();
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //    };
 | 
				
			||||||
 | 
					            //    timer.Start();
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //logger.Info($"当前时间:{DateTime.Now}\r\n获取录像机的时间");
 | 
				
			||||||
 | 
					            ////获取录像机的时间
 | 
				
			||||||
 | 
					            //_chkFunction.HIK_DVR_TIME();
 | 
				
			||||||
 | 
					            //_chkFunction.HIKStartDVRRecord();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
					        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
				
			||||||
| 
						 | 
					@ -347,7 +653,19 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        //这个方法用于拦截请求
 | 
					        //这个方法用于拦截请求
 | 
				
			||||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            //退了登录
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<LoginOutEvent>().Unsubscribe(SetLoginOut);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SetLoginOut()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //_chkFunction.HIKStopDVRRecord();
 | 
				
			||||||
 | 
					            Operator = null;
 | 
				
			||||||
 | 
					            Reviewer = null;
 | 
				
			||||||
 | 
					            //Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					            //});
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,356 +0,0 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using DM_Weight.Views;
 | 
					 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class InvoiceAddDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceAddDialogViewModel));
 | 
					 | 
				
			||||||
        public string Title => "调拨加药";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string WindowName = "InvoiceAddWindow";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public InvoiceAddDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (msg.WindowName.Equals(WindowName))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
                int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 1)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 2)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
					 | 
				
			||||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
					 | 
				
			||||||
                            if (enumerator.MoveNext())
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
					 | 
				
			||||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
					 | 
				
			||||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Thread.Sleep(50);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                OpenOneByOne();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            // 已经全部取出
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Status = 3;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _status; set => SetProperty(ref _status, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        private Invoice? _invoic;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public Invoice? Invoice
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _invoic;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _invoic, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
					 | 
				
			||||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return Status == 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = parameters.GetValue<List<ChannelStock>>("ChannelStocks");
 | 
					 | 
				
			||||||
            Invoice o = parameters.GetValue<Invoice>("invoice");
 | 
					 | 
				
			||||||
            Invoice = o;
 | 
					 | 
				
			||||||
            ChannelStocks = channelStocks;
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
					 | 
				
			||||||
            enumerator = enumerable.GetEnumerator();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand OpenDrawer
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status == 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    enumerator.MoveNext();
 | 
					 | 
				
			||||||
                    Status = 1;
 | 
					 | 
				
			||||||
                    OpenOneByOne();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private async void OpenOneByOne()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            _portUtil.WindowName = WindowName;
 | 
					 | 
				
			||||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
					 | 
				
			||||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
					 | 
				
			||||||
            _portUtil.DrawerNo = DrawerNo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 发送加药数量
 | 
					 | 
				
			||||||
                singleChannels.ForEach(it =>
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.AddQuantity, it.Quantity + it.AddQuantity);
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 6)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                for (int i = 0; i < singleChannels.Count; i++)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    ChannelStock it = singleChannels[i];
 | 
					 | 
				
			||||||
                    _portUtil.ClearCount(it.DrawerNo, it.ColNo);
 | 
					 | 
				
			||||||
                    await Task.Delay(50);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            _portUtil.Start();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isFinishClick = false;
 | 
					 | 
				
			||||||
        // 完成按钮
 | 
					 | 
				
			||||||
        public DelegateCommand TakeFinish
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!_isFinishClick)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _isFinishClick = true;
 | 
					 | 
				
			||||||
                    List<ChannelStock> record = ChannelStocks.ToList();
 | 
					 | 
				
			||||||
                    string InvoiceId = Invoice.InvoiceNo;
 | 
					 | 
				
			||||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        SqlSugarHelper.Db.Updateable(new InOutInvoice()
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 1,
 | 
					 | 
				
			||||||
                            InvoiceNo = Invoice.InvoiceNo
 | 
					 | 
				
			||||||
                        }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        for (int i = 0; i < record.Count; i++)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            ChannelStock it = record[i];
 | 
					 | 
				
			||||||
                            if (it.BoardType == 6 && it.PosNo == 0)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            // 更新数据 库存信息
 | 
					 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Quantity = it.Quantity + it.AddQuantity,
 | 
					 | 
				
			||||||
                                PosNo = 1,
 | 
					 | 
				
			||||||
                                ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                EffDate = it.EffDate,
 | 
					 | 
				
			||||||
                                Id = it.Id,
 | 
					 | 
				
			||||||
                            }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
                            // 获取更新完库存后的药品库存
 | 
					 | 
				
			||||||
                            List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                                .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
					 | 
				
			||||||
                                .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
					 | 
				
			||||||
                                .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                                .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            // 保存数据 出/入库记录
 | 
					 | 
				
			||||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                MachineId = it.MachineId,
 | 
					 | 
				
			||||||
                                DrawerNo = it.DrawerNo,
 | 
					 | 
				
			||||||
                                ColNo = it.ColNo,
 | 
					 | 
				
			||||||
                                DrugId = it.DrugId,
 | 
					 | 
				
			||||||
                                ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
					 | 
				
			||||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                Quantity = it.AddQuantity,
 | 
					 | 
				
			||||||
                                Type = 1,
 | 
					 | 
				
			||||||
                                InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                                StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                            }).ExecuteCommand();
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        return true;
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                    if (f.Data)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        // 更新屏显库存
 | 
					 | 
				
			||||||
                        List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
                        if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            singleChannels.ForEach(it =>
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
 | 
					 | 
				
			||||||
                            });
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "操作完成,库存已更新",
 | 
					 | 
				
			||||||
                            Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    if (!f.IsSuccess)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "库存更新失败!",
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    Status = 0;
 | 
					 | 
				
			||||||
                    _isFinishClick = false;
 | 
					 | 
				
			||||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public long CurrentTimeMillis()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 取消按钮
 | 
					 | 
				
			||||||
        public DelegateCommand CancleTake
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
                _portUtil.ResetData();
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BtnCloseCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status != 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _portUtil.ResetData();
 | 
					 | 
				
			||||||
                    Status = 0;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                //DialogParameters parameters = new DialogParameters();
 | 
					 | 
				
			||||||
                //parameters.Add("",);
 | 
					 | 
				
			||||||
                // 关闭当前窗口
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,384 +0,0 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Collections.ObjectModel;
 | 
					 | 
				
			||||||
using System.ComponentModel;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Linq.Expressions;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows.Data;
 | 
					 | 
				
			||||||
using System.Windows.Markup;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class InvoiceInWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceInWindowViewModel));
 | 
					 | 
				
			||||||
        private int _pageNum = 1;
 | 
					 | 
				
			||||||
        public int PageNum
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageNum;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageNum, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageCount = 1;
 | 
					 | 
				
			||||||
        public int PageCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageSize = 8;
 | 
					 | 
				
			||||||
        public int PageSize
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageSize;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageSize, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _totalCount = 0;
 | 
					 | 
				
			||||||
        public int TotalCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _totalCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _totalCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private DelegateCommand _rowSelected;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(GetChannelByInvoice);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public InvoiceInWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "invoiceNo",
 | 
					 | 
				
			||||||
                Name = "凭证单号"
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderTakeSelects; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _orderTakeSelects, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public OrderTakeSelect SelectedItem
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedItem; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedItem, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private Invoice? _selectedInvoice;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public Invoice? SelectedInvoice
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedInvoice; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedInvoice, value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //OpenOrderDialog();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件  处方日期
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string OrderDate
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderDate; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!String.IsNullOrEmpty(value))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, value);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string? _searchValue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段值
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string? SearchValue
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _searchValue; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _searchValue, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<Invoice> _invoices = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<Invoice> Invoices { get { return _invoices; } set { SetProperty(ref _invoices, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<InOutInvoice> _inOutInvoices = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<InOutInvoice> InOutInvoices { get { return _inOutInvoices; } set { SetProperty(ref _inOutInvoices, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _addChannels = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> AddChannels { get { return _addChannels; } set { SetProperty(ref _addChannels, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void GetChannelByInvoice()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            ChannelStocks.Clear();
 | 
					 | 
				
			||||||
            InOutInvoices.Clear();
 | 
					 | 
				
			||||||
            List<ChannelStock> i = new List<ChannelStock>();
 | 
					 | 
				
			||||||
            if (SelectedInvoice != null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                var invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
 | 
					 | 
				
			||||||
                                .Includes<DrugInfo>(i => i.DrugInfo)
 | 
					 | 
				
			||||||
                                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId)
 | 
					 | 
				
			||||||
                                .Where(i => i.InvoiceNo == SelectedInvoice.InvoiceNo)
 | 
					 | 
				
			||||||
                                .ToList();
 | 
					 | 
				
			||||||
                foreach (var invoice in invoices)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
 | 
					 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
 | 
					 | 
				
			||||||
                    .Where(cs => cs.DrugId == invoice.DrugId)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                    .OrderBy(cs => cs.DrugId)
 | 
					 | 
				
			||||||
                    .OrderBy(cs => cs.DrawerNo)
 | 
					 | 
				
			||||||
                    .OrderBy(cs => cs.ColNo)
 | 
					 | 
				
			||||||
                    .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    for (int j = 0; j < q.Count;j++)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        ChannelStock item = q[j];
 | 
					 | 
				
			||||||
                        if(j == 0)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            item.AddQuantity = invoice.quantity;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        item.Invoice = invoice;
 | 
					 | 
				
			||||||
                        i.Add(item);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    InOutInvoice copy = TransExpV2<InOutInvoice, InOutInvoice>.Trans(invoice);
 | 
					 | 
				
			||||||
                    InOutInvoices.Add(copy);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            ICollectionView vw = CollectionViewSource.GetDefaultView(i);
 | 
					 | 
				
			||||||
            vw.GroupDescriptions.Add(new PropertyGroupDescription("Invoice"));
 | 
					 | 
				
			||||||
            ChannelStocks = i;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand OpenInvoiceAdd
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                bool flag = true;
 | 
					 | 
				
			||||||
                for (int i = 0; i < InOutInvoices.Count; i++)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    InOutInvoice invoices = InOutInvoices[i];
 | 
					 | 
				
			||||||
                    if (invoices.quantity != ChannelStocks.FindAll(it => it.DrugId == invoices.DrugId).Sum(it => it.AddQuantity))
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        flag = false;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (flag)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0);
 | 
					 | 
				
			||||||
                    AddChannels.Sort((a, b) =>
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            return a.ColNo - b.ColNo;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        return a.DrawerNo - b.DrawerNo;
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                    OpenOrderDialog();
 | 
					 | 
				
			||||||
                } else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        Message = "库位添加数量小于应添加数量",
 | 
					 | 
				
			||||||
                        Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                    };
 | 
					 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            },() => SelectedInvoice !=null).ObservesProperty(() => SelectedInvoice);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async void OpenOrderDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (SelectedInvoice != null && SelectedInvoice.Status == 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 此处延时1毫秒,等待页面渲染
 | 
					 | 
				
			||||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("invoice", SelectedInvoice);
 | 
					 | 
				
			||||||
                dialogParameters.Add("ChannelStocks", AddChannels);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceAddDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand QueryCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 委托   被动执行     被子窗口执行
 | 
					 | 
				
			||||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
					 | 
				
			||||||
            //if (dialogResult.Result == ButtonResult.OK)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SelectedInvoice = null;
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Invoices.Clear();
 | 
					 | 
				
			||||||
            int totalCount = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var sb = new StringBuilder();
 | 
					 | 
				
			||||||
            sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
 | 
					 | 
				
			||||||
            sb.Append(" inner join ( select c.drug_id as drug_id from channel_stock c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
 | 
					 | 
				
			||||||
            sb.Append(" left join pharmacy_info p1 on p1.pharmacy_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)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,270 +0,0 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using Newtonsoft.Json;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class InvoiceOutWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageNum = 1;
 | 
					 | 
				
			||||||
        public int PageNum
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageNum;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageNum, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageCount = 1;
 | 
					 | 
				
			||||||
        public int PageCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageSize = 8;
 | 
					 | 
				
			||||||
        public int PageSize
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageSize;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageSize, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _totalCount = 0;
 | 
					 | 
				
			||||||
        public int TotalCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _totalCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _totalCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private DelegateCommand _rowSelected;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public InvoiceOutWindowViewModel(IDialogService DialogService)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "invoiceNo",
 | 
					 | 
				
			||||||
                Name = "凭证单号"
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderTakeSelects; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _orderTakeSelects, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public OrderTakeSelect SelectedItem
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedItem; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedItem, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private Invoice? _selectedInvoice;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public Invoice? SelectedInvoice
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedInvoice; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedInvoice, value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //OpenOrderDialog();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件  处方日期
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string OrderDate
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderDate; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!String.IsNullOrEmpty(value))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, value);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string? _searchValue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段值
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string? SearchValue
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _searchValue; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _searchValue, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<Invoice> _invoices = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<Invoice> Invoices { get { return _invoices; } set { SetProperty(ref _invoices, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async void OpenOrderDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (SelectedInvoice != null && SelectedInvoice.Status == 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 此处延时1毫秒,等待页面渲染
 | 
					 | 
				
			||||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("invoice", SelectedInvoice);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand QueryCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 委托   被动执行     被子窗口执行
 | 
					 | 
				
			||||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
					 | 
				
			||||||
            //if (dialogResult.Result == ButtonResult.OK)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SelectedInvoice = null;
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Invoices.Clear();
 | 
					 | 
				
			||||||
            int totalCount = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var sb = new StringBuilder();
 | 
					 | 
				
			||||||
            sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
 | 
					 | 
				
			||||||
            sb.Append(" inner join ( select c.drug_id as drug_id from channel_stock c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
 | 
					 | 
				
			||||||
            sb.Append(" left join pharmacy_info p1 on p1.pharmacy_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)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,426 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Microsoft.Xaml.Behaviors;
 | 
					 | 
				
			||||||
using NetTaste;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using System.Threading;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class InvoiceTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceTakeDialogViewModel));
 | 
					 | 
				
			||||||
        public string Title => "调拨出库";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public InvoiceTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (msg.WindowName == "InvoiceTakeDrugWindow")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
                int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 1)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 2)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
					 | 
				
			||||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
					 | 
				
			||||||
                            if (enumerator.MoveNext())
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
					 | 
				
			||||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
					 | 
				
			||||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Thread.Sleep(50);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                OpenOneByOne();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            // 已经全部取出
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Status = 3;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _status; set => SetProperty(ref _status, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private Invoice? _invoic;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public Invoice? Invoice
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _invoic;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _invoic, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<InOutInvoice> invoices { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
					 | 
				
			||||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return Status == 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            Invoice o = parameters.GetValue<Invoice>("invoice");
 | 
					 | 
				
			||||||
            Invoice = o;
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
 | 
					 | 
				
			||||||
                .Includes<DrugInfo>(i => i.DrugInfo)
 | 
					 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs =>cs.DrugId),(i,t) => i.DrugId == t.DrugId)
 | 
					 | 
				
			||||||
                .Where(i => i.InvoiceNo == Invoice.InvoiceNo)
 | 
					 | 
				
			||||||
                .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
					 | 
				
			||||||
            List<string> msg = new List<string>();
 | 
					 | 
				
			||||||
            for (int i = 0; i < invoices.Count; i++)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                InOutInvoice invoice = invoices[i];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.Quantity > 0)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
 | 
					 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
 | 
					 | 
				
			||||||
                    .Where(cs => cs.DrugId == invoice.DrugId)
 | 
					 | 
				
			||||||
                    .OrderBy(cs => cs.EffDate)
 | 
					 | 
				
			||||||
                    .ToList();
 | 
					 | 
				
			||||||
                int total = HasQChannels.Sum(it => it.Quantity);
 | 
					 | 
				
			||||||
                int TakeQ = invoice.quantity;
 | 
					 | 
				
			||||||
                // 说明数量足够
 | 
					 | 
				
			||||||
                if (total >= TakeQ)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    for (int j = 0; TakeQ > 0; j++)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        ChannelStock stock = HasQChannels[j];
 | 
					 | 
				
			||||||
                        if (TakeQ > stock.Quantity)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            stock.TakeQuantity = stock.Quantity;
 | 
					 | 
				
			||||||
                            channelStocks.Add(stock);
 | 
					 | 
				
			||||||
                            TakeQ -= stock.Quantity;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        else
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            stock.TakeQuantity = TakeQ;
 | 
					 | 
				
			||||||
                            channelStocks.Add(stock);
 | 
					 | 
				
			||||||
                            TakeQ = 0;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    msg.Add($"药品【{invoice.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if(msg.Count > 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
                //MessageBox.Show(string.Join("\n", msg));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("msgInfo", msg);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                channelStocks.Sort((a, b) =>
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        return a.ColNo - b.ColNo;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    return a.DrawerNo - b.DrawerNo;
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
                ChannelStocks = channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand OpenDrawer
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status == 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
					 | 
				
			||||||
                    enumerator = enumerable.GetEnumerator();
 | 
					 | 
				
			||||||
                    enumerator.MoveNext();
 | 
					 | 
				
			||||||
                    Status = 1;
 | 
					 | 
				
			||||||
                    OpenOneByOne();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void OpenOneByOne()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					 | 
				
			||||||
            _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 = "InvoiceTakeDrugWindow";
 | 
					 | 
				
			||||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
					 | 
				
			||||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
					 | 
				
			||||||
            _portUtil.DrawerNo = DrawerNo;
 | 
					 | 
				
			||||||
            _portUtil.Start();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isFinishClick = false;
 | 
					 | 
				
			||||||
        // 完成按钮
 | 
					 | 
				
			||||||
        public DelegateCommand TakeFinish
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!_isFinishClick)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _isFinishClick = true;
 | 
					 | 
				
			||||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
					 | 
				
			||||||
                    if (record.Count > 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        string InvoiceId = Invoice.InvoiceNo;
 | 
					 | 
				
			||||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable(new InOutInvoice()
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Status = 1,
 | 
					 | 
				
			||||||
                                InvoiceNo = Invoice.InvoiceNo
 | 
					 | 
				
			||||||
                            }).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            for (int i = 0; i < record.Count; i++)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                ChannelStock it = record[i];
 | 
					 | 
				
			||||||
                                // 更新数据 库存信息
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
					 | 
				
			||||||
                                    ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = it.EffDate,
 | 
					 | 
				
			||||||
                                    Id = it.Id,
 | 
					 | 
				
			||||||
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                // 获取更新完库存后的药品库存
 | 
					 | 
				
			||||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                                    .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                // 保存数据 出库记录
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    MachineId = it.MachineId,
 | 
					 | 
				
			||||||
                                    DrawerNo = it.DrawerNo,
 | 
					 | 
				
			||||||
                                    ColNo = it.ColNo,
 | 
					 | 
				
			||||||
                                    DrugId = it.DrugId,
 | 
					 | 
				
			||||||
                                    ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
					 | 
				
			||||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                    OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                    Quantity = it.TakeQuantity,
 | 
					 | 
				
			||||||
                                    Type = 2,
 | 
					 | 
				
			||||||
                                    InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                                    StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                                }).ExecuteCommand();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -54,10 +54,18 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            //get => loginMode == 2;
 | 
					            //get => loginMode == 2;
 | 
				
			||||||
            get => ReadAppSetting("loginMode") == "2";
 | 
					            get => ReadAppSetting("loginMode") == "2";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string LoginUserCheck
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            get => ReadAppSetting("loginUser");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private HkcChangeShifts listHkcChangeShifts=new HkcChangeShifts();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private FingerprintUtil _fingerprintUtil;
 | 
					        private FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
        private CHKFunction _chkFunction;
 | 
					        //private CHKFunction _chkFunction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Boolean LoginBtnEnable { get { return _loginBtnEnable; } set { SetProperty(ref _loginBtnEnable, value); } }
 | 
					        public Boolean LoginBtnEnable { get { return _loginBtnEnable; } set { SetProperty(ref _loginBtnEnable, value); } }
 | 
				
			||||||
        public string Password { get { return password; } set { SetProperty(ref password, value); } }
 | 
					        public string Password { get { return password; } set { SetProperty(ref password, value); } }
 | 
				
			||||||
| 
						 | 
					@ -67,14 +75,14 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        public UserList Operator { get; set; }
 | 
					        public UserList Operator { get; set; }
 | 
				
			||||||
        public UserList Reviewer { get; set; }
 | 
					        public UserList Reviewer { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool DrawerPortMsg
 | 
					        //public bool DrawerPortMsg
 | 
				
			||||||
        {
 | 
					        //{
 | 
				
			||||||
            get => !_portUtil.drawerSerial.IsOpen;
 | 
					        //    get => !_portUtil.drawerSerial.IsOpen;
 | 
				
			||||||
        }
 | 
					        //}
 | 
				
			||||||
        public bool CanBusPortMsg
 | 
					        //public bool CanBusPortMsg
 | 
				
			||||||
        {
 | 
					        //{
 | 
				
			||||||
            get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
 | 
					        //    get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
 | 
				
			||||||
        }
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private bool _fingerMsg= CHKFunction.HKUserId>=0;
 | 
					        private bool _fingerMsg= CHKFunction.HKUserId>=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,6 +91,15 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            get => _fingerMsg;
 | 
					            get => _fingerMsg;
 | 
				
			||||||
            set => SetProperty(ref _fingerMsg, value);
 | 
					            set => SetProperty(ref _fingerMsg, value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        //public bool FridgePortMsg
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => !_portUtil.fridgeSerial.IsOpen;
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        //温湿度
 | 
				
			||||||
 | 
					        public bool WSDPortMsg
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => !_portUtil.wsdSerial.IsOpen;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        //录像机登录状态
 | 
					        //录像机登录状态
 | 
				
			||||||
        private bool _hikMsg;
 | 
					        private bool _hikMsg;
 | 
				
			||||||
        public bool HIKMsg
 | 
					        public bool HIKMsg
 | 
				
			||||||
| 
						 | 
					@ -98,13 +115,15 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        //    _regionManager = regionManager;
 | 
					        //    _regionManager = regionManager;
 | 
				
			||||||
        //    _eventAggregator = eventAggregator;
 | 
					        //    _eventAggregator = eventAggregator;
 | 
				
			||||||
        //}
 | 
					        //}
 | 
				
			||||||
        public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, CHKFunction chcFunction)
 | 
					        public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //_fingerprintUtil = fingerprintUtil;
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
            _portUtil = portUtil;
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
            _chkFunction= chcFunction;
 | 
					            //_chkFunction= chcFunction;
 | 
				
			||||||
            _regionManager = regionManager;
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					             FingerMsg = !_fingerprintUtil.bIsConnected;
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private DelegateCommand? _loginCommand;
 | 
					        private DelegateCommand? _loginCommand;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -155,7 +174,7 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        .Includes<RoleDm>(u => u.Role)
 | 
					                                        .Includes<RoleDm>(u => u.Role)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        .First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
 | 
					                                        .First(u => u.UserName == username && (ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId)));
 | 
				
			||||||
                    if (userList == null)
 | 
					                    if (userList == null)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
| 
						 | 
					@ -180,6 +199,29 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
 | 
					                        //1仅当班人、审核人可登录
 | 
				
			||||||
 | 
					                        if (LoginUserCheck.Equals("1"))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //检查当前登录人是否是值班人 (审核人与发药人)
 | 
				
			||||||
 | 
					                            listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
 | 
				
			||||||
 | 
					                               .Where(cs => cs.State == "0").First();
 | 
				
			||||||
 | 
					                            if (listHkcChangeShifts != null)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                if(!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        Message = "仅值班人可登录,当前登录人非值班人",
 | 
				
			||||||
 | 
					                                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                                    };
 | 
				
			||||||
 | 
					                                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                                    Username = "";
 | 
				
			||||||
 | 
					                                    Password = "";
 | 
				
			||||||
 | 
					                                    return;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        if (userList.PassWord == MD5.GetMD5Hash(Password))
 | 
					                        if (userList.PassWord == MD5.GetMD5Hash(Password))
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -219,10 +261,10 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //添加参数,键值对格式
 | 
					                //添加参数,键值对格式
 | 
				
			||||||
                keys.Add("operator", user);
 | 
					                keys.Add("operator", user);
 | 
				
			||||||
                System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
					                //System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
                {
 | 
					                //{
 | 
				
			||||||
                    _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
					                    _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
                }));
 | 
					                //}));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // 双人登录模式
 | 
					            // 双人登录模式
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
| 
						 | 
					@ -235,10 +277,10 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                        keys.Add("reviewer", user);
 | 
					                        keys.Add("reviewer", user);
 | 
				
			||||||
                        Reviewer = user;
 | 
					                        Reviewer = user;
 | 
				
			||||||
                        RaisePropertyChanged("Reviewer");
 | 
					                        RaisePropertyChanged("Reviewer");
 | 
				
			||||||
                        System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
					                        //System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
                        {
 | 
					                        //{
 | 
				
			||||||
                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
					                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
                        }));
 | 
					                        //}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
| 
						 | 
					@ -259,10 +301,10 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                        keys.Add("operator", user);
 | 
					                        keys.Add("operator", user);
 | 
				
			||||||
                        Operator = user;
 | 
					                        Operator = user;
 | 
				
			||||||
                        RaisePropertyChanged("Operator");
 | 
					                        RaisePropertyChanged("Operator");
 | 
				
			||||||
                        System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
					                        //System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
                        {
 | 
					                        //{
 | 
				
			||||||
                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
					                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
                        }));
 | 
					                        //}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
| 
						 | 
					@ -278,6 +320,28 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                // 第一个用户登录
 | 
					                // 第一个用户登录
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    //1仅当班人、审核人可登录
 | 
				
			||||||
 | 
					                    if (LoginUserCheck.Equals("1"))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if(listHkcChangeShifts!=null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if(listHkcChangeShifts.FromOperator.Equals(user.UserName))
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                keys.Add("operator", user);
 | 
				
			||||||
 | 
					                                Operator = user;
 | 
				
			||||||
 | 
					                                RaisePropertyChanged("Operator");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                keys.Add("reviewer", user);
 | 
				
			||||||
 | 
					                                Reviewer = user;
 | 
				
			||||||
 | 
					                                RaisePropertyChanged("Reviewer");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            Username = string.Empty;
 | 
				
			||||||
 | 
					                            Password = string.Empty;
 | 
				
			||||||
 | 
					                            return;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    if (firstLogin.Equals("operator"))
 | 
					                    if (firstLogin.Equals("operator"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        keys.Add("operator", user);
 | 
					                        keys.Add("operator", user);
 | 
				
			||||||
| 
						 | 
					@ -298,7 +362,7 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void Exit()
 | 
					        void Exit()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _chkFunction.HIKLoginOut();
 | 
					            //_chkFunction.HIKLoginOut();
 | 
				
			||||||
            Process.GetCurrentProcess().Kill();
 | 
					            Process.GetCurrentProcess().Kill();
 | 
				
			||||||
            Environment.Exit(0);
 | 
					            Environment.Exit(0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -343,6 +407,29 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
 | 
					                        //1仅当班人、审核人可登录
 | 
				
			||||||
 | 
					                        if (LoginUserCheck.Equals("1"))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //检查当前登录人是否是值班人 (审核人与发药人)
 | 
				
			||||||
 | 
					                            listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
 | 
				
			||||||
 | 
					                               .Where(cs => cs.State == "0").First();
 | 
				
			||||||
 | 
					                            if (listHkcChangeShifts != null)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        Message = "仅值班人可登录,当前登录人非值班人",
 | 
				
			||||||
 | 
					                                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                                    };
 | 
				
			||||||
 | 
					                                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                                    Username = "";
 | 
				
			||||||
 | 
					                                    Password = "";
 | 
				
			||||||
 | 
					                                    return;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        SetUser(userList);
 | 
					                        SetUser(userList);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -361,8 +448,8 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
					        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            FingerMsg = false;// !_fingerprintUtil.bIsConnected;
 | 
					            //FingerMsg = !_fingerprintUtil.bIsConnected;
 | 
				
			||||||
            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
 | 
					            //_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,26 +1,20 @@
 | 
				
			||||||
using Prism.Commands;
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
using Prism.Mvvm;
 | 
					using Prism.Mvvm;
 | 
				
			||||||
using Prism.Regions;
 | 
					using Prism.Regions;
 | 
				
			||||||
using SqlSugar;
 | 
					using SqlSugar;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Globalization;
 | 
					using System.Configuration;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.Report;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using gregn6Lib;
 | 
					 | 
				
			||||||
using Newtonsoft.Json;
 | 
					 | 
				
			||||||
using System.IO;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class MachineRecordWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					    internal class MachineRecordWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
				
			||||||
    { 
 | 
					    { 
 | 
				
			||||||
        private int _pageNum = 1;
 | 
					        private int _pageNum = 1;
 | 
				
			||||||
        public int PageNum
 | 
					        public int PageNum
 | 
				
			||||||
| 
						 | 
					@ -72,7 +66,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                if (value != null)
 | 
					                if (value != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
 | 
					                    SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
 | 
				
			||||||
                } else
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    SetProperty(ref _startDate, value);
 | 
					                    SetProperty(ref _startDate, value);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -85,7 +80,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        public DateTime? EndDate
 | 
					        public DateTime? EndDate
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => _endDate;
 | 
					            get => _endDate;
 | 
				
			||||||
            set{
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
                if (value != null)
 | 
					                if (value != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    TimeSpan ershisi = new TimeSpan(23, 59, 59);
 | 
					                    TimeSpan ershisi = new TimeSpan(23, 59, 59);
 | 
				
			||||||
| 
						 | 
					@ -99,18 +95,6 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                RequestData();
 | 
					                RequestData();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _type;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Type
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _type; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _type, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<MachineRecord>? machineRecords;
 | 
					        private List<MachineRecord>? machineRecords;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public List<MachineRecord>? MachineRecords
 | 
					        public List<MachineRecord>? MachineRecords
 | 
				
			||||||
| 
						 | 
					@ -118,14 +102,6 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            get { return machineRecords; }
 | 
					            get { return machineRecords; }
 | 
				
			||||||
            set { SetProperty(ref machineRecords, value); }
 | 
					            set { SetProperty(ref machineRecords, value); }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        public MachineRecordWindowViewModel()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand Query
 | 
					        public DelegateCommand Query
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
| 
						 | 
					@ -133,77 +109,36 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                RequestData();
 | 
					                RequestData();
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DelegateCommand Download
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                GridReportUtil.PrintReportMechineRecord(Type, StartDate, EndDate);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public DelegateCommand DownloadAccountBook
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                GridReportUtil.PrintReportAccountBook(StartDate, EndDate);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        void ReportInitialize()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //接收导航传过来的参数
 | 
					 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            //取出Type决定页面显示内容
 | 
					 | 
				
			||||||
            Type = navigationContext.Parameters.GetValue<int>("Type");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //查询表格数据
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
     
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            int totalCount = 0;
 | 
					 | 
				
			||||||
            string machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
 | 
					 | 
				
			||||||
            MachineRecords = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
					 | 
				
			||||||
                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
					 | 
				
			||||||
                .Includes<UserList>(mr => mr.User)
 | 
					 | 
				
			||||||
                .Where(mr => mr.MachineId == machineId)
 | 
					 | 
				
			||||||
                .WhereIF(Type == 3, (mr) => new int[] { 31, 32 }.Contains(mr.Type))
 | 
					 | 
				
			||||||
                .WhereIF(Type != 3, (mr) => mr.Type == Type )
 | 
					 | 
				
			||||||
                .WhereIF(StartDate !=null, (mr) => mr.OperationTime > StartDate)
 | 
					 | 
				
			||||||
                .WhereIF(EndDate!=null, (mr) => mr.OperationTime < EndDate)
 | 
					 | 
				
			||||||
                //.Select(mr => mr)
 | 
					 | 
				
			||||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
					 | 
				
			||||||
                //.ToList();
 | 
					 | 
				
			||||||
            TotalCount = totalCount;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
					 | 
				
			||||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //这个方法用于拦截请求
 | 
					 | 
				
			||||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //查询表格数据
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int totalCount = 0;
 | 
				
			||||||
 | 
					            string machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM5";
 | 
				
			||||||
 | 
					            MachineRecords = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
				
			||||||
 | 
					                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
				
			||||||
 | 
					                .Includes<UserList>(mr => mr.User)
 | 
				
			||||||
 | 
					                .Where(mr => mr.MachineId == machineId)
 | 
				
			||||||
 | 
					                .WhereIF(StartDate != null, (mr) => mr.OperationTime > StartDate)
 | 
				
			||||||
 | 
					                .WhereIF(EndDate != null, (mr) => mr.OperationTime < EndDate).OrderByDescending(mr=>mr.OperationTime)
 | 
				
			||||||
 | 
					                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
				
			||||||
 | 
					            //.ToList();
 | 
				
			||||||
 | 
					            TotalCount = totalCount;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,8 @@ using DM_Weight.Finger;
 | 
				
			||||||
using DM_Weight.Views;
 | 
					using DM_Weight.Views;
 | 
				
			||||||
using Unity;
 | 
					using Unity;
 | 
				
			||||||
using DM_Weight.HIKVISION;
 | 
					using DM_Weight.HIKVISION;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -30,7 +32,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //private PortUtil _portUtil;
 | 
					        //private PortUtil _portUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private ScreenUtil _screenUtil;
 | 
					        //private ScreenUtil _screenUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public SolidColorBrush Background
 | 
					        public SolidColorBrush Background
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -60,27 +62,29 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        //    this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
 | 
					        //    this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
 | 
				
			||||||
        //    _screenUtil = screenUtil;
 | 
					        //    _screenUtil = screenUtil;
 | 
				
			||||||
        //}
 | 
					        //}
 | 
				
			||||||
        private FingerprintUtil _fingerprintUtil;
 | 
					        //private FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
        IRegionManager _regionManager;
 | 
					        IRegionManager _regionManager;
 | 
				
			||||||
        IUnityContainer _container;
 | 
					        IUnityContainer _container;
 | 
				
			||||||
        private CHKFunction _cHKFunction;
 | 
					        //private CHKFunction _cHKFunction;
 | 
				
			||||||
        public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil, CHKFunction cHKFunction)
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(PortUtil));
 | 
				
			||||||
 | 
					        public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //_portUtil = portUtil;
 | 
					            //_portUtil = portUtil;
 | 
				
			||||||
            this.eventAggregator = eventAggregator;
 | 
					            this.eventAggregator = eventAggregator;
 | 
				
			||||||
            this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
 | 
					            this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
 | 
				
			||||||
            _screenUtil = screenUtil;
 | 
					            //_fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
            _fingerprintUtil = fingerprintUtil;
 | 
					 | 
				
			||||||
            _regionManager = regionManager;
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
            _container = container;
 | 
					            _container = container;
 | 
				
			||||||
            _cHKFunction = cHKFunction;
 | 
					            //_cHKFunction = cHKFunction;
 | 
				
			||||||
            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
					
 | 
				
			||||||
            {
 | 
					            //System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                _container.RegisterType<object, LoginWindow>("LoginWindow");
 | 
					                _container.RegisterType<object, LoginWindow>("LoginWindow");
 | 
				
			||||||
                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                _regionManager.RegisterViewWithRegion("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }));
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void doMyPrismEvent2(AlertMsg msg)
 | 
					        void doMyPrismEvent2(AlertMsg msg)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,488 +0,0 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Collections.ObjectModel;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class MultiOrderTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
					 | 
				
			||||||
        public string Title => "多处方取药";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
        public MultiOrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (msg.WindowName == "OrderTakeDrugWindow")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
                int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 1)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 2)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
					 | 
				
			||||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
					 | 
				
			||||||
                            if (enumerator.MoveNext())
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
					 | 
				
			||||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
					 | 
				
			||||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Thread.Sleep(50);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                OpenOneByOne();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            // 已经全部取出
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Status = 3;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _status; set => SetProperty(ref _status, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //多处方的处方号
 | 
					 | 
				
			||||||
        private string _multiOrderNo = "处方号:";
 | 
					 | 
				
			||||||
        public string MultiOrderNo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _multiOrderNo;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _multiOrderNo, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        private ObservableCollection<OrderInfo>? _orderInfo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ObservableCollection<OrderInfo>? OrderInfo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _orderInfo;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _orderInfo, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderDetail> orderDetails { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
					 | 
				
			||||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return Status == 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            OrderInfo = parameters.GetValue<ObservableCollection<OrderInfo>>("orderInfo");
 | 
					 | 
				
			||||||
            MultiOrderNo += string.Join(",   ", OrderInfo.Select(o => o.OrderNo));
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
					 | 
				
			||||||
              //.Includes<DrugInfo>(od => od.DrugInfo)
 | 
					 | 
				
			||||||
              .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
					 | 
				
			||||||
              .Where(od => OrderInfo.Select(o => o.OrderNo).Contains(od.OrderNo)).GroupBy(od=>od.DrugId)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
              .Select(od=>new OrderDetail { DrugId=od.DrugId,SetEffDate=od.SetEffDate,SetManuNo=od.SetManuNo, Quantity=SqlFunc.AggregateSum(od.Quantity) })
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //.Where(od => od.OrderNo. OrderInfo.OrderNo)
 | 
					 | 
				
			||||||
                .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
					 | 
				
			||||||
            List<string> msg = new List<string>();
 | 
					 | 
				
			||||||
            for (int i = 0; i < orderDetails.Count; i++)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                OrderDetail orderDetail = orderDetails[i];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.Quantity > 0)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
					 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
					 | 
				
			||||||
                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
					 | 
				
			||||||
                    .OrderBy(cs => cs.EffDate)
 | 
					 | 
				
			||||||
                    .OrderBy(cs => cs.DrawerNo)
 | 
					 | 
				
			||||||
                    .ToList();
 | 
					 | 
				
			||||||
                int total = HasQChannels.Sum(it => it.Quantity);
 | 
					 | 
				
			||||||
                int TakeQ = orderDetail.Quantity;
 | 
					 | 
				
			||||||
                int multiTakeQ = orderDetail.Quantity;
 | 
					 | 
				
			||||||
                List<ChannelStock> multiTake = new List<ChannelStock>();
 | 
					 | 
				
			||||||
                //multiTakeQ = orderDetails.Where(c => c.DrugId == orderDetail.DrugId).Sum(c => c.Quantity);
 | 
					 | 
				
			||||||
                // 说明数量足够
 | 
					 | 
				
			||||||
                if (total >= multiTakeQ)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    for (int j = 0; TakeQ > 0; j++)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        ChannelStock stock = HasQChannels[j];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (TakeQ > stock.Quantity)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            //#region 存在该库存且库存数量大于待取数量则把取药数量加上
 | 
					 | 
				
			||||||
                            //var varChannelStock = channelStocks.Where(c => c.Location == stock.Location && c.Quantity > c.TakeQuantity + TakeQ).ToList();
 | 
					 | 
				
			||||||
                            //if (varChannelStock != null && varChannelStock.Count > 0)
 | 
					 | 
				
			||||||
                            //{
 | 
					 | 
				
			||||||
                            //    channelStocks.Where(c => c.Location == stock.Location).Select(c => c.TakeQuantity += TakeQ).ToList();
 | 
					 | 
				
			||||||
                            //    break;
 | 
					 | 
				
			||||||
                            //}
 | 
					 | 
				
			||||||
                            //#endregion
 | 
					 | 
				
			||||||
                            stock.TakeQuantity = stock.Quantity;
 | 
					 | 
				
			||||||
                            channelStocks.Add(stock);
 | 
					 | 
				
			||||||
                            TakeQ -= stock.Quantity;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        else
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            //#region 存在该库存且库存数量大于待取数量则把取药数量加上
 | 
					 | 
				
			||||||
                            //var varChannelStock = channelStocks.Where(c => c.Location == stock.Location && c.Quantity > c.TakeQuantity + TakeQ).ToList();
 | 
					 | 
				
			||||||
                            //if (varChannelStock != null && varChannelStock.Count > 0)
 | 
					 | 
				
			||||||
                            //{
 | 
					 | 
				
			||||||
                            //    channelStocks.Where(c => c.Location == stock.Location).Select(c => c.TakeQuantity += TakeQ).ToList();
 | 
					 | 
				
			||||||
                            //    break;
 | 
					 | 
				
			||||||
                            //}
 | 
					 | 
				
			||||||
                            //#endregion
 | 
					 | 
				
			||||||
                            stock.TakeQuantity = TakeQ;
 | 
					 | 
				
			||||||
                            channelStocks.Add(stock);
 | 
					 | 
				
			||||||
                            TakeQ = 0;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    //msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
					 | 
				
			||||||
                    msg.Add($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (msg.Count > 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
                //MessageBox.Show(string.Join("\n", msg));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("msgInfo", msg);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                channelStocks.Sort((a, b) =>
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        return a.ColNo - b.ColNo;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    return a.DrawerNo - b.DrawerNo;
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
                ChannelStocks = channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        public DelegateCommand OpenDrawer
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status == 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
					 | 
				
			||||||
                    enumerator = enumerable.GetEnumerator();
 | 
					 | 
				
			||||||
                    enumerator.MoveNext();
 | 
					 | 
				
			||||||
                    Status = 1;
 | 
					 | 
				
			||||||
                    OpenOneByOne();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void OpenOneByOne()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 发送取药数量
 | 
					 | 
				
			||||||
            singleChannels.ForEach(it =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                try
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch (Exception ex)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        Message = $"打开抽屉异常{ex.Message}",
 | 
					 | 
				
			||||||
                        Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                    };
 | 
					 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            _portUtil.WindowName = "OrderTakeDrugWindow";
 | 
					 | 
				
			||||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
					 | 
				
			||||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
					 | 
				
			||||||
            _portUtil.DrawerNo = DrawerNo;
 | 
					 | 
				
			||||||
            _portUtil.Start();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isFinishClick = false;
 | 
					 | 
				
			||||||
        // 完成按钮
 | 
					 | 
				
			||||||
        public DelegateCommand TakeFinish
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!_isFinishClick)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _isFinishClick = true;
 | 
					 | 
				
			||||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    //根据处方单数量分别更新处方状态、写记录信息
 | 
					 | 
				
			||||||
                    if (OrderInfo.Count > 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        for (int j = 0; j < OrderInfo.Count; j++)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            string InvoiceId = OrderInfo[j].OrderNo;
 | 
					 | 
				
			||||||
                            var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                //SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
					 | 
				
			||||||
                                //{
 | 
					 | 
				
			||||||
                                //    DmStatus = 1,
 | 
					 | 
				
			||||||
                                //    OrderNo = OrderInfo[j].OrderNo
 | 
					 | 
				
			||||||
                                //}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    OrderNo = OrderInfo[j].OrderNo,
 | 
					 | 
				
			||||||
                                    PatientId = OrderInfo[j].PatientId,
 | 
					 | 
				
			||||||
                                    Pharmacy = OrderInfo[j].Pharmacy,
 | 
					 | 
				
			||||||
                                    State = 1,
 | 
					 | 
				
			||||||
                                    Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
					 | 
				
			||||||
                                });
 | 
					 | 
				
			||||||
                                for (int i = 0; i < record.Count; i++)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                    List<OrderDetail> orderDet = SqlSugarHelper.Db.Queryable<OrderDetail>().Where(od => od.OrderNo == OrderInfo[j].OrderNo && od.DrugId == record[i].DrugId).ToList();
 | 
					 | 
				
			||||||
                                    //该对方没有这个药,跳出循环
 | 
					 | 
				
			||||||
                                    if (orderDet == null || orderDet.Count <= 0)
 | 
					 | 
				
			||||||
                                        continue;
 | 
					 | 
				
			||||||
                                    int orderTakeQuantity = orderDet[0].Quantity;
 | 
					 | 
				
			||||||
                                    ChannelStock it = record[i];
 | 
					 | 
				
			||||||
                                    // 更新数据 库存信息
 | 
					 | 
				
			||||||
                                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
					 | 
				
			||||||
                                    {
 | 
					 | 
				
			||||||
                                        Quantity = it.Quantity - it.TakeQuantity,
 | 
					 | 
				
			||||||
                                        ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                        EffDate = it.EffDate,
 | 
					 | 
				
			||||||
                                        Id = it.Id,
 | 
					 | 
				
			||||||
                                    }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                    // 获取更新完库存后的药品库存
 | 
					 | 
				
			||||||
                                    List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                                        .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
					 | 
				
			||||||
                                        .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
					 | 
				
			||||||
                                        .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                                        .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                    // 保存数据 出库记录
 | 
					 | 
				
			||||||
                                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					 | 
				
			||||||
                                    {
 | 
					 | 
				
			||||||
                                        MachineId = it.MachineId,
 | 
					 | 
				
			||||||
                                        DrawerNo = it.DrawerNo,
 | 
					 | 
				
			||||||
                                        ColNo = it.ColNo,
 | 
					 | 
				
			||||||
                                        DrugId = it.DrugId,
 | 
					 | 
				
			||||||
                                        ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                        EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
					 | 
				
			||||||
                                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                                        Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                        OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                        Quantity = orderTakeQuantity,
 | 
					 | 
				
			||||||
                                        Type = 2,
 | 
					 | 
				
			||||||
                                        InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                                        StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                                    }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                //更新处方状态
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    DmStatus = 1,
 | 
					 | 
				
			||||||
                                    OrderNo = OrderInfo[j].OrderNo
 | 
					 | 
				
			||||||
                                }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                return true;
 | 
					 | 
				
			||||||
                            });
 | 
					 | 
				
			||||||
                            if (f.Data)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                //});
 | 
					 | 
				
			||||||
                                // 更新屏显库存
 | 
					 | 
				
			||||||
                                List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
                                if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    singleChannels.ForEach(it =>
 | 
					 | 
				
			||||||
                                    {
 | 
					 | 
				
			||||||
                                        _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
 | 
					 | 
				
			||||||
                                    });
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Message = "抽屉取药完成,库存已更新",
 | 
					 | 
				
			||||||
                                    Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                                };
 | 
					 | 
				
			||||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            if (!f.IsSuccess)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Message = "抽屉取药完成,库存更新失败!",
 | 
					 | 
				
			||||||
                                    Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                                };
 | 
					 | 
				
			||||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        _isFinishClick = false;
 | 
					 | 
				
			||||||
                        //RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
                        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public long CurrentTimeMillis()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 取消按钮
 | 
					 | 
				
			||||||
        public DelegateCommand CancleTake
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                _portUtil.ResetData();
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BtnCloseCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status != 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _portUtil.ResetData();
 | 
					 | 
				
			||||||
                    Status = 0;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                //DialogParameters parameters = new DialogParameters();
 | 
					 | 
				
			||||||
                //parameters.Add("",);
 | 
					 | 
				
			||||||
                // 关闭当前窗口
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,380 +0,0 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Collections.ObjectModel;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class MultiOrderTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        public static MultiOrderTakeDrugWindowViewModel vm;
 | 
					 | 
				
			||||||
        private int _pageNum = 1;
 | 
					 | 
				
			||||||
        public int PageNum
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageNum;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageNum, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageCount = 1;
 | 
					 | 
				
			||||||
        public int PageCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageSize = 8;
 | 
					 | 
				
			||||||
        public int PageSize
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageSize;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageSize, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _totalCount = 0;
 | 
					 | 
				
			||||||
        public int TotalCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _totalCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _totalCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public MultiOrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
            vm = this;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //public static ObservableCollection<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    new OrderTakeSelect
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //        Code = "OrderNo",
 | 
					 | 
				
			||||||
        //        Name = "处方号"
 | 
					 | 
				
			||||||
        //    },
 | 
					 | 
				
			||||||
        //    new OrderTakeSelect
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //        Code = "PatientId",
 | 
					 | 
				
			||||||
        //        Name = "患者编号"
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //private ObservableCollection<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //public ObservableCollection<OrderTakeSelect> OrderTakeSelects
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get { return _orderTakeSelects; }
 | 
					 | 
				
			||||||
        //    set
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //        SetProperty(ref _orderTakeSelects, value);
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
					 | 
				
			||||||
        ///// <summary>
 | 
					 | 
				
			||||||
        ///// 查询条件 查询字段
 | 
					 | 
				
			||||||
        ///// </summary>
 | 
					 | 
				
			||||||
        //public OrderTakeSelect SelectedItem
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get { return _selectedItem; }
 | 
					 | 
				
			||||||
        //    set
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //        SetProperty(ref _selectedItem, value);
 | 
					 | 
				
			||||||
        //        RequestData();
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //private OrderInfo? _selectedOrder;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //public OrderInfo? SelectedOrder
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get { return _selectedOrder; }
 | 
					 | 
				
			||||||
        //    set
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //        SetProperty(ref _selectedOrder, value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //        //OpenOrderDialog();
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件  处方日期
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string OrderDate
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderDate; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!String.IsNullOrEmpty(value))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, value);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //private string? _searchValue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ///// <summary>
 | 
					 | 
				
			||||||
        ///// 查询条件 查询字段值
 | 
					 | 
				
			||||||
        ///// </summary>
 | 
					 | 
				
			||||||
        //public string? SearchValue
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get { return _searchValue; }
 | 
					 | 
				
			||||||
        //    set
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //        SetProperty(ref _searchValue, value);
 | 
					 | 
				
			||||||
        //        RequestData();
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        ///全选
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        private bool _allChecked = false;
 | 
					 | 
				
			||||||
        public bool IsAllChecked
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _allChecked; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _allChecked, value);
 | 
					 | 
				
			||||||
                if (!IsItemCheck)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    RequestData();
 | 
					 | 
				
			||||||
                    //根据全选或反选设置其后的选中状态
 | 
					 | 
				
			||||||
                    OrderInfos.ToList().ForEach(oi => oi.ItemIsChecked = _allChecked);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    IsItemCheck = false;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool _isItemCheck = false;
 | 
					 | 
				
			||||||
        public bool IsItemCheck
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _isItemCheck;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _isItemCheck, value);
 | 
					 | 
				
			||||||
                if (OrderInfos.ToList().Where(od => od.ItemIsChecked == false).Count() <= 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    IsAllChecked = true;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        //private bool _itemIsChecked = false;
 | 
					 | 
				
			||||||
        //public bool ItemIsChecked
 | 
					 | 
				
			||||||
        //{
 | 
					 | 
				
			||||||
        //    get => _itemIsChecked;
 | 
					 | 
				
			||||||
        //    set
 | 
					 | 
				
			||||||
        //    {
 | 
					 | 
				
			||||||
        //         SetProperty(ref _itemIsChecked, value);
 | 
					 | 
				
			||||||
        //    }
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
        //多处方取药
 | 
					 | 
				
			||||||
        public DelegateCommand BtnTakeOrder { get => new DelegateCommand(TakeByMultiOrder); }
 | 
					 | 
				
			||||||
        private void TakeByMultiOrder()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            OrderInfos = new ObservableCollection<OrderInfo>(OrderInfos.Where(o => o.ItemIsChecked == true).ToList());
 | 
					 | 
				
			||||||
            if (OrderInfos != null && OrderInfos.Count() > 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 此处延时1毫秒,等待页面渲染
 | 
					 | 
				
			||||||
                //await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("orderInfo", OrderInfos);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "MultiOrderTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                //请勾选要取药的处方信息
 | 
					 | 
				
			||||||
                AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    Message = "请勾选要取药的处方信息",
 | 
					 | 
				
			||||||
                    Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                };
 | 
					 | 
				
			||||||
                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            IsAllChecked = false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private ObservableCollection<OrderInfo> _orderInfos = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ObservableCollection<OrderInfo> OrderInfos
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderInfos; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _orderInfos, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //部门
 | 
					 | 
				
			||||||
        private ObservableCollection<OrderDepartment> _orderDepartments = new ObservableCollection<OrderDepartment>();
 | 
					 | 
				
			||||||
        public ObservableCollection<OrderDepartment> OrderDepartments
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _orderDepartments;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _orderDepartments, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderDepartment _orderDepartment = new OrderDepartment();
 | 
					 | 
				
			||||||
        public OrderDepartment OrderDepartment
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _orderDepartment;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _orderDepartment, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 委托   被动执行     被子窗口执行
 | 
					 | 
				
			||||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
					 | 
				
			||||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
					 | 
				
			||||||
            //{
 | 
					 | 
				
			||||||
            //SelectedOrder = null;
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand QueryCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            OrderInfos.Clear();
 | 
					 | 
				
			||||||
            int totalCount = 0;
 | 
					 | 
				
			||||||
            //string SearchValue = null;
 | 
					 | 
				
			||||||
            //if (SearchValue != null)
 | 
					 | 
				
			||||||
            //{
 | 
					 | 
				
			||||||
            //    strSearchValue = SearchValue.Trim().Replace("\r", "");
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
					 | 
				
			||||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
					 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
					 | 
				
			||||||
                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
					 | 
				
			||||||
                .WhereIF(!(OrderDepartment.DeptName.Equals("全部")), oi => oi.DeptName == OrderDepartment.DeptName)
 | 
					 | 
				
			||||||
                //.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
					 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
					 | 
				
			||||||
                .Where(oi => oi.DmStatus == 0)
 | 
					 | 
				
			||||||
                .Where(oi => oi.HisDispFlag == 0)
 | 
					 | 
				
			||||||
                .Where(oi => oi.CancelFlag == 0)
 | 
					 | 
				
			||||||
                .GroupBy(oi => oi.OrderDate)
 | 
					 | 
				
			||||||
                .Select(oi => oi)
 | 
					 | 
				
			||||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
					 | 
				
			||||||
            //.ToList();
 | 
					 | 
				
			||||||
            OrderInfos = new ObservableCollection<OrderInfo>(queryData);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (OrderDepartments.Where(d => d.DeptName == "全部").ToList().Count <= 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                OrderDepartment deptDefault = new OrderDepartment();
 | 
					 | 
				
			||||||
                deptDefault.DeptName = "全部";
 | 
					 | 
				
			||||||
                OrderDepartments.Add(deptDefault);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            var orderDeparts = queryData.GroupBy(o=>o.DeptName).ToList();
 | 
					 | 
				
			||||||
            for (int i = 0; i < orderDeparts.Count; i++)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                OrderDepartment dept = new OrderDepartment();
 | 
					 | 
				
			||||||
                if (orderDeparts[i].Key != null && orderDeparts[i].Key != string.Empty&& OrderDepartments.Where(d => d.DeptName == orderDeparts[i].Key).ToList().Count<=0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    dept.DeptName = orderDeparts[i].Key;
 | 
					 | 
				
			||||||
                    OrderDepartments.Add(dept);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            TotalCount = totalCount;
 | 
					 | 
				
			||||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
					 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            //_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
					 | 
				
			||||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求
 | 
					 | 
				
			||||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            //_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            //if (msg.EventType == EventType.CODESCAN)
 | 
					 | 
				
			||||||
            //{
 | 
					 | 
				
			||||||
            //    SearchValue = msg.Code;
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,554 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Drawing.Printing;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Security.Cryptography.Pkcs;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Media;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class OpenBoxNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
 | 
				
			||||||
 | 
					        private int _drawerType = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int DrawerType
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drawerType;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _drawerType, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //所选药箱号
 | 
				
			||||||
 | 
					        private int _drawerNo = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int DrawerNo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drawerNo;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _drawerNo, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //开名下药箱按钮的显示状态
 | 
				
			||||||
 | 
					        private bool _selfEnable = false;
 | 
				
			||||||
 | 
					        public bool SelfEnable { get => _selfEnable; set => SetProperty(ref _selfEnable, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //名下药箱按钮显示内容
 | 
				
			||||||
 | 
					        private string _selfContent="打开药箱";
 | 
				
			||||||
 | 
					        public string SelfContent { get => _selfContent; set => SetProperty(ref _selfContent, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //开公共药箱按钮的显示状态
 | 
				
			||||||
 | 
					        private bool _publicEnable = true;
 | 
				
			||||||
 | 
					        public bool PublicEnable { get => _publicEnable; set => SetProperty(ref _publicEnable, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //公共药箱按钮显示内容
 | 
				
			||||||
 | 
					        private string _publicContent;
 | 
				
			||||||
 | 
					        public string PublicContent { get => _publicContent; set => SetProperty(ref _publicContent, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //公共药箱状态
 | 
				
			||||||
 | 
					        //private int _publicStatus = 0;
 | 
				
			||||||
 | 
					        //public int PublicStatus { get => _publicStatus; set => SetProperty(ref _publicStatus, value); }
 | 
				
			||||||
 | 
					        //名下药箱状态
 | 
				
			||||||
 | 
					        private int _selfStatus = 0;
 | 
				
			||||||
 | 
					        public int SelfStatus { get => _selfStatus; set => SetProperty(ref _selfStatus, value); }
 | 
				
			||||||
 | 
					        //抽屉号列表
 | 
				
			||||||
 | 
					        public static List<ChannelList> iList = new List<ChannelList>();
 | 
				
			||||||
 | 
					        //第几个抽屉号
 | 
				
			||||||
 | 
					        //public static int iNumber = 1;
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public OpenBoxNewWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #region 抽屉按钮
 | 
				
			||||||
 | 
					        private Brush _button1Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button1Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button1Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button1Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button2Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button2Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button2Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button2Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button3Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button3Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button3Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button3Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button4Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button4Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button4Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button4Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button5Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button5Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button5Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button5Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button6Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button6Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button6Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button6Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button7Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button7Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button7Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button7Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button8Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button8Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button8Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button8Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button9Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button9Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button9Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button9Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button10Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button10Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button10Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button10Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button11Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button11Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button11Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button11Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button12Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button12Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button12Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button12Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button13Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button13Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button13Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button13Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button14Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button14Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button14Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button14Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button15Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button15Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button15Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button15Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button16Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button16Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button16Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button16Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button17Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button17Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button17Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button17Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private Brush _button18Color = Brushes.White;
 | 
				
			||||||
 | 
					        public Brush Button18Color
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button18Color;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button18Color, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _button1Enable = false;
 | 
				
			||||||
 | 
					        public bool Button1Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button1Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button1Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button2Enable = false;
 | 
				
			||||||
 | 
					        public bool Button2Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button2Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button2Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button3Enable = false;
 | 
				
			||||||
 | 
					        public bool Button3Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button3Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button3Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button4Enable = false;
 | 
				
			||||||
 | 
					        public bool Button4Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button4Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button4Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button5Enable = false;
 | 
				
			||||||
 | 
					        public bool Button5Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button5Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button5Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button6Enable = false;
 | 
				
			||||||
 | 
					        public bool Button6Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button6Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button6Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button7Enable = false;
 | 
				
			||||||
 | 
					        public bool Button7Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button7Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button7Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button8Enable = false;
 | 
				
			||||||
 | 
					        public bool Button8Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button8Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button8Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button9Enable = false;
 | 
				
			||||||
 | 
					        public bool Button9Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button9Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button9Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button10Enable = false;
 | 
				
			||||||
 | 
					        public bool Button10Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button10Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button10Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button11Enable = false;
 | 
				
			||||||
 | 
					        public bool Button11Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button11Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button11Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button12Enable = false;
 | 
				
			||||||
 | 
					        public bool Button12Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button12Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button12Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button13Enable = false;
 | 
				
			||||||
 | 
					        public bool Button13Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button13Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button13Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button14Enable = false;
 | 
				
			||||||
 | 
					        public bool Button14Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button14Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button14Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button15Enable = false;
 | 
				
			||||||
 | 
					        public bool Button15Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button15Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button15Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button16Enable = false;
 | 
				
			||||||
 | 
					        public bool Button16Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button16Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button16Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button17Enable = false;
 | 
				
			||||||
 | 
					        public bool Button17Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button17Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button17Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _button18Enable = false;
 | 
				
			||||||
 | 
					        public bool Button18Enable
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _button18Enable;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _button18Enable, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					        //设置按钮颜色
 | 
				
			||||||
 | 
					        private void SetBtnColor(int drawerNo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            switch (drawerNo)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case 1:
 | 
				
			||||||
 | 
					                    Button1Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 2:
 | 
				
			||||||
 | 
					                    Button2Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 3:
 | 
				
			||||||
 | 
					                    Button3Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 4:
 | 
				
			||||||
 | 
					                    Button4Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 5:
 | 
				
			||||||
 | 
					                    Button5Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 6:
 | 
				
			||||||
 | 
					                    Button6Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 7:
 | 
				
			||||||
 | 
					                    Button7Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 8:
 | 
				
			||||||
 | 
					                    Button8Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 9:
 | 
				
			||||||
 | 
					                    Button9Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 10:
 | 
				
			||||||
 | 
					                    Button10Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 11:
 | 
				
			||||||
 | 
					                    Button11Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 12:
 | 
				
			||||||
 | 
					                    Button12Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 13:
 | 
				
			||||||
 | 
					                    Button13Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 14:
 | 
				
			||||||
 | 
					                    Button14Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 15:
 | 
				
			||||||
 | 
					                    Button15Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 16:
 | 
				
			||||||
 | 
					                    Button16Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 17:
 | 
				
			||||||
 | 
					                    Button17Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 18:
 | 
				
			||||||
 | 
					                    Button18Color = Brushes.Yellow;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                default:
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //设置按钮可用状态
 | 
				
			||||||
 | 
					        private void SetBtnEnable(int drawerNo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            switch (drawerNo)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case 1:
 | 
				
			||||||
 | 
					                    Button1Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 2:
 | 
				
			||||||
 | 
					                    Button2Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 3:
 | 
				
			||||||
 | 
					                    Button3Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 4:
 | 
				
			||||||
 | 
					                    Button4Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 5:
 | 
				
			||||||
 | 
					                    Button5Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 6:
 | 
				
			||||||
 | 
					                    Button6Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 7:
 | 
				
			||||||
 | 
					                    Button7Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 8:
 | 
				
			||||||
 | 
					                    Button8Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 9:
 | 
				
			||||||
 | 
					                    Button9Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 10:
 | 
				
			||||||
 | 
					                    Button10Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 11:
 | 
				
			||||||
 | 
					                    Button11Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 12:
 | 
				
			||||||
 | 
					                    Button12Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 13:
 | 
				
			||||||
 | 
					                    Button13Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 14:
 | 
				
			||||||
 | 
					                    Button14Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 15:
 | 
				
			||||||
 | 
					                    Button15Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 16:
 | 
				
			||||||
 | 
					                    Button16Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 17:
 | 
				
			||||||
 | 
					                    Button17Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 18:
 | 
				
			||||||
 | 
					                    Button18Enable = true;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                default:
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            List<ChannelList> chlList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5").ToList();//.Select(cl => cl.BelongUser).First();
 | 
				
			||||||
 | 
					            if (chlList != null && chlList.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                for (int i = 0; i < chlList.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ChannelList chl = chlList[i];
 | 
				
			||||||
 | 
					                    if (Convert.ToDateTime(chl.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SetBtnColor(chl.DrawerNo);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    //DrawerType== 1为公共药箱
 | 
				
			||||||
 | 
					                    if (chl.DrawerType == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SetBtnEnable(chl.DrawerNo);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if (!string.IsNullOrEmpty(chl.BelongUser)&& chl.BelongUser == HomeWindowViewModel.Operator.UserBarcode)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SetBtnEnable(chl.DrawerNo);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 选择药箱,打开药箱
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public DelegateCommand<string> UpdateDrawerNo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<string>(OpenBoxAction);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public async void OpenBoxAction(string strDrawerNo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            DrawerNo = Convert.ToInt32(strDrawerNo);
 | 
				
			||||||
 | 
					            DrawerType = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo == Convert.ToInt32(strDrawerNo)).Select(cl => cl.DrawerType).First();
 | 
				
			||||||
 | 
					            SelfEnable = true;
 | 
				
			||||||
 | 
					            //int listSelfState = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5")
 | 
				
			||||||
 | 
					            //  .WhereIf(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int listDrawerState = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType)
 | 
				
			||||||
 | 
					                .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First();
 | 
				
			||||||
 | 
					            if (DrawerType == 1) //公共药箱
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (listDrawerState == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SelfContent = "还公共药箱";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SelfContent = "取公共药箱";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (listDrawerState == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SelfContent = "还名下药箱";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SelfContent = "取名下药箱";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand<string> OpenBoxDelegate
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<string>((DrawerType) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SearchBox();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SearchBox()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType)
 | 
				
			||||||
 | 
					                .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).ToList();
 | 
				
			||||||
 | 
					            // .Select(cl => cl.DrawerNo).ToList();
 | 
				
			||||||
 | 
					            if (iList.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //_portUtil.SpeakAsync("正在打开药箱");
 | 
				
			||||||
 | 
					                //_portUtil.DrawerNo = iList[iNumber];
 | 
				
			||||||
 | 
					                //iNumber++;
 | 
				
			||||||
 | 
					                //_portUtil.OpenBox();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                for (int i = 0; i < iList.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ChannelList channelList = iList[i];
 | 
				
			||||||
 | 
					                    //记录开药箱日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        DrawerNo = channelList.DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = $"打开{iList[i].DrawerNo}号药箱",
 | 
				
			||||||
 | 
					                        OptionType= SelfContent.Substring(0,1)=="取"? 0:1
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    //记录药箱打开时间
 | 
				
			||||||
 | 
					                    channelList.EffDate = DateTime.Now.ToString();
 | 
				
			||||||
 | 
					                    channelList.DrawerState = SelfContent.Substring(0, 1) == "取" ? 0 : 1;
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate, it.DrawerState }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    _portUtil.SpeakAsync($"正在打开{channelList.DrawerNo}号药箱");
 | 
				
			||||||
 | 
					                    logger.Info($"正在打开{channelList.DrawerNo}号药箱");
 | 
				
			||||||
 | 
					                    ModbusHelper.GetInstance().OpenBoxDoor(channelList.DrawerNo - 1);
 | 
				
			||||||
 | 
					                    Thread.Sleep(1000);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                SelfStatus = 0;
 | 
				
			||||||
 | 
					                PublicEnable = true;
 | 
				
			||||||
 | 
					                SelfEnable = true;
 | 
				
			||||||
 | 
					                DrawerType = -1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,264 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Threading;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class OpenBoxWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
 | 
				
			||||||
 | 
					        private int _drawerType = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int DrawerType
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _drawerType;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _drawerType, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int status = 0;
 | 
				
			||||||
 | 
					        public int Status { get => status; set => SetProperty(ref status, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //开名下药箱按钮的显示状态
 | 
				
			||||||
 | 
					        private bool _selfEnable = true;
 | 
				
			||||||
 | 
					        public bool SelfEnable { get => _selfEnable; set => SetProperty(ref _selfEnable, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //名下药箱按钮显示内容
 | 
				
			||||||
 | 
					        private string _selfContent;
 | 
				
			||||||
 | 
					        public string SelfContent { get => _selfContent; set => SetProperty(ref _selfContent, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //开公共药箱按钮的显示状态
 | 
				
			||||||
 | 
					        private bool _publicEnable = true;
 | 
				
			||||||
 | 
					        public bool PublicEnable { get => _publicEnable; set => SetProperty(ref _publicEnable, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //公共药箱按钮显示内容
 | 
				
			||||||
 | 
					        private string _publicContent;
 | 
				
			||||||
 | 
					        public string PublicContent { get => _publicContent; set => SetProperty(ref _publicContent, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //公共药箱状态
 | 
				
			||||||
 | 
					        private int _publicStatus = 0;
 | 
				
			||||||
 | 
					        public int PublicStatus { get => _publicStatus; set => SetProperty(ref _publicStatus, value); }
 | 
				
			||||||
 | 
					        //名下药箱状态
 | 
				
			||||||
 | 
					        private int _selfStatus = 0;
 | 
				
			||||||
 | 
					        public int SelfStatus { get => _publicStatus; set => SetProperty(ref _publicStatus, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //抽屉号列表
 | 
				
			||||||
 | 
					        public static List<ChannelList> iList = new List<ChannelList>();
 | 
				
			||||||
 | 
					        //第几个抽屉号
 | 
				
			||||||
 | 
					        //public static int iNumber = 1;
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public OpenBoxWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand<string> OpenBoxDelegate
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<string>((DrawerType) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                this.DrawerType = Convert.ToInt32(DrawerType);
 | 
				
			||||||
 | 
					                switch (this.DrawerType)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    case 0:
 | 
				
			||||||
 | 
					                        PublicEnable = false;
 | 
				
			||||||
 | 
					                        PublicStatus = 1;
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 1:
 | 
				
			||||||
 | 
					                        SelfEnable = false;
 | 
				
			||||||
 | 
					                        SelfStatus = 1;
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                SearchBox();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SearchBox()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType)
 | 
				
			||||||
 | 
					                .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).ToList();
 | 
				
			||||||
 | 
					            // .Select(cl => cl.DrawerNo).ToList();
 | 
				
			||||||
 | 
					            if (iList.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //_portUtil.SpeakAsync("正在打开药箱");
 | 
				
			||||||
 | 
					                //_portUtil.DrawerNo = iList[iNumber];
 | 
				
			||||||
 | 
					                //iNumber++;
 | 
				
			||||||
 | 
					                //_portUtil.OpenBox();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                for (int i = 0; i < iList.Count; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ChannelList channelList = iList[i];
 | 
				
			||||||
 | 
					                    //记录开药箱日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        DrawerNo = channelList.DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = $"打开{iList[i]}号药箱",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    //记录药箱打开时间
 | 
				
			||||||
 | 
					                    channelList.EffDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
				
			||||||
 | 
					                    channelList.DrawerState = 0;
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate, it.DrawerState }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    _portUtil.SpeakAsync($"正在打开{channelList.DrawerNo}号药箱");
 | 
				
			||||||
 | 
					                    logger.Info($"正在打开{channelList.DrawerNo}号药箱");
 | 
				
			||||||
 | 
					                    ModbusHelper.GetInstance().OpenBoxDoor(channelList.DrawerNo - 1);
 | 
				
			||||||
 | 
					                    Thread.Sleep(1000);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                PublicStatus = 0;
 | 
				
			||||||
 | 
					                SelfStatus = 0;
 | 
				
			||||||
 | 
					                PublicEnable = true;
 | 
				
			||||||
 | 
					                SelfEnable = true;
 | 
				
			||||||
 | 
					                DrawerType = -1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            switch (msg.EventType)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // 药箱打开
 | 
				
			||||||
 | 
					                case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					                    //记录开药箱日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        //DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = "药箱打开",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //if (iNumber < iList.Count)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //_portUtil.DrawerNo = iList[iNumber];
 | 
				
			||||||
 | 
					                    //iNumber++;
 | 
				
			||||||
 | 
					                    if (PublicStatus == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        PublicStatus = 2;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SelfStatus = 2;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    //_portUtil.OpenBox();
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                    //else
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //iNumber = 0;
 | 
				
			||||||
 | 
					                    //_portUtil.GetBoxStatus();
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                // 药箱关闭
 | 
				
			||||||
 | 
					                case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					                    //记录药箱操作日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        //DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = "药箱关闭",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (PublicStatus == 2)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        PublicStatus = 3;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SelfStatus = 3;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    PublicEnable = true;
 | 
				
			||||||
 | 
					                    SelfEnable = true;
 | 
				
			||||||
 | 
					                    DrawerType = -1;
 | 
				
			||||||
 | 
					                    //_portUtil.Operate = false;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                // 打开失败
 | 
				
			||||||
 | 
					                case EventType.OPENERROR:
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = msg.Message,
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    PublicEnable = true;
 | 
				
			||||||
 | 
					                    SelfEnable = true;
 | 
				
			||||||
 | 
					                    DrawerType = -1;
 | 
				
			||||||
 | 
					                    PublicStatus = 0;
 | 
				
			||||||
 | 
					                    SelfStatus = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //记录药箱操作日志
 | 
				
			||||||
 | 
					                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MachineId = "DM5",
 | 
				
			||||||
 | 
					                        //DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					                        Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                        OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                        Type = 55,
 | 
				
			||||||
 | 
					                        InvoiceId = "药箱打开失败",
 | 
				
			||||||
 | 
					                    }).ExecuteCommand();
 | 
				
			||||||
 | 
					                    //_portUtil.Operate = false;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            //_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            CheckDrawerState();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //查询名下药箱与公共药箱状态
 | 
				
			||||||
 | 
					        private void CheckDrawerState()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            PublicContent = "开公共药箱";
 | 
				
			||||||
 | 
					            int listSelfState = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5")
 | 
				
			||||||
 | 
					                .Where(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerState).First();
 | 
				
			||||||
 | 
					            if (listSelfState > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SelfContent = "还名下药箱";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SelfContent = "取名下药箱";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,414 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using log4net.Repository.Hierarchy;
 | 
					 | 
				
			||||||
using Microsoft.Xaml.Behaviors;
 | 
					 | 
				
			||||||
using NetTaste;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using System.Threading;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class OrderReturnDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderReturnDialogViewModel));
 | 
					 | 
				
			||||||
        public string Title => "处方退药";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
        public OrderReturnDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (msg.WindowName == "ReturnDrug1Window")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
                int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 1)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 2)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
					 | 
				
			||||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
					 | 
				
			||||||
                            if (enumerator.MoveNext())
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
					 | 
				
			||||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
					 | 
				
			||||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Thread.Sleep(50);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                OpenOneByOne();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            // 已经全部取出
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Status = 3;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
					 | 
				
			||||||
                            //channelStocks.ForEach(it => it.ReturnQuantity = msg.Quantitys[it.ColNo - 1]);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _status; set => SetProperty(ref _status, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderInfo? _orderInfo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public OrderInfo? OrderInfo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _orderInfo;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _orderInfo, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderDetail> orderDetails { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
					 | 
				
			||||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return Status == 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            OrderInfo o = parameters.GetValue<OrderInfo>("orderInfo");
 | 
					 | 
				
			||||||
            OrderInfo = o;
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
					 | 
				
			||||||
                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
					 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
 | 
					 | 
				
			||||||
                .Where(od => od.OrderNo == OrderInfo.OrderNo)
 | 
					 | 
				
			||||||
                .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = new List<ChannelStock>();
 | 
					 | 
				
			||||||
            List<string> msg = new List<string>();
 | 
					 | 
				
			||||||
            for (int i = 0; i < orderDetails.Count; i++)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                OrderDetail orderDetail = orderDetails[i];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                    .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                    .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
 | 
					 | 
				
			||||||
                    .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
 | 
					 | 
				
			||||||
                    .Where(cs => cs.DrugId == orderDetail.DrugId)
 | 
					 | 
				
			||||||
                    .OrderBy(cs => cs.EffDate)
 | 
					 | 
				
			||||||
                    .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // 有库位
 | 
					 | 
				
			||||||
                if (HasQChannels.Count > 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    ChannelStock singleChannel = HasQChannels.Find(it => (it.BoardType == 2 && (25 - it.Quantity >= orderDetail.Quantity)));
 | 
					 | 
				
			||||||
                    ChannelStock otherChannel = HasQChannels.Find(it => it.BoardType != 2);
 | 
					 | 
				
			||||||
                    if ((singleChannel ?? otherChannel) != null)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        //(singleChannel ?? otherChannel).TakeQuantity = orderDetail.Quantity;
 | 
					 | 
				
			||||||
                        (singleChannel ?? otherChannel).ReturnQuantity = orderDetail.Quantity;
 | 
					 | 
				
			||||||
                        channelStocks.Add(singleChannel ?? otherChannel);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】现有库位不足以放置药品");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    msg.Add($"药品【{orderDetail.DrugInfo.DrugName}】无库位");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (msg.Count > 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
                //MessageBox.Show(string.Join("\n", msg));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("msgInfo", msg);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                channelStocks.Sort((a, b) =>
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        return a.ColNo - b.ColNo;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    return a.DrawerNo - b.DrawerNo;
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
                ChannelStocks = channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand OpenDrawer
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status == 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
					 | 
				
			||||||
                    enumerator = enumerable.GetEnumerator();
 | 
					 | 
				
			||||||
                    enumerator.MoveNext();
 | 
					 | 
				
			||||||
                    Status = 1;
 | 
					 | 
				
			||||||
                    OpenOneByOne();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void OpenOneByOne()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 发送还药数量
 | 
					 | 
				
			||||||
            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)
 | 
					 | 
				
			||||||
                            }).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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,448 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using Microsoft.Xaml.Behaviors;
 | 
					 | 
				
			||||||
using NetTaste;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using System.Threading;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class OrderTakeDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
 | 
					 | 
				
			||||||
        public string Title => "处方取药";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
        public OrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (msg.WindowName == "OrderTakeDrugWindow")
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
                int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 1)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 2)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
					 | 
				
			||||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
					 | 
				
			||||||
                            if (enumerator.MoveNext())
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
					 | 
				
			||||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
					 | 
				
			||||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Thread.Sleep(50);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                OpenOneByOne();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            // 已经全部取出
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Status = 3;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            logger.Info($"抽屉【{DrawerNo}】库位取药数量【{msg.Quantitys}】");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _status; set => SetProperty(ref _status, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderInfo? _orderInfo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public OrderInfo? OrderInfo
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _orderInfo;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _orderInfo, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderDetail> orderDetails { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
					 | 
				
			||||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return Status == 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            OrderInfo o = parameters.GetValue<OrderInfo>("orderInfo");
 | 
					 | 
				
			||||||
            OrderInfo = o;
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
					 | 
				
			||||||
                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
					 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "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);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            _portUtil.WindowName = "OrderTakeDrugWindow";
 | 
					 | 
				
			||||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
					 | 
				
			||||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
					 | 
				
			||||||
            _portUtil.DrawerNo = DrawerNo;
 | 
					 | 
				
			||||||
            _portUtil.Start();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isFinishClick = false;
 | 
					 | 
				
			||||||
        // 完成按钮
 | 
					 | 
				
			||||||
        public DelegateCommand TakeFinish
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!_isFinishClick)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _isFinishClick = true;
 | 
					 | 
				
			||||||
                    List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
 | 
					 | 
				
			||||||
                    if (record.Count > 0)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        string InvoiceId = OrderInfo.OrderNo;
 | 
					 | 
				
			||||||
                        var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                DmStatus = 1,
 | 
					 | 
				
			||||||
                                OrderNo = OrderInfo.OrderNo
 | 
					 | 
				
			||||||
                            }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                OrderNo = OrderInfo.OrderNo,
 | 
					 | 
				
			||||||
                                PatientId = OrderInfo.PatientId,
 | 
					 | 
				
			||||||
                                Pharmacy = OrderInfo.Pharmacy,
 | 
					 | 
				
			||||||
                                State = 1,
 | 
					 | 
				
			||||||
                                Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
					 | 
				
			||||||
                            });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            for (int i = 0; i < record.Count; i++)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                ChannelStock it = record[i];
 | 
					 | 
				
			||||||
                                // 更新数据 库存信息
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Quantity = it.Quantity - it.TakeQuantity,
 | 
					 | 
				
			||||||
                                    ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = it.EffDate,
 | 
					 | 
				
			||||||
                                    Id = it.Id,
 | 
					 | 
				
			||||||
                                }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
 | 
					 | 
				
			||||||
                                // 获取更新完库存后的药品库存
 | 
					 | 
				
			||||||
                                List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
					 | 
				
			||||||
                                    .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                                    .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                // 保存数据 出库记录
 | 
					 | 
				
			||||||
                                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    MachineId = it.MachineId,
 | 
					 | 
				
			||||||
                                    DrawerNo = it.DrawerNo,
 | 
					 | 
				
			||||||
                                    ColNo = it.ColNo,
 | 
					 | 
				
			||||||
                                    DrugId = it.DrugId,
 | 
					 | 
				
			||||||
                                    ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                    EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
					 | 
				
			||||||
                                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                                    Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                    OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                    Quantity = it.TakeQuantity,
 | 
					 | 
				
			||||||
                                    Type = 2,
 | 
					 | 
				
			||||||
                                    InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                                    StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                                }).ExecuteCommand();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,274 +0,0 @@
 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Drawing.Printing;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class OrderTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageNum = 1;
 | 
					 | 
				
			||||||
        public int PageNum
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageNum;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageNum, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageCount = 1;
 | 
					 | 
				
			||||||
        public int PageCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageSize = 8;
 | 
					 | 
				
			||||||
        public int PageSize
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageSize;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageSize, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _totalCount = 0;
 | 
					 | 
				
			||||||
        public int TotalCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _totalCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _totalCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private DelegateCommand _rowSelected;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public OrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "OrderNo",
 | 
					 | 
				
			||||||
                Name = "处方号"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "PatientId",
 | 
					 | 
				
			||||||
                Name = "患者编号"
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderTakeSelects; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _orderTakeSelects, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public OrderTakeSelect SelectedItem
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedItem; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedItem, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderInfo? _selectedOrder;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public OrderInfo? SelectedOrder
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedOrder; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedOrder, value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //OpenOrderDialog();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件  处方日期
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string OrderDate
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderDate; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!String.IsNullOrEmpty(value))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, value);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string? _searchValue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段值
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string? SearchValue
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _searchValue; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _searchValue, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderInfo> _orderInfos = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<OrderInfo> OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async void OpenOrderDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 此处延时1毫秒,等待页面渲染
 | 
					 | 
				
			||||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("orderInfo", SelectedOrder);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 委托   被动执行     被子窗口执行
 | 
					 | 
				
			||||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
					 | 
				
			||||||
            //if(dialogResult.Result == ButtonResult.OK)
 | 
					 | 
				
			||||||
            //{
 | 
					 | 
				
			||||||
            SelectedOrder = null;
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand QueryCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            OrderInfos.Clear();
 | 
					 | 
				
			||||||
            int totalCount = 0;
 | 
					 | 
				
			||||||
            //string SearchValue = null;
 | 
					 | 
				
			||||||
            //if (SearchValue != null)
 | 
					 | 
				
			||||||
            //{
 | 
					 | 
				
			||||||
            //    strSearchValue = SearchValue.Trim().Replace("\r", "");
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
					 | 
				
			||||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
					 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
 | 
					 | 
				
			||||||
                .WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
					 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
 | 
					 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
					 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
					 | 
				
			||||||
                .Where(oi => oi.DmStatus == 0)
 | 
					 | 
				
			||||||
                .Where(oi => oi.HisDispFlag == 0)
 | 
					 | 
				
			||||||
                .Where(oi => oi.CancelFlag == 0)
 | 
					 | 
				
			||||||
                .GroupBy(oi => oi.OrderDate)
 | 
					 | 
				
			||||||
                .Select(oi => oi)
 | 
					 | 
				
			||||||
                .ToPageList(PageNum, PageSize, ref totalCount);
 | 
					 | 
				
			||||||
            //.ToList();
 | 
					 | 
				
			||||||
            OrderInfos = queryData;
 | 
					 | 
				
			||||||
            TotalCount = totalCount;
 | 
					 | 
				
			||||||
            PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
					 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
					 | 
				
			||||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求
 | 
					 | 
				
			||||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (msg.EventType == EventType.CODESCAN)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SearchValue = msg.Code;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,36 +0,0 @@
 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Collections.ObjectModel;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    [Serializable]
 | 
					 | 
				
			||||||
    public class PremissionViewModel: BindableBase
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        private int _id;
 | 
					 | 
				
			||||||
        private string _premissionName;
 | 
					 | 
				
			||||||
        private string _premissionPath;
 | 
					 | 
				
			||||||
        private string _premissionImage;
 | 
					 | 
				
			||||||
        private List<PremissionViewModel> _children = new List<PremissionViewModel>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Id { get => _id; set => SetProperty(ref _id, value); }
 | 
					 | 
				
			||||||
        public string PremissionName { get => _premissionName; set => SetProperty(ref _premissionName, value); }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 菜单路径 
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        public string PremissionPath { get => _premissionPath; set => SetProperty(ref _premissionPath, value); }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 图片source 
 | 
					 | 
				
			||||||
        ///</summary>
 | 
					 | 
				
			||||||
        public string PremissionImage { get => _premissionImage; set => SetProperty(ref _premissionImage, value); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<PremissionViewModel> Children { get => _children; set => SetProperty(ref _children, value); }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,331 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using log4net.Repository.Hierarchy;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class ReturnDrugDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(ReturnDrugDialogViewModel));
 | 
					 | 
				
			||||||
        public string Title => "归还药品(记录)";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string WindowName = "ReturnDrug1Window";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private MachineRecord _machineRecord;
 | 
					 | 
				
			||||||
        public MachineRecord MachineRecord
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _machineRecord; }
 | 
					 | 
				
			||||||
            set { SetProperty(ref _machineRecord, value); }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ReturnDrugDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (msg.WindowName.Equals(WindowName))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 2;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 2)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 3;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        try
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (Status == 2)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                ReturnQuantity = msg.Quantitys[ChannelStock.ColNo - 1];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                logger.Info($"抽屉【{ChannelStock.DrawerNo}】库位药品数量【{msg.Quantitys}】");
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        catch (Exception e)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            logger.Error(e);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _status; set => SetProperty(ref _status, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private ChannelStock _channelStock;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ChannelStock ChannelStock
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStock;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStock, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _returnQuantity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int ReturnQuantity
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _returnQuantity;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (value < 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    throw new ArgumentException("还药数量不能是负数");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (value > MachineRecord.CanReturnQuantity)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    throw new ArgumentException("还药数量超出");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                SetProperty(ref _returnQuantity, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return Status == 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            MachineRecord _record = parameters.GetValue<MachineRecord>("record");
 | 
					 | 
				
			||||||
            MachineRecord = _record;
 | 
					 | 
				
			||||||
            ReturnQuantity = MachineRecord.CanReturnQuantity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                .Where(cs => cs.DrugId == MachineRecord.DrugId)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                .WhereIF(MachineRecord.ManuNo != null,cs => cs.ManuNo == MachineRecord.ManuNo)
 | 
					 | 
				
			||||||
                .OrderBy(cs => cs.DrawerNo)
 | 
					 | 
				
			||||||
                .OrderBy(cs => cs.ColNo)
 | 
					 | 
				
			||||||
                .ToList();
 | 
					 | 
				
			||||||
            ChannelStocks = queryData;
 | 
					 | 
				
			||||||
            if(ChannelStocks.Count > 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                ChannelStock = ChannelStocks[0];
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand OpenDrawer
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (ChannelStock != null)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    Status = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    _portUtil.SpeakAsync("正在打开" + ChannelStock.DrawerNo + "号抽屉");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    _portUtil.WindowName = WindowName;
 | 
					 | 
				
			||||||
                    _portUtil.BoardType = ChannelStock.BoardType;
 | 
					 | 
				
			||||||
                    _portUtil.ColNos = new int[] { ChannelStock.ColNo };
 | 
					 | 
				
			||||||
                    _portUtil.DrawerNo = ChannelStock.DrawerNo;
 | 
					 | 
				
			||||||
                    _portUtil.Start();
 | 
					 | 
				
			||||||
                } else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        Message = "请选择退还药品要放入的库位!",
 | 
					 | 
				
			||||||
                        Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                    };
 | 
					 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }, () => Status == 0);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isFinishClick = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool IsFinishClick { get => _isFinishClick; set => SetProperty(ref _isFinishClick, value); }
 | 
					 | 
				
			||||||
        // 完成按钮
 | 
					 | 
				
			||||||
        public DelegateCommand TakeFinish
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IsFinishClick = true;
 | 
					 | 
				
			||||||
                string InvoiceId = "RETURN_" + CurrentTimeMillis();
 | 
					 | 
				
			||||||
                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                        
 | 
					 | 
				
			||||||
                    // 更新数据 库存信息
 | 
					 | 
				
			||||||
                    SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        Quantity = ChannelStock.Quantity + ReturnQuantity,
 | 
					 | 
				
			||||||
                        Id = ChannelStock.Id,
 | 
					 | 
				
			||||||
                    }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    // 获取更新完库存后的药品库存
 | 
					 | 
				
			||||||
                    List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                        .Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
 | 
					 | 
				
			||||||
                        .Where(cs => cs.DrugId.Equals(ChannelStock.DrugId))
 | 
					 | 
				
			||||||
                        .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                        .ToList();
 | 
					 | 
				
			||||||
                    // 更新数据 取药记录 设置还药数量、状态
 | 
					 | 
				
			||||||
                    SqlSugarHelper.Db.Updateable(new MachineRecord()
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        ReturnQuantity1 = MachineRecord.ReturnQuantity1 + ReturnQuantity,
 | 
					 | 
				
			||||||
                        Id = MachineRecord.Id,
 | 
					 | 
				
			||||||
                        Status = (MachineRecord.CanReturnQuantity - ReturnQuantity) == 0 ? 2 : 1,
 | 
					 | 
				
			||||||
                    }).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    // 保存数据 还药记录
 | 
					 | 
				
			||||||
                    SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            MachineId = ChannelStock.MachineId,
 | 
					 | 
				
			||||||
                            DrawerNo = ChannelStock.DrawerNo,
 | 
					 | 
				
			||||||
                            ColNo = ChannelStock.ColNo,
 | 
					 | 
				
			||||||
                            DrugId = ChannelStock.DrugId,
 | 
					 | 
				
			||||||
                            ManuNo = ChannelStock.ManuNo,
 | 
					 | 
				
			||||||
                            EffDate = !String.IsNullOrEmpty(ChannelStock.EffDate) ? DateTime.ParseExact(ChannelStock.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
					 | 
				
			||||||
                            Operator = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                            OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                            Quantity = ReturnQuantity,
 | 
					 | 
				
			||||||
                            Type = 31,
 | 
					 | 
				
			||||||
                            InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                            GetId = MachineRecord.Id,
 | 
					 | 
				
			||||||
                            StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                        }).ExecuteCommand();
 | 
					 | 
				
			||||||
                    return true;
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
                if (f.Data)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 更新屏显库存
 | 
					 | 
				
			||||||
                    if (ChannelStock.BoardType == 5)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        Message = "操作完成,库存已更新",
 | 
					 | 
				
			||||||
                        Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                    };
 | 
					 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (!f.IsSuccess)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        Message = "库存更新失败!",
 | 
					 | 
				
			||||||
                        Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                    };
 | 
					 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
                IsFinishClick = false;
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }, () => !IsFinishClick && ReturnQuantity > 0).ObservesProperty(() => IsFinishClick).ObservesProperty(() => ReturnQuantity);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public long CurrentTimeMillis()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 取消按钮
 | 
					 | 
				
			||||||
        public DelegateCommand CancleTake
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IsFinishClick = false;
 | 
					 | 
				
			||||||
                _portUtil.ResetData();
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BtnCloseCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 关闭当前窗口
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
            }, () => Status == 0).ObservesProperty(() => Status);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,254 +0,0 @@
 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class ReturnDrugWindow2ViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageNum = 1;
 | 
					 | 
				
			||||||
        public int PageNum
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageNum;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageNum, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageCount = 1;
 | 
					 | 
				
			||||||
        public int PageCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _pageSize = 8;
 | 
					 | 
				
			||||||
        public int PageSize
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _pageSize;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _pageSize, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _totalCount = 0;
 | 
					 | 
				
			||||||
        public int TotalCount
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _totalCount;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _totalCount, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        //刷新
 | 
					 | 
				
			||||||
        public DelegateCommand Query
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private DelegateCommand _rowSelected;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ReturnDrugWindow2ViewModel(IDialogService DialogService)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "OrderNo",
 | 
					 | 
				
			||||||
                Name = "处方号"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "PatientId",
 | 
					 | 
				
			||||||
                Name = "患者编号"
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<OrderTakeSelect> OrderTakeSelects
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderTakeSelects; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _orderTakeSelects, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public OrderTakeSelect SelectedItem
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedItem; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedItem, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderInfo? _selectedOrder;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public OrderInfo? SelectedOrder
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedOrder; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedOrder, value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //OpenOrderDialog();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件  处方日期
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string OrderDate
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _orderDate; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!String.IsNullOrEmpty(value))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _orderDate, value);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string? _searchValue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段值
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string? SearchValue
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _searchValue; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _searchValue, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderInfo> _orderInfos = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<OrderInfo> OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async void OpenOrderDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            //if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
 | 
					 | 
				
			||||||
            if (SelectedOrder != null && SelectedOrder.DmStatus == 1 && SelectedOrder.CancelFlag == 1 && SelectedOrder.HisDispFlag == 1)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 此处延时1毫秒,等待页面渲染
 | 
					 | 
				
			||||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("orderInfo", SelectedOrder);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderReturnDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 委托   被动执行     被子窗口执行
 | 
					 | 
				
			||||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
					 | 
				
			||||||
            if (dialogResult.Result == ButtonResult.OK)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SelectedOrder = null;
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            OrderInfos.Clear();
 | 
					 | 
				
			||||||
            int totalCount = 0;
 | 
					 | 
				
			||||||
            List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
 | 
					 | 
				
			||||||
                .InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
 | 
					 | 
				
			||||||
                .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "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)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,216 +0,0 @@
 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class ReturnDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private DelegateCommand _rowSelected;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ReturnDrugWindowViewModel(IDialogService DialogService)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        //刷新
 | 
					 | 
				
			||||||
        public DelegateCommand Query
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "DrugName",
 | 
					 | 
				
			||||||
                Name = "药品名称"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "PyCode",
 | 
					 | 
				
			||||||
                Name = "拼音码"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "DrugBarcode",
 | 
					 | 
				
			||||||
                Name = "药品条码"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "DrugId",
 | 
					 | 
				
			||||||
                Name = "药品编码"
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<OrderTakeSelect> Selects
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selects; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selects, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public OrderTakeSelect SelectedItem
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedItem; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedItem, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private MachineRecord? _selectedRecord;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public MachineRecord? SelectedRecord
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedRecord; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedRecord, value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //OpenOrderDialog();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string _queryDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件  处方日期
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string QueryDate
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _queryDate; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!String.IsNullOrEmpty(value))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _queryDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    SetProperty(ref _queryDate, value);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string? _searchValue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段值
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string? SearchValue
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _searchValue; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _searchValue, value);
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<MachineRecord> _machineRecords = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<MachineRecord> MachineRecords { get { return _machineRecords; } set { SetProperty(ref _machineRecords, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async void OpenOrderDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (SelectedRecord != null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 此处延时1毫秒,等待页面渲染
 | 
					 | 
				
			||||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                dialogParameters.Add("record", SelectedRecord);
 | 
					 | 
				
			||||||
                DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnDrugDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 委托   被动执行     被子窗口执行
 | 
					 | 
				
			||||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
					 | 
				
			||||||
            //if (dialogResult.Result == ButtonResult.OK)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SelectedRecord = null;
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            List<MachineRecord> queryData = SqlSugarHelper.Db.Queryable<MachineRecord>()
 | 
					 | 
				
			||||||
                .Includes<DrugInfo>(mr => mr.DrugInfo)
 | 
					 | 
				
			||||||
                .Includes<UserList>(mr => mr.User)
 | 
					 | 
				
			||||||
                .Where(mr => mr.Type == 2)
 | 
					 | 
				
			||||||
                .Where(mr => mr.Status < 2)
 | 
					 | 
				
			||||||
                .Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "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)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,356 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using log4net.Repository.Hierarchy;
 | 
					 | 
				
			||||||
using Newtonsoft.Json.Linq;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using DM_Weight.Views;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class ReturnEmptyDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(ReturnEmptyDialogViewModel));
 | 
					 | 
				
			||||||
        public string Title => "归还空瓶(记录)";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string WindowName = "ReturnEmpty1Window";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ReturnEmptyDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (msg.WindowName.Equals(WindowName))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 2;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 2)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Status = 3;
 | 
					 | 
				
			||||||
                            if(ChannelStock.DrawerType == 3)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                ReturnQuantity = msg.Quantitys[0];
 | 
					 | 
				
			||||||
                                logger.Info($"抽屉【{ChannelStock.DrawerNo}】回收库位药品数量增加【{msg.Quantitys[0]}】");
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 2)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            ReturnQuantity = msg.Quantitys[0];
 | 
					 | 
				
			||||||
                            logger.Info($"抽屉【{ChannelStock.DrawerNo}】回收库位药品数量增加【{msg.Quantitys[0]}】");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _returnQuantity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int ReturnQuantity
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _returnQuantity;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (value < 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    throw new ArgumentException("还药数量不能是负数");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                //if (value > MachineRecord.CanReturnQuantity)
 | 
					 | 
				
			||||||
                //{
 | 
					 | 
				
			||||||
                //    throw new ArgumentException("还药数量超出");
 | 
					 | 
				
			||||||
                //}
 | 
					 | 
				
			||||||
                SetProperty(ref _returnQuantity, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _status; set => SetProperty(ref _status, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<MachineRecord> _machineRecords = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<MachineRecord> MachineRecords
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _machineRecords;
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _machineRecords, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private 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.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)
 | 
					 | 
				
			||||||
                            }).ExecuteCommand();
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        return true;
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                    if (f.Data)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        // 更新屏显库存
 | 
					 | 
				
			||||||
                        if (ChannelStock.BoardType == 5)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "操作完成,库存已更新",
 | 
					 | 
				
			||||||
                            Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    if (!f.IsSuccess)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "库存更新失败!",
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    Status = 0;
 | 
					 | 
				
			||||||
                    IsFinishClick = false;
 | 
					 | 
				
			||||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
					 | 
				
			||||||
                } else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        Message = "选择的归还数目与实际数目不符",
 | 
					 | 
				
			||||||
                        Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                    };
 | 
					 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    IsFinishClick = false;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }, () => !IsFinishClick && ReturnQuantity > 0).ObservesProperty(() => IsFinishClick).ObservesProperty(() => ReturnQuantity);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public long CurrentTimeMillis()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 取消按钮
 | 
					 | 
				
			||||||
        public DelegateCommand CancleTake
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IsFinishClick = false;
 | 
					 | 
				
			||||||
                _portUtil.ResetData();
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BtnCloseCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status != 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _portUtil.ResetData();
 | 
					 | 
				
			||||||
                    Status = 0;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                //DialogParameters parameters = new DialogParameters();
 | 
					 | 
				
			||||||
                //parameters.Add("",);
 | 
					 | 
				
			||||||
                // 关闭当前窗口
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,134 +0,0 @@
 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -104,7 +104,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    // 父菜单
 | 
					                    // 父菜单
 | 
				
			||||||
                    PremissionDm p = AllPremissions.ToList().Find(it2 => it2.Id == it.Id);
 | 
					                    PremissionDm p = AllPremissions.ToList().Find(it2 => it2.Id == it.Id);
 | 
				
			||||||
                    int index = AllPremissions.ToList().FindIndex(it2 => it2.Id == it.Id);
 | 
					                    int index = AllPremissions.ToList().FindIndex(it2 => it2.Id == it.Id);
 | 
				
			||||||
 | 
					                    if (p != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
                        if (p != null && p.Children != null && it != null && it.Children != null && p.Children.Count == it.Children.Count)
 | 
					                        if (p != null && p.Children != null && it != null && it.Children != null && p.Children.Count == it.Children.Count)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            AllPremissions.RemoveAt(index);
 | 
					                            AllPremissions.RemoveAt(index);
 | 
				
			||||||
| 
						 | 
					@ -133,6 +134,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                AllPremissions.RemoveAt(index);
 | 
					                                AllPremissions.RemoveAt(index);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                RightPremissions = new ObservableCollection<PremissionDm>(Permissions);
 | 
					                RightPremissions = new ObservableCollection<PremissionDm>(Permissions);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -161,22 +164,74 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            PremissionDm quyao = new PremissionDm
 | 
					            PremissionDm quyao = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 1,
 | 
					                Id = 1,
 | 
				
			||||||
                PremissionName = "取药",
 | 
					                //PremissionName = "取药",
 | 
				
			||||||
 | 
					                PremissionName = "药箱操作",
 | 
				
			||||||
                PremissionImage = "/Images/TbQyao.png",
 | 
					                PremissionImage = "/Images/TbQyao.png",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>();
 | 
					            ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
            PremissionDm quyao1 = new PremissionDm
 | 
					            //PremissionDm quyao1 = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 11,
 | 
				
			||||||
 | 
					            //    PremissionName = "处方取药",
 | 
				
			||||||
 | 
					            //    PremissionPath = "OrderTakeDrugWindow",
 | 
				
			||||||
 | 
					            //};  
 | 
				
			||||||
 | 
					            //PremissionDm quyao1 = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 11,
 | 
				
			||||||
 | 
					            //    PremissionName = "处方取药",
 | 
				
			||||||
 | 
					            //    PremissionPath = "OrderTakeDrugNewWindow",
 | 
				
			||||||
 | 
					            //};    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //开药箱
 | 
				
			||||||
 | 
					            //PremissionDm openBox = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 11,
 | 
				
			||||||
 | 
					            //    PremissionName = "开药箱",
 | 
				
			||||||
 | 
					            //    PremissionPath = "OpenBoxWindow",
 | 
				
			||||||
 | 
					            //};
 | 
				
			||||||
 | 
					            //开药箱
 | 
				
			||||||
 | 
					            //PremissionDm openBox = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 11,
 | 
				
			||||||
 | 
					            //    PremissionName = "开药箱",
 | 
				
			||||||
 | 
					            //    PremissionPath = "OpenBoxNewWindow",
 | 
				
			||||||
 | 
					            //};
 | 
				
			||||||
 | 
					            //开药箱核对名下单子
 | 
				
			||||||
 | 
					            PremissionDm openBoxWithOrder = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 11,
 | 
					                Id = 11,
 | 
				
			||||||
                PremissionName = "处方取药",
 | 
					                PremissionName = "操作药箱",
 | 
				
			||||||
                PremissionPath = "OrderTakeDrugWindow",
 | 
					                PremissionPath = "CheckSelfOrderWindow",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            PremissionDm quyao2 = new PremissionDm
 | 
					            //核对处方
 | 
				
			||||||
 | 
					            PremissionDm checkOrder = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 12,
 | 
					                Id = 12,
 | 
				
			||||||
                PremissionName = "调拨出库",
 | 
					                PremissionName = "核对处方",
 | 
				
			||||||
                PremissionPath = "InvoiceOutWindow",
 | 
					                //PremissionPath = "CheckOrderWindow",
 | 
				
			||||||
 | 
					                PremissionPath = "CheckOrderNewWindow",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					            //核对处方
 | 
				
			||||||
 | 
					            PremissionDm addition = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 13,
 | 
				
			||||||
 | 
					                PremissionName = "药箱补药",
 | 
				
			||||||
 | 
					                //PremissionPath = "CheckOrderWindow",
 | 
				
			||||||
 | 
					                PremissionPath = "AdditionWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //PremissionDm quyao1 = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 11,
 | 
				
			||||||
 | 
					            //    PremissionName = "交接柜补药",
 | 
				
			||||||
 | 
					            //    PremissionPath = "AddToJiaoJieWindow",
 | 
				
			||||||
 | 
					            //};
 | 
				
			||||||
 | 
					            //PremissionDm quyao2 = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 12,
 | 
				
			||||||
 | 
					            //    PremissionName = "调拨出库",
 | 
				
			||||||
 | 
					            //    PremissionPath = "InvoiceOutWindow",
 | 
				
			||||||
 | 
					            //};
 | 
				
			||||||
            PremissionDm quyao3 = new PremissionDm
 | 
					            PremissionDm quyao3 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 13,
 | 
					                Id = 13,
 | 
				
			||||||
| 
						 | 
					@ -203,14 +258,19 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    PremissionName = "多处方取药",
 | 
					                    PremissionName = "多处方取药",
 | 
				
			||||||
                    PremissionPath = "MultiOrderTakeDrugWindow",
 | 
					                    PremissionPath = "MultiOrderTakeDrugWindow",
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                quyaoChild.Add(mulityOrder);
 | 
					                //quyaoChild.Add(mulityOrder);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            quyaoChild.Add(quyao1);
 | 
					
 | 
				
			||||||
            quyaoChild.Add(quyao2);
 | 
					            //quyaoChild.Add(quyao1);
 | 
				
			||||||
            quyaoChild.Add(quyao3);
 | 
					            //quyaoChild.Add(quyao2);
 | 
				
			||||||
            quyaoChild.Add(quyao4);
 | 
					            //quyaoChild.Add(quyao3);
 | 
				
			||||||
            quyaoChild.Add(quyao5);
 | 
					            //quyaoChild.Add(quyao4);
 | 
				
			||||||
 | 
					            //quyaoChild.Add(quyao5);
 | 
				
			||||||
 | 
					            //quyaoChild.Add(openBox);
 | 
				
			||||||
 | 
					            quyaoChild.Add(checkOrder);
 | 
				
			||||||
 | 
					            quyaoChild.Add(addition);
 | 
				
			||||||
 | 
					            quyaoChild.Add(openBoxWithOrder);
 | 
				
			||||||
            quyao.Children = quyaoChild;
 | 
					            quyao.Children = quyaoChild;
 | 
				
			||||||
            defaultAll.Add(quyao);
 | 
					            defaultAll.Add(quyao);
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
| 
						 | 
					@ -256,12 +316,34 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                jiayaoChild.Add(jiayao5);
 | 
					                jiayaoChild.Add(jiayao5);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            jiayaoChild.Add(jiayao1);
 | 
					            PremissionDm jiayao6 = new PremissionDm
 | 
				
			||||||
            jiayaoChild.Add(jiayao2);
 | 
					            {
 | 
				
			||||||
            jiayaoChild.Add(jiayao3);
 | 
					                Id = 26,
 | 
				
			||||||
            jiayaoChild.Add(jiayao4);
 | 
					                PremissionName = "药品请领",
 | 
				
			||||||
            jiayao.Children = jiayaoChild;
 | 
					                PremissionPath = "CollectDrugWindow",
 | 
				
			||||||
            defaultAll.Add(jiayao);
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            PremissionDm jiayao7 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 27,
 | 
				
			||||||
 | 
					                PremissionName = "请领列表",
 | 
				
			||||||
 | 
					                PremissionPath = "ApplyListWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm jiayao8 = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 28,
 | 
				
			||||||
 | 
					                PremissionName = "请领入库",
 | 
				
			||||||
 | 
					                PremissionPath = "ApplyInStockWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            //jiayaoChild.Add(jiayao1);
 | 
				
			||||||
 | 
					            //jiayaoChild.Add(jiayao2);
 | 
				
			||||||
 | 
					            //jiayaoChild.Add(jiayao3);
 | 
				
			||||||
 | 
					            //jiayaoChild.Add(jiayao6);
 | 
				
			||||||
 | 
					            //jiayaoChild.Add(jiayao7);
 | 
				
			||||||
 | 
					            //jiayaoChild.Add(jiayao8);
 | 
				
			||||||
 | 
					            //jiayaoChild.Add(jiayao4);
 | 
				
			||||||
 | 
					            //jiayao.Children = jiayaoChild;
 | 
				
			||||||
 | 
					            //defaultAll.Add(jiayao);
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
            #region 还药菜单
 | 
					            #region 还药菜单
 | 
				
			||||||
            PremissionDm huanyao = new PremissionDm
 | 
					            PremissionDm huanyao = new PremissionDm
 | 
				
			||||||
| 
						 | 
					@ -283,11 +365,17 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                PremissionName = "归还药品",
 | 
					                PremissionName = "归还药品",
 | 
				
			||||||
                PremissionPath = "ReturnDrugWindow2",
 | 
					                PremissionPath = "ReturnDrugWindow2",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					            //PremissionDm huanyao2 = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 32,
 | 
				
			||||||
 | 
					            //    PremissionName = "归还空瓶",
 | 
				
			||||||
 | 
					            //    PremissionPath = "ReturnEmptyWindow",
 | 
				
			||||||
 | 
					            //};
 | 
				
			||||||
            PremissionDm huanyao2 = new PremissionDm
 | 
					            PremissionDm huanyao2 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 32,
 | 
					                Id = 32,
 | 
				
			||||||
                PremissionName = "归还空瓶",
 | 
					                PremissionName = "空瓶取出",
 | 
				
			||||||
                PremissionPath = "ReturnEmptyWindow",
 | 
					                PremissionPath = "ReturnEmptyDestoryWindow",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            PremissionDm huanyao3 = new PremissionDm
 | 
					            PremissionDm huanyao3 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -295,50 +383,71 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                PremissionName = "归还记录",
 | 
					                PremissionName = "归还记录",
 | 
				
			||||||
                PremissionPath = "ReturnRecordWindow",
 | 
					                PremissionPath = "ReturnRecordWindow",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1);
 | 
					            //PremissionDm surgery = new PremissionDm
 | 
				
			||||||
            huanyaoChild.Add(huanyao2);
 | 
					            //{
 | 
				
			||||||
            huanyaoChild.Add(huanyao3);
 | 
					            //    Id = 17,
 | 
				
			||||||
            huanyao.Children = huanyaoChild;
 | 
					            //    PremissionName = "手术核销",
 | 
				
			||||||
            defaultAll.Add(huanyao);
 | 
					            //    PremissionPath = "SurgeryTakeWindow"
 | 
				
			||||||
 | 
					            //};
 | 
				
			||||||
 | 
					            //huanyaoChild.Add(Convert.ToInt32(ConfigurationManager.AppSettings["returnDrugMode"]) == 1 ? huanyao11 : huanyao1);
 | 
				
			||||||
 | 
					            //huanyaoChild.Add(huanyao2);
 | 
				
			||||||
 | 
					            ////huanyaoChild.Add(surgery);
 | 
				
			||||||
 | 
					            //huanyaoChild.Add(huanyao3);
 | 
				
			||||||
 | 
					            //huanyao.Children = huanyaoChild;
 | 
				
			||||||
 | 
					            //defaultAll.Add(huanyao);
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
            #region 库存管理菜单 
 | 
					            #region 库存管理菜单 
 | 
				
			||||||
            PremissionDm kuguan = new PremissionDm
 | 
					            //PremissionDm kuguan = new PremissionDm
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                Id = 4,
 | 
					            //    Id = 4,
 | 
				
			||||||
                PremissionName = "库存管理",
 | 
					            //    PremissionName = "库存管理",
 | 
				
			||||||
                PremissionImage = "/Images/TbKuc.png",
 | 
					            //    PremissionImage = "/Images/TbKuc.png",
 | 
				
			||||||
            };
 | 
					            //};
 | 
				
			||||||
            ObservableCollection<PremissionDm> kuguanChild = new ObservableCollection<PremissionDm>();
 | 
					            //ObservableCollection<PremissionDm> kuguanChild = new ObservableCollection<PremissionDm>();
 | 
				
			||||||
            PremissionDm kuguan1 = new PremissionDm
 | 
					            //PremissionDm kuguan1 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                Id = 41,
 | 
					            //    Id = 41,
 | 
				
			||||||
                PremissionName = "库存列表",
 | 
					            //    PremissionName = "库存列表",
 | 
				
			||||||
                PremissionPath = "StockListWindow",
 | 
					            //    PremissionPath = "StockListWindow",
 | 
				
			||||||
            };
 | 
					            //};
 | 
				
			||||||
            PremissionDm kuguan2 = new PremissionDm
 | 
					            //PremissionDm kuguan2 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                Id = 42,
 | 
					            //    Id = 42,
 | 
				
			||||||
                PremissionName = "库存盘点",
 | 
					            //    PremissionName = "库存盘点",
 | 
				
			||||||
                PremissionPath = "CheckStockWindow",
 | 
					            //    PremissionPath = "CheckStockWindow",
 | 
				
			||||||
            };
 | 
					            //};
 | 
				
			||||||
            PremissionDm kuguan3 = new PremissionDm
 | 
					            //PremissionDm kuguan3 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                Id = 43,
 | 
					            //    Id = 43,
 | 
				
			||||||
                PremissionName = "盘点记录",
 | 
					            //    PremissionName = "盘点记录",
 | 
				
			||||||
                PremissionPath = "CheckRecordWindow",
 | 
					            //    PremissionPath = "CheckRecordWindow",
 | 
				
			||||||
            };
 | 
					            //};
 | 
				
			||||||
            PremissionDm kuguan4 = new PremissionDm
 | 
					            //PremissionDm kuguan4 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                Id = 44,
 | 
					            //    Id = 44,
 | 
				
			||||||
                PremissionName = "药品列表",
 | 
					            //    PremissionName = "药品列表",
 | 
				
			||||||
                PremissionPath = "DrugListWindow",
 | 
					            //    PremissionPath = "DrugListWindow",
 | 
				
			||||||
            };
 | 
					            //};
 | 
				
			||||||
            kuguanChild.Add(kuguan1);
 | 
					            //PremissionDm kuguan5 = new PremissionDm
 | 
				
			||||||
            kuguanChild.Add(kuguan2);
 | 
					            //{
 | 
				
			||||||
            kuguanChild.Add(kuguan3);
 | 
					            //    Id = 45,
 | 
				
			||||||
            kuguanChild.Add(kuguan4);
 | 
					            //    PremissionName = "交接班记录",
 | 
				
			||||||
            kuguan.Children = kuguanChild;
 | 
					            //    PremissionPath = "ChangeShiftsListWindow",
 | 
				
			||||||
            defaultAll.Add(kuguan);
 | 
					            //};
 | 
				
			||||||
 | 
					            //PremissionDm kuguan6 = new PremissionDm
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    Id = 46,
 | 
				
			||||||
 | 
					            //    PremissionName = "账册",
 | 
				
			||||||
 | 
					            //    PremissionPath = "AccountWindow",
 | 
				
			||||||
 | 
					            //};
 | 
				
			||||||
 | 
					            //kuguanChild.Add(kuguan1);
 | 
				
			||||||
 | 
					            //kuguanChild.Add(kuguan2);
 | 
				
			||||||
 | 
					            //kuguanChild.Add(kuguan4);
 | 
				
			||||||
 | 
					            //kuguanChild.Add(kuguan6);
 | 
				
			||||||
 | 
					            //kuguanChild.Add(kuguan3);
 | 
				
			||||||
 | 
					            //kuguanChild.Add(kuguan5);
 | 
				
			||||||
 | 
					            //kuguan.Children = kuguanChild;
 | 
				
			||||||
 | 
					            //defaultAll.Add(kuguan);
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
            #region 系统设置菜单
 | 
					            #region 系统设置菜单
 | 
				
			||||||
            PremissionDm sysset = new PremissionDm
 | 
					            PremissionDm sysset = new PremissionDm
 | 
				
			||||||
| 
						 | 
					@ -363,12 +472,55 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            PremissionDm sysset3 = new PremissionDm
 | 
					            PremissionDm sysset3 = new PremissionDm
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Id = 53,
 | 
					                Id = 53,
 | 
				
			||||||
                PremissionName = "设置",
 | 
					                PremissionName = "绑定药品",
 | 
				
			||||||
                PremissionPath = "SettingWindow",
 | 
					                PremissionPath = "BindBoxPackageWindow",
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm settingBox = new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 54,
 | 
				
			||||||
 | 
					                PremissionName = "药箱设置",
 | 
				
			||||||
 | 
					                PremissionPath = "SettingBoxWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm  machineRecord= new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 54,
 | 
				
			||||||
 | 
					                PremissionName = "操作记录",
 | 
				
			||||||
 | 
					                PremissionPath = "MachineRecordWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            PremissionDm  wSDRecord= new PremissionDm
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Id = 54,
 | 
				
			||||||
 | 
					                PremissionName = "温湿度记录",
 | 
				
			||||||
 | 
					                PremissionPath = "WSDRecordWindow",
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            //PremissionDm sysset3;
 | 
				
			||||||
 | 
					            //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    //有冰箱,需要冰箱设置(两个冰箱)
 | 
				
			||||||
 | 
					            //    sysset3 = new PremissionDm
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        Id = 53,
 | 
				
			||||||
 | 
					            //        PremissionName = "设置",
 | 
				
			||||||
 | 
					            //        PremissionPath = "SettingMainWindow",
 | 
				
			||||||
 | 
					            //    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //else
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    sysset3 = new PremissionDm
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        Id = 53,
 | 
				
			||||||
 | 
					            //        PremissionName = "设置",
 | 
				
			||||||
 | 
					            //        PremissionPath = "SettingWindow",
 | 
				
			||||||
 | 
					            //    };
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            syssetChild.Add(sysset1);
 | 
					            syssetChild.Add(sysset1);
 | 
				
			||||||
            syssetChild.Add(sysset2);
 | 
					            syssetChild.Add(sysset2);
 | 
				
			||||||
            syssetChild.Add(sysset3);
 | 
					            syssetChild.Add(sysset3);
 | 
				
			||||||
 | 
					            syssetChild.Add(settingBox);
 | 
				
			||||||
 | 
					            syssetChild.Add(machineRecord);
 | 
				
			||||||
 | 
					            syssetChild.Add(wSDRecord);
 | 
				
			||||||
            sysset.Children = syssetChild;
 | 
					            sysset.Children = syssetChild;
 | 
				
			||||||
            defaultAll.Add(sysset);
 | 
					            defaultAll.Add(sysset);
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,344 +0,0 @@
 | 
				
			||||||
using log4net;
 | 
					 | 
				
			||||||
using log4net.Repository.Hierarchy;
 | 
					 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Speech.Synthesis;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
using DM_Weight.Port;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using DM_Weight.Views;
 | 
					 | 
				
			||||||
using System.Threading;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class SelfAddDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(SelfAddDialogViewModel));
 | 
					 | 
				
			||||||
        public string Title => "自选加药";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public event Action<IDialogResult> RequestClose;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private static readonly DateTime Jan1st1970 = new DateTime
 | 
					 | 
				
			||||||
   (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string WindowName = "SelfAddWindow";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public SelfAddDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _portUtil = portUtil;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        void DoMyPrismEvent(DeviceMsg msg)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (msg.WindowName.Equals(WindowName))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
                int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
                List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (msg.EventType)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // 抽屉打开
 | 
					 | 
				
			||||||
                    case EventType.DRAWEROPEN:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 1)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 2);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 抽屉关闭
 | 
					 | 
				
			||||||
                    case EventType.DRAWERCLOSE:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            if (channelStocks[0].process == 2)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                channelStocks.ForEach(it => it.process = 3);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
 | 
					 | 
				
			||||||
                            int DrawerNoBefore = groupingBefore.Key;
 | 
					 | 
				
			||||||
                            if (enumerator.MoveNext())
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
 | 
					 | 
				
			||||||
                                int DrawerNoAfter = groupingAfter.Key;
 | 
					 | 
				
			||||||
                                if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    Thread.Sleep(50);
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                OpenOneByOne();
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            // 已经全部取出
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Status = 3;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 数量变化
 | 
					 | 
				
			||||||
                    case EventType.UPDATEQUANTITY:
 | 
					 | 
				
			||||||
                        if (Status == 1)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    // 打开失败
 | 
					 | 
				
			||||||
                    case EventType.OPENERROR:
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = msg.Message,
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                        Status = 0;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private int _status = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _status; set => SetProperty(ref _status, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => _channelStocks;
 | 
					 | 
				
			||||||
            set => SetProperty(ref _channelStocks, value);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
 | 
					 | 
				
			||||||
        private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool CanCloseDialog()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return Status == 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogClosed()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 取消消息订阅
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void OnDialogOpened(IDialogParameters parameters)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = parameters.GetValue<List<ChannelStock>>("ChannelStocks");
 | 
					 | 
				
			||||||
            ChannelStocks = channelStocks;
 | 
					 | 
				
			||||||
            RequestData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
 | 
					 | 
				
			||||||
            enumerator = enumerable.GetEnumerator();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand OpenDrawer
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status == 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    enumerator.MoveNext();
 | 
					 | 
				
			||||||
                    Status = 1;
 | 
					 | 
				
			||||||
                    OpenOneByOne();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private async void OpenOneByOne()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            IGrouping<int, ChannelStock> grouping = enumerator.Current;
 | 
					 | 
				
			||||||
            int DrawerNo = grouping.Key;
 | 
					 | 
				
			||||||
            List<ChannelStock> channelStocks = grouping.ToList();
 | 
					 | 
				
			||||||
            channelStocks.ForEach(it => it.process = 1);
 | 
					 | 
				
			||||||
            _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
            _portUtil.WindowName = WindowName;
 | 
					 | 
				
			||||||
            _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
 | 
					 | 
				
			||||||
            _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
 | 
					 | 
				
			||||||
            _portUtil.DrawerNo = DrawerNo;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // 发送加药数量
 | 
					 | 
				
			||||||
                singleChannels.ForEach(it =>
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.AddQuantity, it.Quantity + it.AddQuantity);
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 6)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                for(int i = 0; i < singleChannels.Count; i++)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    ChannelStock it = singleChannels[i];
 | 
					 | 
				
			||||||
                    _portUtil.ClearCount(it.DrawerNo, it.ColNo);
 | 
					 | 
				
			||||||
                    await Task.Delay(50);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            _portUtil.Start();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private bool _isFinishClick = false;
 | 
					 | 
				
			||||||
        // 完成按钮
 | 
					 | 
				
			||||||
        public DelegateCommand TakeFinish
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(async () =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (!_isFinishClick)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _isFinishClick = true;
 | 
					 | 
				
			||||||
                    List<ChannelStock> record = ChannelStocks.ToList();
 | 
					 | 
				
			||||||
                    string InvoiceId = "SELF_" + CurrentTimeMillis();
 | 
					 | 
				
			||||||
                    var f = SqlSugarHelper.Db.UseTran(() =>
 | 
					 | 
				
			||||||
                    {   
 | 
					 | 
				
			||||||
                        for (int i = 0; i < record.Count; i++)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            ChannelStock it = record[i];
 | 
					 | 
				
			||||||
                            if (it.BoardType == 6 && it.PosNo == 0)
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            // 更新数据 库存信息
 | 
					 | 
				
			||||||
                            SqlSugarHelper.Db.Updateable(new ChannelStock()
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                Quantity = it.Quantity + it.AddQuantity,
 | 
					 | 
				
			||||||
                                PosNo = 1,
 | 
					 | 
				
			||||||
                                ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                EffDate = it.EffDate,
 | 
					 | 
				
			||||||
                                Id = it.Id,
 | 
					 | 
				
			||||||
                            }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
 | 
					 | 
				
			||||||
                            // 获取更新完库存后的药品库存
 | 
					 | 
				
			||||||
                            List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                                .Where(cs => cs.MachineId.Equals(it.MachineId))
 | 
					 | 
				
			||||||
                                .Where(cs => cs.DrugId.Equals(it.DrugId))
 | 
					 | 
				
			||||||
                                .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                                .ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            // 保存数据 出/入库记录
 | 
					 | 
				
			||||||
                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                MachineId = it.MachineId,
 | 
					 | 
				
			||||||
                                DrawerNo = it.DrawerNo,
 | 
					 | 
				
			||||||
                                ColNo = it.ColNo,
 | 
					 | 
				
			||||||
                                DrugId = it.DrugId,
 | 
					 | 
				
			||||||
                                ManuNo = it.ManuNo,
 | 
					 | 
				
			||||||
                                EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
					 | 
				
			||||||
                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
					 | 
				
			||||||
                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
					 | 
				
			||||||
                                OperationTime = DateTime.Now,
 | 
					 | 
				
			||||||
                                Quantity = it.AddQuantity,
 | 
					 | 
				
			||||||
                                Type = 1,
 | 
					 | 
				
			||||||
                                InvoiceId = InvoiceId,
 | 
					 | 
				
			||||||
                                StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
					 | 
				
			||||||
                            }).ExecuteCommand();
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        return true;
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                    if (f.Data)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        // 更新屏显库存
 | 
					 | 
				
			||||||
                        List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
					 | 
				
			||||||
                        if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            singleChannels.ForEach(it =>
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
 | 
					 | 
				
			||||||
                            });
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "操作完成,库存已更新",
 | 
					 | 
				
			||||||
                            Type = MsgType.SUCCESS,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    if (!f.IsSuccess)
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            Message = "库存更新失败!",
 | 
					 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    Status = 0;
 | 
					 | 
				
			||||||
                    _isFinishClick = false;
 | 
					 | 
				
			||||||
                    RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public long CurrentTimeMillis()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // 取消按钮
 | 
					 | 
				
			||||||
        public DelegateCommand CancleTake
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestData();
 | 
					 | 
				
			||||||
                _portUtil.ResetData();
 | 
					 | 
				
			||||||
                Status = 0;
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand BtnCloseCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (Status != 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _portUtil.ResetData();
 | 
					 | 
				
			||||||
                    Status = 0;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                //DialogParameters parameters = new DialogParameters();
 | 
					 | 
				
			||||||
                //parameters.Add("",);
 | 
					 | 
				
			||||||
                // 关闭当前窗口
 | 
					 | 
				
			||||||
                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,201 +0,0 @@
 | 
				
			||||||
using Prism.Commands;
 | 
					 | 
				
			||||||
using Prism.Mvvm;
 | 
					 | 
				
			||||||
using Prism.Regions;
 | 
					 | 
				
			||||||
using Prism.Services.Dialogs;
 | 
					 | 
				
			||||||
using SqlSugar;
 | 
					 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Configuration;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
using DM_Weight.Models;
 | 
					 | 
				
			||||||
using DM_Weight.select;
 | 
					 | 
				
			||||||
using DM_Weight.util;
 | 
					 | 
				
			||||||
using Prism.Events;
 | 
					 | 
				
			||||||
using DM_Weight.msg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class SelfAddWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        IDialogService _dialogService;
 | 
					 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public static List<OrderTakeSelect> StaticSelects = new()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "DrugName",
 | 
					 | 
				
			||||||
                Name = "药品名称"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "PyCode",
 | 
					 | 
				
			||||||
                Name = "拼音码"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "DrugBarcode",
 | 
					 | 
				
			||||||
                Name = "药品条码"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            new OrderTakeSelect
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Code = "DrugId",
 | 
					 | 
				
			||||||
                Name = "药品编码"
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public SelfAddWindowViewModel(IDialogService DialogService,IEventAggregator eventAggregator)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            _dialogService = DialogService;
 | 
					 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<OrderTakeSelect> _selects = StaticSelects;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<OrderTakeSelect> Selects
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selects; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selects, value);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private OrderTakeSelect _selectedItem = StaticSelects[0];
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public OrderTakeSelect SelectedItem
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _selectedItem; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _selectedItem, value);
 | 
					 | 
				
			||||||
                RequestChannelData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private string? _searchValue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 查询条件 查询字段值
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string? SearchValue
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get { return _searchValue; }
 | 
					 | 
				
			||||||
            set
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                SetProperty(ref _searchValue, value);
 | 
					 | 
				
			||||||
                RequestChannelData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private List<ChannelStock> _channelStocks = new();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand QueryCommand
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestChannelData();
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public DelegateCommand OpenSelfDialog
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            get => new DelegateCommand(() =>
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                List<ChannelStock> addChannels = ChannelStocks.FindAll(it => it.AddQuantity > 0).ToList();
 | 
					 | 
				
			||||||
                if (addChannels.Count > 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    addChannels.Sort((a, b) =>
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        if ((a.DrawerNo - b.DrawerNo) == 0)
 | 
					 | 
				
			||||||
                        {
 | 
					 | 
				
			||||||
                            return a.ColNo - b.ColNo;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        return a.DrawerNo - b.DrawerNo;
 | 
					 | 
				
			||||||
                    });
 | 
					 | 
				
			||||||
                    DialogParameters dialogParameters = new DialogParameters();
 | 
					 | 
				
			||||||
                    dialogParameters.Add("ChannelStocks", addChannels);
 | 
					 | 
				
			||||||
                    DialogServiceExtensions.ShowDialogHost(_dialogService, "SelfAddDialog", dialogParameters, DoDialogResult, "RootDialog");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        Message = "请填写加药数量",
 | 
					 | 
				
			||||||
                        Type = MsgType.ERROR
 | 
					 | 
				
			||||||
                    };
 | 
					 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void DoDialogResult(IDialogResult dialogResult)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 委托   被动执行     被子窗口执行
 | 
					 | 
				
			||||||
            // dialogResult  第一方面可以拿到任意参数   第二方面   可判断关闭状态
 | 
					 | 
				
			||||||
            if (dialogResult.Result == ButtonResult.OK)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                RequestChannelData();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool KeepAlive => false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
 | 
					 | 
				
			||||||
        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            continuationCallback(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public void RequestChannelData()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
 | 
					 | 
				
			||||||
                .Includes<DrugInfo>(cs => cs.DrugInfo)
 | 
					 | 
				
			||||||
                .Where(cs => cs.DrugId != null)
 | 
					 | 
				
			||||||
                .Where(cs => cs.DrawerType == 1)
 | 
					 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
 | 
					 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
 | 
					 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
 | 
					 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
 | 
					 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugInfo.DrugBarcode.Contains(SearchValue))
 | 
					 | 
				
			||||||
                .OrderBy(cs => cs.DrugId)
 | 
					 | 
				
			||||||
                .OrderBy(cs => cs.DrawerNo)
 | 
					 | 
				
			||||||
                .OrderBy(cs => cs.ColNo)
 | 
					 | 
				
			||||||
                .ToList();
 | 
					 | 
				
			||||||
            ChannelStocks = queryData;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //接收导航传过来的参数  现在是在此处初始化了表格数据
 | 
					 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            RequestChannelData();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
					 | 
				
			||||||
        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //这个方法用于拦截请求
 | 
					 | 
				
			||||||
        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue