Compare commits
	
		
			93 Commits
		
	
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							
							
								
								 | 
						88a4940a5c | 
							 | 
					|
| 
							
							
								
								 | 
						fb168eda34 | 
							 | 
					|
| 
							
							
								
								 | 
						12c2cc4e22 | 
							 | 
					|
| 
							
							
								
								 | 
						35270de250 | 
							 | 
					|
| 
							
							
								
								 | 
						946fe26a17 | 
							 | 
					|
| 
							
							
								
								 | 
						e6ffeffc11 | 
							 | 
					|
| 
							
							
								
								 | 
						6b1a640995 | 
							 | 
					|
| 
							
							
								
								 | 
						d05801a802 | 
							 | 
					|
| 
							
							
								
								 | 
						e4d32570e6 | 
							 | 
					|
| 
							
							
								
								 | 
						8eb5a3ff03 | 
							 | 
					|
| 
							
							
								
								 | 
						24b5d6257b | 
							 | 
					|
| 
							
							
								
								 | 
						b1974bd1a5 | 
							 | 
					|
| 
							
							
								
								 | 
						303c6f337d | 
							 | 
					|
| 
							
							
								
								 | 
						1402d31de2 | 
							 | 
					|
| 
							
							
								
								 | 
						8ce450a4f5 | 
							 | 
					|
| 
							
							
								
								 | 
						74da88a362 | 
							 | 
					|
| 
							
							
								
								 | 
						ee624a7c0d | 
							 | 
					|
| 
							
							
								
								 | 
						e75f04beaf | 
							 | 
					|
| 
							
							
								
								 | 
						c7d7a3b266 | 
							 | 
					|
| 
							
							
								
								 | 
						f2614723e2 | 
							 | 
					|
| 
							
							
								
								 | 
						3b7ef9e29f | 
							 | 
					|
| 
							
							
								
								 | 
						a82c9f1cd1 | 
							 | 
					|
| 
							
							
								
								 | 
						90d67f92f6 | 
							 | 
					|
| 
							
							
								
								 | 
						eb5cefe10b | 
							 | 
					|
| 
							
							
								
								 | 
						3c1a569b49 | 
							 | 
					|
| 
							
							
								
								 | 
						fd17d9e5a9 | 
							 | 
					|
| 
							
							
								
								 | 
						47d2d9c475 | 
							 | 
					|
| 
							
							
								
								 | 
						8ea3075d3c | 
							 | 
					|
| 
							
							
								
								 | 
						1ba351b659 | 
							 | 
					|
| 
							
							
								
								 | 
						fd77a36296 | 
							 | 
					|
| 
							
							
								
								 | 
						5dbf4f8e15 | 
							 | 
					|
| 
							
							
								
								 | 
						5e27e28a96 | 
							 | 
					|
| 
							
							
								
								 | 
						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 | 
							 | 
					
| 
						 | 
					@ -360,4 +360,5 @@ MigrationBackup/
 | 
				
			||||||
.ionide/
 | 
					.ionide/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 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=xiangxiang_xianchang;userid=root;password=root" />
 | 
				
			||||||
  </connectionStrings>
 | 
					  </connectionStrings>
 | 
				
			||||||
	<!--<runtime>
 | 
						<!--<runtime>
 | 
				
			||||||
		--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
							--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
				
			||||||
| 
						 | 
					@ -12,19 +12,37 @@
 | 
				
			||||||
	<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="159" />
 | 
				
			||||||
		<!-- 登录模式 1单人登录2双人登录 -->
 | 
							<!-- 登录模式 1单人登录2双人登录 -->
 | 
				
			||||||
		<add key="loginMode" value="1" />
 | 
							<add key="loginMode" value="1" />
 | 
				
			||||||
		<!-- 登录顺序,指定先登录的人的名称有效值,只有在登录模式等于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"/>
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
 | 
				
			||||||
 | 
							<add key="stopRecord" value="180"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<add key="gridConnectionString" value="MYSQL; Database=hkcdb; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
 | 
							<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="COM3" />
 | 
							<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,16 +99,16 @@
 | 
				
			||||||
		<!-- 指纹机号码 -->
 | 
							<!-- 指纹机号码 -->
 | 
				
			||||||
		<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="10.1.100.15"/>
 | 
				
			||||||
		<!--海康威视端口-->
 | 
							<!--海康威视端口-->
 | 
				
			||||||
		<add key="HIKPort" value="8000"/>
 | 
							<add key="HIKPort" value="8000"/>
 | 
				
			||||||
		<!--海康威视用户名-->
 | 
							<!--海康威视用户名-->
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -32,6 +34,7 @@ namespace DM_Weight
 | 
				
			||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    public partial class App : PrismApplication
 | 
					    public partial class App : PrismApplication
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        public static bool DbConnectionFail { get; set; } = false;
 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(App));
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(App));
 | 
				
			||||||
        public App()
 | 
					        public App()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -44,6 +47,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 +55,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>();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,8 +63,12 @@ namespace DM_Weight
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            logger.Error($"发生错误:{e.Exception.Message}");
 | 
					            logger.Error($"发生错误:{e.Exception.Message}");
 | 
				
			||||||
            e.Handled = true;
 | 
					            e.Handled = true;
 | 
				
			||||||
 | 
					            if (e.Exception.Message.Contains("连接数据库过程中发生错误"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                DbConnectionFail = true;
 | 
				
			||||||
 | 
					                Container.Resolve<MainWindow>();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 | 
					        void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,18 +95,21 @@ 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(""));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 串口工具
 | 
					            // 串口工具
 | 
				
			||||||
            containerRegistry.RegisterSingleton<PortUtil>();
 | 
					            containerRegistry.RegisterSingleton<PortUtil>();
 | 
				
			||||||
 | 
					            containerRegistry.RegisterSingleton<SocketHelper>();
 | 
				
			||||||
            // 指纹机工具
 | 
					            // 指纹机工具
 | 
				
			||||||
            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 +134,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 +276,74 @@ 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>();
 | 
				
			||||||
 | 
					            //紧急开锁页面
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<EmergencyWindow, EmergencyWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            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,26 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    class BoxNumConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string str=value.ToString();
 | 
				
			||||||
 | 
					            return !(str == parameter.ToString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,45 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class DrawerContentConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //int iLength = value[0].ToString().Length;
 | 
				
			||||||
 | 
					            //int ButtonDrawerNo = int.Parse(value[0].ToString().Substring(0, iLength-3));
 | 
				
			||||||
 | 
					            //int SelectedDrawerNo = int.Parse(value[1].ToString());
 | 
				
			||||||
 | 
					            //return ButtonDrawerNo == SelectedDrawerNo;
 | 
				
			||||||
 | 
					            if (value!=null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                string name = value.ToString();
 | 
				
			||||||
 | 
					                string num = parameter.ToString();
 | 
				
			||||||
 | 
					                if (!string.IsNullOrEmpty(name))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return num + " " + name;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                    return num;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if(!string.IsNullOrEmpty(parameter.ToString()))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return parameter.ToString();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return "";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            throw new NotImplementedException();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -4,18 +4,25 @@ using System.Globalization;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using System.Windows;
 | 
					 | 
				
			||||||
using System.Windows.Data;
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.Converter
 | 
					namespace DM_Weight.Converter
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    internal class DrawerSelectConverter : IMultiValueConverter
 | 
					    internal class DrawerSelectConverter : IMultiValueConverter
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
 | 
					        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            int ButtonDrawerNo = int.Parse(value[0].ToString());
 | 
					            if (!string.IsNullOrEmpty(values[0].ToString()) && values[0].ToString().Length >= 1)
 | 
				
			||||||
            int SelectedDrawerNo = int.Parse(value[1].ToString());
 | 
					            {
 | 
				
			||||||
            return ButtonDrawerNo == SelectedDrawerNo;
 | 
					
 | 
				
			||||||
 | 
					                int iIndex = values[0].ToString().IndexOf("号");
 | 
				
			||||||
 | 
					                //int iLength = values[0].ToString().Length;
 | 
				
			||||||
 | 
					                int ButtonDrawerNo = int.Parse(values[0].ToString().Substring(0, iIndex));
 | 
				
			||||||
 | 
					                int SelectedDrawerNo = int.Parse(values[1].ToString());
 | 
				
			||||||
 | 
					                return ButtonDrawerNo == SelectedDrawerNo;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					                false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 | 
					        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,127 +0,0 @@
 | 
				
			||||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <PropertyGroup>
 | 
					 | 
				
			||||||
    <OutputType>WinExe</OutputType>
 | 
					 | 
				
			||||||
    <TargetFramework>net6.0-windows</TargetFramework>
 | 
					 | 
				
			||||||
    <Nullable>enable</Nullable>
 | 
					 | 
				
			||||||
    <UseWPF>true</UseWPF>
 | 
					 | 
				
			||||||
    <PackageIcon></PackageIcon>
 | 
					 | 
				
			||||||
    <Product>毒麻管理程序</Product>
 | 
					 | 
				
			||||||
    <ApplicationIcon>Images\favicon.ico</ApplicationIcon>
 | 
					 | 
				
			||||||
  </PropertyGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	<ItemGroup>
 | 
					 | 
				
			||||||
		<None Remove="Images\body-bg.jpg" />
 | 
					 | 
				
			||||||
		<None Remove="Images\box-16.jpg" />
 | 
					 | 
				
			||||||
		<None Remove="Images\box.png" />
 | 
					 | 
				
			||||||
		<None Remove="Images\favicon.ico" />
 | 
					 | 
				
			||||||
		<None Remove="Images\finger-bg-r.png" />
 | 
					 | 
				
			||||||
		<None Remove="Images\logo.png" />
 | 
					 | 
				
			||||||
		<None Remove="Images\TbExit.png" />
 | 
					 | 
				
			||||||
		<None Remove="Images\TbJiay.png" />
 | 
					 | 
				
			||||||
		<None Remove="Images\TbKuc.png" />
 | 
					 | 
				
			||||||
		<None Remove="Images\TbQyao.png" />
 | 
					 | 
				
			||||||
		<None Remove="Images\TbSet.png" />
 | 
					 | 
				
			||||||
		<None Remove="Images\TbTuiy.png" />
 | 
					 | 
				
			||||||
	</ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
    <COMReference Include="zkemkeeper">
 | 
					 | 
				
			||||||
      <WrapperTool>tlbimp</WrapperTool>
 | 
					 | 
				
			||||||
      <VersionMinor>0</VersionMinor>
 | 
					 | 
				
			||||||
      <VersionMajor>1</VersionMajor>
 | 
					 | 
				
			||||||
      <Guid>fe9ded34-e159-408e-8490-b720a5e632c7</Guid>
 | 
					 | 
				
			||||||
      <Lcid>0</Lcid>
 | 
					 | 
				
			||||||
      <Isolated>false</Isolated>
 | 
					 | 
				
			||||||
      <EmbedInteropTypes>False</EmbedInteropTypes>
 | 
					 | 
				
			||||||
    </COMReference>
 | 
					 | 
				
			||||||
    <COMReference Include="gregn6Lib">
 | 
					 | 
				
			||||||
      <WrapperTool>tlbimp</WrapperTool>
 | 
					 | 
				
			||||||
      <VersionMinor>0</VersionMinor>
 | 
					 | 
				
			||||||
      <VersionMajor>6</VersionMajor>
 | 
					 | 
				
			||||||
      <Guid>4018f953-1bfe-441e-8a04-dc8ba1ff060e</Guid>
 | 
					 | 
				
			||||||
      <Lcid>0</Lcid>
 | 
					 | 
				
			||||||
      <Isolated>false</Isolated>
 | 
					 | 
				
			||||||
      <EmbedInteropTypes>False</EmbedInteropTypes>
 | 
					 | 
				
			||||||
    </COMReference>
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
    <Content Include="Images\favicon.ico" />
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
	<Resource Include="Images\body-bg.jpg" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\box-16.jpg" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\box.png" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\favicon.ico" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\finger-bg-r.png" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\logo.png" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\TbExit.png" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\TbJiay.png" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\TbKuc.png" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\TbQyao.png" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\TbSet.png" />
 | 
					 | 
				
			||||||
    <Resource Include="Images\TbTuiy.png" />
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
    <PackageReference Include="log4net" Version="2.0.15" />
 | 
					 | 
				
			||||||
    <PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
 | 
					 | 
				
			||||||
    <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
 | 
					 | 
				
			||||||
    <PackageReference Include="Prism.Unity" Version="8.1.97" />
 | 
					 | 
				
			||||||
    <PackageReference Include="SharpPromise" Version="1.7.0" />
 | 
					 | 
				
			||||||
    <PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
 | 
					 | 
				
			||||||
    <PackageReference Include="SuperSimpleTcp" Version="3.0.10" />
 | 
					 | 
				
			||||||
    <PackageReference Include="System.Drawing.Common" Version="7.0.0" />
 | 
					 | 
				
			||||||
    <PackageReference Include="System.IO.Ports" Version="7.0.0" />
 | 
					 | 
				
			||||||
    <PackageReference Include="System.Management" Version="7.0.1" />
 | 
					 | 
				
			||||||
    <PackageReference Include="System.Reactive" Version="5.0.0" />
 | 
					 | 
				
			||||||
    <PackageReference Include="System.Speech" Version="7.0.0" />
 | 
					 | 
				
			||||||
    <PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
    <ApplicationDefinition Update="App.xaml">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </ApplicationDefinition>
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
    <None Update="App.config">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </None>
 | 
					 | 
				
			||||||
    <None Update="log4net.config">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </None>
 | 
					 | 
				
			||||||
    <None Update="ReportTemp\account_book_temp.grf">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </None>
 | 
					 | 
				
			||||||
    <None Update="ReportTemp\machine_log_check.grf">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </None>
 | 
					 | 
				
			||||||
    <None Update="ReportTemp\machine_log_return.grf">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </None>
 | 
					 | 
				
			||||||
    <None Update="ReportTemp\machine_log_add.grf">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </None>
 | 
					 | 
				
			||||||
    <None Update="ReportTemp\machine_log_take.grf">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </None>
 | 
					 | 
				
			||||||
    <None Update="ReportTemp\stock_template.grf">
 | 
					 | 
				
			||||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
					 | 
				
			||||||
    </None>
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
    <Page Update="Views\Dialog\InvoiceTakeDialog.xaml">
 | 
					 | 
				
			||||||
      <XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
 | 
					 | 
				
			||||||
    </Page>
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <ItemGroup>
 | 
					 | 
				
			||||||
    <Folder Include="HIKVISION\" />
 | 
					 | 
				
			||||||
  </ItemGroup>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
</Project>
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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>
 | 
				
			||||||
| 
						 | 
					@ -66,9 +67,14 @@
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <PackageReference Include="Common.Logging" Version="3.4.1" />
 | 
				
			||||||
 | 
					    <PackageReference Include="FluentModbus" Version="5.3.0" />
 | 
				
			||||||
    <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="Mina" Version="2.0.12" />
 | 
				
			||||||
 | 
					    <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="SharpPromise" Version="1.7.0" />
 | 
					    <PackageReference Include="SharpPromise" Version="1.7.0" />
 | 
				
			||||||
    <PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
 | 
					    <PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
 | 
				
			||||||
| 
						 | 
					@ -97,6 +103,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>
 | 
				
			||||||
| 
						 | 
					@ -109,19 +118,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>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,43 +19,42 @@ namespace DM_Weight.Finger
 | 
				
			||||||
    public class FingerprintUtil
 | 
					    public class FingerprintUtil
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
 | 
					        private ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
 | 
				
			||||||
        public zkemkeeper.CZKEMClass axCZKEM1; //= new zkemkeeper.CZKEMClass();
 | 
					        public zkemkeeper.CZKEMClass axCZKEM1= new zkemkeeper.CZKEMClass();
 | 
				
			||||||
        public bool bIsConnected = false;
 | 
					        public bool bIsConnected = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private string fingerIp = ConfigurationManager.AppSettings["fingerIp"].ToString();
 | 
					        private string fingerIp = ConfigurationManager.AppSettings["fingerIp"].ToString();
 | 
				
			||||||
        private int fingerPort = 4370;
 | 
					        private int fingerPort = 4370;
 | 
				
			||||||
        private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"].ToString());
 | 
					        private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"].ToString());
 | 
				
			||||||
        private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"].ToString());
 | 
					        private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"].ToString());
 | 
				
			||||||
        private readonly IEventAggregator _eventAggregator;
 | 
					        private IEventAggregator _eventAggregator;
 | 
				
			||||||
        public FingerprintUtil(IEventAggregator eventAggregator)
 | 
					        public FingerprintUtil(IEventAggregator eventAggregator)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
            logger.Info($"进入构造器,开始连接指纹机");
 | 
					            logger.Info($"进入构造器,开始连接指纹机");
 | 
				
			||||||
            Task.Run(() =>
 | 
					           // Task.Run(() =>
 | 
				
			||||||
           {
 | 
					           //{
 | 
				
			||||||
               ConnectionMain();
 | 
					               ConnectionMain();
 | 
				
			||||||
           });
 | 
					           //});
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void ConnectionMain()
 | 
					        public void ConnectionMain()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                axCZKEM1 = new CZKEMClass();
 | 
					                //axCZKEM1 = new CZKEMClass();
 | 
				
			||||||
                bIsConnected = axCZKEM1.Connect_Net(fingerIp, fingerPort);
 | 
					                bIsConnected = axCZKEM1.Connect_Net(fingerIp, fingerPort);
 | 
				
			||||||
                logger.Info($"连接指纹机,IP:{fingerIp},端口:{fingerPort},机器号:{machineNumber},连接结果:{bIsConnected}");
 | 
					                logger.Info($"连接指纹机,IP:{fingerIp},端口:{fingerPort},机器号:{machineNumber},连接结果:{bIsConnected}");
 | 
				
			||||||
                if (bIsConnected)
 | 
					                if (bIsConnected)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (axCZKEM1.RegEvent(machineNumber, 65535))
 | 
					                    if (axCZKEM1.RegEvent(machineNumber, 9))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
 | 
					                        axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
 | 
				
			||||||
                        //this.axCZKEM1.OnEnrollFinger += new zkemkeeper._IZKEMEvents_OnEnrollFingerEventHandler(axCZKEM1_OnEnrollFinger);
 | 
					                        //this.axCZKEM1.OnEnrollFinger += new zkemkeeper._IZKEMEvents_OnEnrollFingerEventHandler(axCZKEM1_OnEnrollFinger);
 | 
				
			||||||
                        this.axCZKEM1.OnEnrollFingerEx += new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
 | 
					                        axCZKEM1.OnEnrollFingerEx += new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                _eventAggregator.GetEvent<FingerprintEvent>().Publish(new FingerprintMsg()
 | 
					                _eventAggregator.GetEvent<FingerprintEvent>().Publish(new FingerprintMsg()
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Message = "CONNECT",
 | 
					                    Message = "CONNECT",
 | 
				
			||||||
| 
						 | 
					@ -67,6 +66,25 @@ namespace DM_Weight.Finger
 | 
				
			||||||
                logger.Info($"连接指纹机异常{ex.Message.ToString()}");
 | 
					                logger.Info($"连接指纹机异常{ex.Message.ToString()}");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 用于退出登录重连指纹机
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public void FingerDisconnect()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info("重连指纹机");
 | 
				
			||||||
 | 
					                axCZKEM1.Disconnect(); 
 | 
				
			||||||
 | 
					                axCZKEM1.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
 | 
				
			||||||
 | 
					                axCZKEM1.OnEnrollFingerEx -= new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
 | 
				
			||||||
 | 
					                ConnectionMain();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"指纹机Disconnect异常{ex.Message.ToString()}"); 
 | 
				
			||||||
 | 
					                ConnectionMain();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //If your fingerprint(or your card) passes the verification,this event will be triggered
 | 
					        //If your fingerprint(or your card) passes the verification,this event will be triggered
 | 
				
			||||||
        private void axCZKEM1_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode)
 | 
					        private void axCZKEM1_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -18,144 +19,215 @@ namespace DM_Weight.HIKVISION
 | 
				
			||||||
        private bool m_bInitSDK = false;
 | 
					        private bool m_bInitSDK = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private Int32 m_lRealHandle = -1;
 | 
					        private Int32 m_lRealHandle = -1;
 | 
				
			||||||
        public static int HKUserId = -1; 
 | 
					        public static int HKUserId = -1;
 | 
				
			||||||
        private uint iLastErr = 0; 
 | 
					        private uint iLastErr = 0;
 | 
				
			||||||
        private string str;
 | 
					        private string str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            m_bInitSDK = CHCNetSDK.NET_DVR_Init();
 | 
					            try
 | 
				
			||||||
            if (m_bInitSDK == false)
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //MessageBox.Show("NET_DVR_Init error!");
 | 
					
 | 
				
			||||||
                //return;
 | 
					
 | 
				
			||||||
                logger.Info("NET_DVR_Init error!");
 | 
					                logger.Info("HIKInit");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                m_bInitSDK = CHCNetSDK.NET_DVR_Init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"HIKInit-{m_bInitSDK}");
 | 
				
			||||||
 | 
					                if (m_bInitSDK == false)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //MessageBox.Show("NET_DVR_Init error!");
 | 
				
			||||||
 | 
					                    //return;
 | 
				
			||||||
 | 
					                    logger.Info("NET_DVR_Init error!");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //保存SDK日志 To save the SDK log
 | 
				
			||||||
 | 
					                    CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //保存SDK日志 To save the SDK log
 | 
					                logger.Info($"HIKInit Exception:{ex.Message}");
 | 
				
			||||||
                CHCNetSDK.NET_DVR_SetLogToFile(3, "C:\\SdkLog\\", true);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return m_bInitSDK;
 | 
					            return m_bInitSDK;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public int HIKLogin()
 | 
					        public int HIKLogin()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            string ip= ReadApp.ReadAppSetting("HIKIP");
 | 
					            try
 | 
				
			||||||
            string port=ReadApp.ReadAppSetting("HIKPort");
 | 
					 | 
				
			||||||
            string userName= ReadApp.ReadAppSetting("HIKUser");
 | 
					 | 
				
			||||||
            string password= ReadApp.ReadAppSetting("HIKPassword");
 | 
					 | 
				
			||||||
            if (HKUserId < 0)
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info("HIKLogin");
 | 
				
			||||||
                struLogInfo = new CHCNetSDK.NET_DVR_USER_LOGIN_INFO();
 | 
					                string ip = ReadApp.ReadAppSetting("HIKIP");
 | 
				
			||||||
 | 
					                string port = ReadApp.ReadAppSetting("HIKPort");
 | 
				
			||||||
                //设备IP地址或者域名
 | 
					                string userName = ReadApp.ReadAppSetting("HIKUser");
 | 
				
			||||||
                byte[] byIP = System.Text.Encoding.Default.GetBytes(ip);
 | 
					                string password = ReadApp.ReadAppSetting("HIKPassword");
 | 
				
			||||||
                struLogInfo.sDeviceAddress = new byte[129];
 | 
					 | 
				
			||||||
                byIP.CopyTo(struLogInfo.sDeviceAddress, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //设备用户名
 | 
					 | 
				
			||||||
                byte[] byUserName = System.Text.Encoding.Default.GetBytes(userName);
 | 
					 | 
				
			||||||
                struLogInfo.sUserName = new byte[64];
 | 
					 | 
				
			||||||
                byUserName.CopyTo(struLogInfo.sUserName, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //设备密码
 | 
					 | 
				
			||||||
                byte[] byPassword = System.Text.Encoding.Default.GetBytes(password);
 | 
					 | 
				
			||||||
                struLogInfo.sPassword = new byte[64];
 | 
					 | 
				
			||||||
                byPassword.CopyTo(struLogInfo.sPassword, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                struLogInfo.wPort = ushort.Parse(port);//设备服务端口号
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //if (LoginCallBack == null)
 | 
					 | 
				
			||||||
                //{
 | 
					 | 
				
			||||||
                //    LoginCallBack = new CHCNetSDK.LOGINRESULTCALLBACK(cbLoginCallBack);//注册回调函数                    
 | 
					 | 
				
			||||||
                //}
 | 
					 | 
				
			||||||
                //struLogInfo.cbLoginResult = LoginCallBack;
 | 
					 | 
				
			||||||
                struLogInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V40();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                //登录设备 Login the device
 | 
					 | 
				
			||||||
                HKUserId = CHCNetSDK.NET_DVR_Login_V40(ref struLogInfo, ref DeviceInfo);
 | 
					 | 
				
			||||||
                if (HKUserId < 0)
 | 
					                if (HKUserId < 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    iLastErr = CHCNetSDK.NET_DVR_GetLastError();
 | 
					
 | 
				
			||||||
                    str = "NET_DVR_Login_V40 failed, error code= " + iLastErr; //登录失败,输出错误号
 | 
					                    struLogInfo = new CHCNetSDK.NET_DVR_USER_LOGIN_INFO();
 | 
				
			||||||
                    logger.Info(str);
 | 
					
 | 
				
			||||||
 | 
					                    //设备IP地址或者域名
 | 
				
			||||||
 | 
					                    byte[] byIP = System.Text.Encoding.Default.GetBytes(ip);
 | 
				
			||||||
 | 
					                    struLogInfo.sDeviceAddress = new byte[129];
 | 
				
			||||||
 | 
					                    byIP.CopyTo(struLogInfo.sDeviceAddress, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //设备用户名
 | 
				
			||||||
 | 
					                    byte[] byUserName = System.Text.Encoding.Default.GetBytes(userName);
 | 
				
			||||||
 | 
					                    struLogInfo.sUserName = new byte[64];
 | 
				
			||||||
 | 
					                    byUserName.CopyTo(struLogInfo.sUserName, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //设备密码
 | 
				
			||||||
 | 
					                    byte[] byPassword = System.Text.Encoding.Default.GetBytes(password);
 | 
				
			||||||
 | 
					                    struLogInfo.sPassword = new byte[64];
 | 
				
			||||||
 | 
					                    byPassword.CopyTo(struLogInfo.sPassword, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    struLogInfo.wPort = ushort.Parse(port);//设备服务端口号
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //if (LoginCallBack == null)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    LoginCallBack = new CHCNetSDK.LOGINRESULTCALLBACK(cbLoginCallBack);//注册回调函数                    
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                    //struLogInfo.cbLoginResult = LoginCallBack;
 | 
				
			||||||
 | 
					                    struLogInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V40();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //登录设备 Login the device
 | 
				
			||||||
 | 
					                    HKUserId = CHCNetSDK.NET_DVR_Login_V40(ref struLogInfo, ref DeviceInfo);
 | 
				
			||||||
 | 
					                    if (HKUserId < 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        iLastErr = CHCNetSDK.NET_DVR_GetLastError();
 | 
				
			||||||
 | 
					                        str = "NET_DVR_Login_V40 failed, error code= " + iLastErr; //登录失败,输出错误号
 | 
				
			||||||
 | 
					                        logger.Info(str);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        //登录成功
 | 
				
			||||||
 | 
					                        //MessageBox.Show("Login Success!");
 | 
				
			||||||
 | 
					                        logger.Info("Login Success!");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    //登录成功
 | 
					                    //注销登录 Logout the device
 | 
				
			||||||
                    //MessageBox.Show("Login Success!");
 | 
					                    if (m_lRealHandle >= 0)
 | 
				
			||||||
                    logger.Info("Login Success!");
 | 
					                    {
 | 
				
			||||||
                }
 | 
					                        //MessageBox.Show("Please stop live view firstly");
 | 
				
			||||||
 | 
					                        logger.Info("Please stop live view firstly");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (!CHCNetSDK.NET_DVR_Logout(HKUserId))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        iLastErr = CHCNetSDK.NET_DVR_GetLastError();
 | 
				
			||||||
 | 
					                        str = "NET_DVR_Logout failed, error code= " + iLastErr;
 | 
				
			||||||
 | 
					                        logger.Info(str);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    HKUserId = -1;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //注销登录 Logout the device
 | 
					 | 
				
			||||||
                if (m_lRealHandle >= 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    //MessageBox.Show("Please stop live view firstly");
 | 
					 | 
				
			||||||
                    logger.Info("Please stop live view firstly");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (!CHCNetSDK.NET_DVR_Logout(HKUserId))
 | 
					                logger.Info($"HIKLogin Exception:{ex.Message}");
 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    iLastErr = CHCNetSDK.NET_DVR_GetLastError();
 | 
					 | 
				
			||||||
                    str = "NET_DVR_Logout failed, error code= " + iLastErr;
 | 
					 | 
				
			||||||
                    logger.Info(str);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                HKUserId = -1;
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return HKUserId;
 | 
					            return HKUserId;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void HIKLoginOut()
 | 
					        public void HIKLoginOut()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (m_lRealHandle >= 0)
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
               bool stopRealPlay=  CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
 | 
					
 | 
				
			||||||
                logger.Info($"录像机NET_DVR_StopRealPlay接口返回{stopRealPlay}");
 | 
					                if (m_lRealHandle >= 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool stopRealPlay = CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
 | 
				
			||||||
 | 
					                    logger.Info($"录像机NET_DVR_StopRealPlay接口返回{stopRealPlay}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (HKUserId >= 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool logout = CHCNetSDK.NET_DVR_Logout(HKUserId);
 | 
				
			||||||
 | 
					                    logger.Info($"录像机NET_DVR_Logout接口返回{logout}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (m_bInitSDK == true)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool cleanUp = CHCNetSDK.NET_DVR_Cleanup();
 | 
				
			||||||
 | 
					                    logger.Info($"录像机NET_DVR_Cleanup接口返回{cleanUp}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (HKUserId >= 0)
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                bool logout= CHCNetSDK.NET_DVR_Logout(HKUserId);
 | 
					                logger.Info($"HIKLoginOut Exception{ex.Message}");
 | 
				
			||||||
                logger.Info($"录像机NET_DVR_Logout接口返回{logout}");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (m_bInitSDK == true)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                bool cleanUp= CHCNetSDK.NET_DVR_Cleanup();
 | 
					 | 
				
			||||||
                logger.Info($"录像机NET_DVR_Cleanup接口返回{cleanUp}");
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool HIKStartDVRRecord()
 | 
					        public bool HIKStartDVRRecord()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            bool isStart= CHCNetSDK.NET_DVR_StartDVRRecord(HKUserId, 0xffff, 0);
 | 
					            bool isStart = false;
 | 
				
			||||||
            logger.Info($"录像机NET_DVR_StartDVRRecord接口返回{isStart}");
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                isStart = CHCNetSDK.NET_DVR_StartDVRRecord(HKUserId, 0xffff, 0);
 | 
				
			||||||
 | 
					                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;
 | 
				
			||||||
            logger.Info($"录像机NET_DVR_StopDVRRecord接口返回{isStop}");
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                isStop = CHCNetSDK.NET_DVR_StopDVRRecord(HKUserId, 0xffff);
 | 
				
			||||||
 | 
					                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,21 +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(ColumnName = "state")]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public int? State { get; set; }
 | 
					        public int? State { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
| 
						 | 
					@ -101,6 +108,17 @@ namespace DM_Weight.Models
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => DrawerNo + "-" + ColNo;
 | 
					            get => DrawerNo + "-" + ColNo;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName ="yh_no")]
 | 
				
			||||||
 | 
					        public string BelongUser
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get;set;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //归属用户的用户名
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "commnet")]
 | 
				
			||||||
 | 
					        public string BelongUserName
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get;set;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        //private int _addQuantity = 0;
 | 
					        //private int _addQuantity = 0;
 | 
				
			||||||
        //[SugarColumn(IsIgnore = true)]
 | 
					        //[SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        //public int AddQuantity
 | 
					        //public int AddQuantity
 | 
				
			||||||
| 
						 | 
					@ -196,5 +214,9 @@ namespace DM_Weight.Models
 | 
				
			||||||
        private string _drugSpec;
 | 
					        private string _drugSpec;
 | 
				
			||||||
        [SugarColumn(ColumnName = "drug_manu_no")]
 | 
					        [SugarColumn(ColumnName = "drug_manu_no")]
 | 
				
			||||||
        public string DrugSpec { get=> _drugSpec;set=>SetProperty(ref _drugSpec, value); }
 | 
					        public string DrugSpec { get=> _drugSpec;set=>SetProperty(ref _drugSpec, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private string _belongUserName;
 | 
				
			||||||
 | 
					        //[SugarColumn(IsIgnore =true)]
 | 
				
			||||||
 | 
					        //public string BelongUserName { get => _belongUserName;set=>SetProperty(ref _belongUserName, value); }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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,9 +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)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public int DrawerState { get; set; } = 0;
 | 
					        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; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,17 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 记录系统中网口通信中用到的ip与端口号
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public class IpAndPort
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string Ip { get; set; }
 | 
				
			||||||
 | 
					        public int Port { 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,12 +37,12 @@ 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")]
 | 
				
			||||||
 | 
					        //public int? CheckQuantity { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(ColumnName = "check_quantity")]
 | 
					 | 
				
			||||||
        public int? CheckQuantity { get; set; }
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 批号 
 | 
					        /// 批号 
 | 
				
			||||||
        ///</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,16 +134,66 @@ 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)]
 | 
				
			||||||
        public int CanReturnQuantity
 | 
					        public int CanReturnQuantity
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => Quantity - ReturnQuantity1 - ReturnQuantity2;
 | 
					            get => Quantity - ReturnQuantity1 - ReturnQuantity2;
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [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; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,14 +13,14 @@ namespace DM_Weight.Models
 | 
				
			||||||
        /// <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,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,157 +9,181 @@ namespace DM_Weight.Models
 | 
				
			||||||
    /// 
 | 
					    /// 
 | 
				
			||||||
    ///</summary>
 | 
					    ///</summary>
 | 
				
			||||||
    [SugarTable("order_info")]
 | 
					    [SugarTable("order_info")]
 | 
				
			||||||
    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>
 | 
					 | 
				
			||||||
        ///  
 | 
					 | 
				
			||||||
        /// 默认值: NULL
 | 
					 | 
				
			||||||
        ///</summary>
 | 
					 | 
				
			||||||
        [SugarColumn(ColumnName = "sex")]
 | 
					 | 
				
			||||||
        public string Sex { get; set; }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        ///  
 | 
					 | 
				
			||||||
        /// 默认值: NULL
 | 
					 | 
				
			||||||
        ///</summary>
 | 
					 | 
				
			||||||
        [SugarColumn(ColumnName = "age")]
 | 
					 | 
				
			||||||
        public string Age { get; set; }
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        ///  
 | 
					 | 
				
			||||||
        /// 默认值: NULL
 | 
					 | 
				
			||||||
        ///</summary>
 | 
					 | 
				
			||||||
        [SugarColumn(ColumnName = "id_number")]
 | 
					 | 
				
			||||||
        public string IdNumber { get; set; }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: NULL
 | 
					        /// 默认值: NULL
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _sex;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "sex")]
 | 
				
			||||||
 | 
					        public string Sex { get=> _sex; set=>SetProperty(ref _sex,value); }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _age;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "age")]
 | 
				
			||||||
 | 
					        public string Age { get=> _age; set=>SetProperty(ref _age,value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</summary>
 | 
				
			||||||
 | 
					        private string _idNumber;
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "id_number")]
 | 
				
			||||||
 | 
					        public string IdNumber { get=> _idNumber; set=> SetProperty(ref _idNumber, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///  
 | 
				
			||||||
 | 
					        /// 默认值: NULL
 | 
				
			||||||
 | 
					        ///</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>
 | 
				
			||||||
        ///  
 | 
					        ///  
 | 
				
			||||||
        /// 默认值: 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
 | 
				
			||||||
| 
						 | 
					@ -196,7 +236,23 @@ namespace DM_Weight.Models
 | 
				
			||||||
        ///</summary>
 | 
					        ///</summary>
 | 
				
			||||||
        //[SugarColumn(ColumnName = "identity")]
 | 
					        //[SugarColumn(ColumnName = "identity")]
 | 
				
			||||||
        //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 = "doctor_Code")]
 | 
				
			||||||
 | 
					        public string DoctorCode { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,32 +0,0 @@
 | 
				
			||||||
using System;
 | 
					 | 
				
			||||||
using System.Collections.Generic;
 | 
					 | 
				
			||||||
using System.Linq;
 | 
					 | 
				
			||||||
using System.Text;
 | 
					 | 
				
			||||||
using System.Threading.Tasks;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace DM_Weight.Models
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    public class OrderTakeVo
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        public DrugInfo Drug { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public OrderDetail OrderDetail { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public ChannelStock ChannelStock { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int StockQuantity { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Quantity { get; set; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int GetQuantity { get; set; } = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int Status { get; set; } = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int[] BeforeQuantity { get; set; } = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int[] AfterQuantity { get; set; } = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public int AddQuantity { get; set; } = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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,60 @@
 | 
				
			||||||
 | 
					using Common.Logging;
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using Mina.Core.Future;
 | 
				
			||||||
 | 
					using Mina.Filter.Codec;
 | 
				
			||||||
 | 
					using Mina.Transport.Socket;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Net;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class FingerHelper
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(SocketHelper));
 | 
				
			||||||
 | 
					        AsyncSocketConnector acceptor = new AsyncSocketConnector();
 | 
				
			||||||
 | 
					        IConnectFuture iConnectFuture;
 | 
				
			||||||
 | 
					        string ip = ConfigurationManager.AppSettings["fingerIp"].ToString();
 | 
				
			||||||
 | 
					        FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					        public FingerHelper(FingerprintUtil fingerprintUtil)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
 | 
					            acceptor.ExceptionCaught += (o, e) => logger.Error(e.Exception);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //acceptor.FilterChain.AddLast("logger", new LoggingFilter());
 | 
				
			||||||
 | 
					            acceptor.FilterChain.AddLast("encoding", new ProtocolCodecFilter(new MyMinaCodecFactory()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            acceptor.SessionIdle += (o, e) => logger.Info("IDLE " + e.Session.GetIdleCount(e.IdleStatus));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            acceptor.MessageReceived += (o, e) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info("MessageReceived>>>>>>>>>>>>>>>>");
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            acceptor.SessionClosed += (o, e) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info("SessionClosed");
 | 
				
			||||||
 | 
					                Task.Delay(50).Wait();
 | 
				
			||||||
 | 
					                SocketConnect();
 | 
				
			||||||
 | 
					                _fingerprintUtil.FingerDisconnect();
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            this.SocketConnect();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public void SocketConnect()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            iConnectFuture = acceptor.Connect(new IPEndPoint(IPAddress.Parse(ip), 4370)).Await();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info($"再次连接结果:{iConnectFuture.Connected.ToString()}");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void SendMessage(MyBaseMessage baseMessage)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            iConnectFuture.Session.Write(baseMessage);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,72 @@
 | 
				
			||||||
 | 
					using Polly;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Net.Sockets;
 | 
				
			||||||
 | 
					using System.Net;
 | 
				
			||||||
 | 
					using System.Runtime.InteropServices;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.ViewModels;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class KeepAliveSocket
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 生成带有心跳检测的socket
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public class KeepALiveSocket
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private static ILog socketLogger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
 | 
				
			||||||
 | 
					            public static Socket MakeKeepALiveSocket(string ip, int port)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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(ip), port);
 | 
				
			||||||
 | 
					                Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 | 
				
			||||||
 | 
					                _socket = Policy.Handle<Exception>()
 | 
				
			||||||
 | 
					                  .Retry(3, (exception, retryCount) => {
 | 
				
			||||||
 | 
					                      socketLogger.Info($"建立Socket,第{retryCount}次重试", exception);
 | 
				
			||||||
 | 
					                      // return TimeSpan.FromSeconds (1);
 | 
				
			||||||
 | 
					                  })
 | 
				
			||||||
 | 
					                  .Execute<Socket>(() => {
 | 
				
			||||||
 | 
					                      _socket.IOControl(IOControlCode.KeepAliveValues, inOptionValues, null);
 | 
				
			||||||
 | 
					                      _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
 | 
				
			||||||
 | 
					                      _socket.BeginConnect(iep,null,null);
 | 
				
			||||||
 | 
					                      return _socket;
 | 
				
			||||||
 | 
					                  });
 | 
				
			||||||
 | 
					                return _socket;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            public static Socket MakeKeepALiveSocket(IpAndPort ipAndPort)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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(ipAndPort.Ip), ipAndPort.Port);
 | 
				
			||||||
 | 
					                Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
 | 
				
			||||||
 | 
					                _socket = Policy.Handle<Exception>()
 | 
				
			||||||
 | 
					                  .Retry(3, (exception, retryCount) => {
 | 
				
			||||||
 | 
					                      socketLogger.Info($"建立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;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,180 @@
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using DM_Weight.ViewModels;
 | 
				
			||||||
 | 
					using DM_Weight.Views;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Modbus.Device;
 | 
				
			||||||
 | 
					using Polly;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					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.Speech.Synthesis;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using static DM_Weight.Port.KeepAliveSocket;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class ModbusHelper
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private static ModbusHelper instance;
 | 
				
			||||||
 | 
					        private ModbusIpMaster master;
 | 
				
			||||||
 | 
					        private Socket socket;
 | 
				
			||||||
 | 
					        private TcpClient client;
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
 | 
				
			||||||
 | 
					        private static object _lock = new object();
 | 
				
			||||||
 | 
					        public static bool BoxOperate { get; set; }
 | 
				
			||||||
 | 
					        public ModbusHelper()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            socket = MakeKeepALiveSocket();
 | 
				
			||||||
 | 
					            client = new TcpClient();
 | 
				
			||||||
 | 
					            client.Client = socket;
 | 
				
			||||||
 | 
					            master = ModbusIpMaster.CreateIp(client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public static ModbusHelper GetInstance()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            lock (_lock)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (instance == null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //lock (objLock)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    if (instance == null)
 | 
				
			||||||
 | 
					                    instance = new ModbusHelper();
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return instance;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SetModusIpMaster()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info("SetModusIpMaster");
 | 
				
			||||||
 | 
					            socket = MakeKeepALiveSocket();
 | 
				
			||||||
 | 
					            client = new TcpClient();
 | 
				
			||||||
 | 
					            client.Client = socket;
 | 
				
			||||||
 | 
					            master = ModbusIpMaster.CreateIp(client);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool[] GetAllBoxState()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            lock (_lock)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                bool[] bools = Policy.Handle<Exception>()
 | 
				
			||||||
 | 
					                .Retry(3, (exception, retryCount) =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    this.Dispose();
 | 
				
			||||||
 | 
					                    //Debug.WriteLine($"获取所有箱子门状态出错,第{retryCount}次重试", exception);
 | 
				
			||||||
 | 
					                    logger.Info($"获取所有箱子门状态出错,第{retryCount}次重试, 异常信息{exception}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Thread.Sleep(50);
 | 
				
			||||||
 | 
					                    BoxOperate = false;
 | 
				
			||||||
 | 
					                    this.SetModusIpMaster();
 | 
				
			||||||
 | 
					                    // return TimeSpan.FromSeconds (1);
 | 
				
			||||||
 | 
					                    //Task.Factory.StartNew(() =>
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    FingerprintUtil.FingerDisconnect();
 | 
				
			||||||
 | 
					                    //});
 | 
				
			||||||
 | 
					                }).Execute<bool[]>(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bool[] flags = new bool[18];
 | 
				
			||||||
 | 
					                    if (master == null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        this.SetModusIpMaster();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    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();
 | 
				
			||||||
 | 
					                    logger.Info("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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            lock (_lock)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                BoxOperate = true;
 | 
				
			||||||
 | 
					                bool bFlag = false;
 | 
				
			||||||
 | 
					                Thread.Sleep(50);
 | 
				
			||||||
 | 
					                Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    this.Dispose();
 | 
				
			||||||
 | 
					                    //Debug.WriteLine($"打开箱子出错,第{retryCount}次重试", exception);
 | 
				
			||||||
 | 
					                    logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
 | 
				
			||||||
 | 
					                    Thread.Sleep(50);
 | 
				
			||||||
 | 
					                    this.SetModusIpMaster();
 | 
				
			||||||
 | 
					                    //Task.Factory.StartNew(() =>
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    FingerprintUtil.FingerDisconnect();
 | 
				
			||||||
 | 
					                    //});
 | 
				
			||||||
 | 
					                    //return TimeSpan.FromSeconds (1);
 | 
				
			||||||
 | 
					                })).Execute(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    logger.Info($"正在打开{boxNum}号药箱");
 | 
				
			||||||
 | 
					                    master.WriteSingleRegister(1, (ushort)boxNum, 20);
 | 
				
			||||||
 | 
					                    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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private static SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
 | 
				
			||||||
 | 
					        public static void SpeakAsync(string textinfo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            speechSynthesizer.Rate = 2;
 | 
				
			||||||
 | 
					            speechSynthesizer.SpeakAsync(textinfo);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class MyBaseMessage
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public int addr { get; set; } = 1;
 | 
				
			||||||
 | 
					        public short lockNo { get; set; }
 | 
				
			||||||
 | 
					        public short delay { get; set; } = 2;
 | 
				
			||||||
 | 
					        public int functionCode { get; set; } = 6;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public MyBaseMessage() { }
 | 
				
			||||||
 | 
					        public MyBaseMessage(short lockNo, int addr = 1, short delay = 2, int functionCode = 6)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            this.addr = addr;
 | 
				
			||||||
 | 
					            this.lockNo = lockNo;
 | 
				
			||||||
 | 
					            this.delay = delay;
 | 
				
			||||||
 | 
					            this.functionCode = functionCode;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					using Mina.Filter.Codec.Demux;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class MyMinaCodecFactory : DemuxingProtocolCodecFactory
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public MyMinaCodecFactory()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            AddMessageEncoder(new MyMinaEncoder());
 | 
				
			||||||
 | 
					            AddMessageDecoder(new MyMinaDecoder());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,51 @@
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using Mina.Core.Buffer;
 | 
				
			||||||
 | 
					using Mina.Core.Session;
 | 
				
			||||||
 | 
					using Mina.Filter.Codec;
 | 
				
			||||||
 | 
					using Mina.Filter.Codec.Demux;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    internal class MyMinaDecoder : IMessageDecoder
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(SocketHelper));
 | 
				
			||||||
 | 
					        public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info("Decodable");
 | 
				
			||||||
 | 
					            return MessageDecoderResult.OK;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public MessageDecoderResult Decode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info("Decode");
 | 
				
			||||||
 | 
					            int length = input.Remaining;
 | 
				
			||||||
 | 
					            byte functionCode = input.Get(7);
 | 
				
			||||||
 | 
					            if (functionCode == 4)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                int a = input.Get(length - 2);
 | 
				
			||||||
 | 
					                int b = input.Get(length - 1);
 | 
				
			||||||
 | 
					                int c = input.Get(length - 3);
 | 
				
			||||||
 | 
					                int d = input.Get(length - 4); logger.Info($"查状态收到返回a:{a};b:{b};c:{c};d:{d}");
 | 
				
			||||||
 | 
					                bool f = false;
 | 
				
			||||||
 | 
					                if (a > 0 || b > 0 || c > 0 || d > 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    f = true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                output.Write(f);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            input.Position = length;
 | 
				
			||||||
 | 
					            return MessageDecoderResult.OK;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void FinishDecode(IoSession session, IProtocolDecoderOutput output)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,61 @@
 | 
				
			||||||
 | 
					using Mina.Core.Buffer;
 | 
				
			||||||
 | 
					using Mina.Core.Session;
 | 
				
			||||||
 | 
					using Mina.Filter.Codec;
 | 
				
			||||||
 | 
					using Mina.Filter.Codec.Demux;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class MyMinaEncoder : IMessageEncoder<MyBaseMessage>
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private short accumulate = 0;
 | 
				
			||||||
 | 
					        public void Encode(IoSession session, MyBaseMessage message, IProtocolEncoderOutput output)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            IoBuffer input = IoBuffer.Allocate(12);
 | 
				
			||||||
 | 
					            input.AutoExpand = true;
 | 
				
			||||||
 | 
					            input.PutInt16(accumulate);
 | 
				
			||||||
 | 
					            input.PutInt16(0);
 | 
				
			||||||
 | 
					            input.PutInt16(6);
 | 
				
			||||||
 | 
					            input.Put((byte)message.addr);
 | 
				
			||||||
 | 
					            // 功能码
 | 
				
			||||||
 | 
					            input.Put((byte)message.functionCode);
 | 
				
			||||||
 | 
					            // 锁号
 | 
				
			||||||
 | 
					            input.PutInt16(message.lockNo);
 | 
				
			||||||
 | 
					            // 开锁时间
 | 
				
			||||||
 | 
					            input.PutInt16(message.delay);
 | 
				
			||||||
 | 
					            input.Flip();
 | 
				
			||||||
 | 
					            accumulate += 1;
 | 
				
			||||||
 | 
					            session.Write(input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void Encode(IoSession session, object message, IProtocolEncoderOutput output)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            IoBuffer input = IoBuffer.Allocate(12);
 | 
				
			||||||
 | 
					            input.AutoExpand = true;
 | 
				
			||||||
 | 
					            if (message is MyBaseMessage)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var m = message as MyBaseMessage;
 | 
				
			||||||
 | 
					                input.PutInt16(accumulate);
 | 
				
			||||||
 | 
					                input.PutInt16(0);
 | 
				
			||||||
 | 
					                input.PutInt16(6);
 | 
				
			||||||
 | 
					                input.Put((byte)m.addr);
 | 
				
			||||||
 | 
					                // 功能码
 | 
				
			||||||
 | 
					                input.Put((byte)m.functionCode);
 | 
				
			||||||
 | 
					                // 锁号
 | 
				
			||||||
 | 
					                input.PutInt16(m.lockNo);
 | 
				
			||||||
 | 
					                // 开锁时间
 | 
				
			||||||
 | 
					                input.PutInt16(m.delay);
 | 
				
			||||||
 | 
					                input.Flip();
 | 
				
			||||||
 | 
					                accumulate += 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            session.Write(input);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -23,6 +23,15 @@ using Unity;
 | 
				
			||||||
using DM_Weight.msg;
 | 
					using DM_Weight.msg;
 | 
				
			||||||
using DM_Weight.Views;
 | 
					using DM_Weight.Views;
 | 
				
			||||||
using System.Reflection;
 | 
					using System.Reflection;
 | 
				
			||||||
 | 
					using DM_Weight.HIKVISION;
 | 
				
			||||||
 | 
					using PreviewDemo;
 | 
				
			||||||
 | 
					using System.Runtime.InteropServices;
 | 
				
			||||||
 | 
					using DM_Weight.Common;
 | 
				
			||||||
 | 
					using System.Net;
 | 
				
			||||||
 | 
					using System.Text.RegularExpressions;
 | 
				
			||||||
 | 
					using Modbus.Device;
 | 
				
			||||||
 | 
					using Polly;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.Port
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -37,6 +46,12 @@ namespace DM_Weight.Port
 | 
				
			||||||
        // 条码枪串口
 | 
					        // 条码枪串口
 | 
				
			||||||
        public SerialPort scanCodeSerial;
 | 
					        public SerialPort scanCodeSerial;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 冰箱串口
 | 
				
			||||||
 | 
					        public SerialPort fridgeSerial;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 温湿度串口
 | 
				
			||||||
 | 
					        public SerialPort wsdSerial;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 抽屉串口协议232 | 485
 | 
					        // 抽屉串口协议232 | 485
 | 
				
			||||||
        private int _drawerProtocol = Convert.ToInt32(ConfigurationManager.AppSettings["DrawerProtocol"]);
 | 
					        private int _drawerProtocol = Convert.ToInt32(ConfigurationManager.AppSettings["DrawerProtocol"]);
 | 
				
			||||||
| 
						 | 
					@ -71,14 +86,16 @@ namespace DM_Weight.Port
 | 
				
			||||||
        private int[] AfterQuantity { get; set; } = new int[] { };
 | 
					        private int[] AfterQuantity { get; set; } = new int[] { };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 整体流程状态
 | 
					        // 整体流程状态
 | 
				
			||||||
        public int statue { get; set; } = 0;
 | 
					        private int statue { get; set; } = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 是否正在操作中
 | 
					        // 是否正在操作中
 | 
				
			||||||
        public bool Operate { get; set; }
 | 
					        public bool Operate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DateTime dateTime { get; set; } = DateTime.Now;
 | 
					        //冰箱是否正在操作中
 | 
				
			||||||
 | 
					        public bool FridgeOperate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DateTime dateTime { get; set; } = DateTime.Now;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public async void ResetData()
 | 
					        public async void ResetData()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -117,12 +134,104 @@ namespace DM_Weight.Port
 | 
				
			||||||
            DrawerNo = 0;
 | 
					            DrawerNo = 0;
 | 
				
			||||||
            ColNos = new int[] { };
 | 
					            ColNos = new int[] { };
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        public async void OpenBox()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info($"打开药箱,药箱号【{DrawerNo}】");
 | 
				
			||||||
 | 
					            Operate = true;
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                byte[] buffer = await OpenDrawer();
 | 
				
			||||||
 | 
					                int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"OpenDrawer{string.Join(",", r)}");
 | 
				
			||||||
 | 
					                if (DrawerState(r))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    statue = 1;
 | 
				
			||||||
 | 
					                    // 返回消息  抽屉已经打开
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        EventType = util.EventType.DRAWEROPEN,
 | 
				
			||||||
 | 
					                        WindowName = WindowName,
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    logger.Info($"药箱【{DrawerNo}】打开成功");
 | 
				
			||||||
 | 
					                    await Task.Delay(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 返回消息  抽屉打开失败
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        EventType = util.EventType.OPENERROR,
 | 
				
			||||||
 | 
					                        WindowName = WindowName,
 | 
				
			||||||
 | 
					                        Message = $"药箱【{DrawerNo}】打开失败"
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    logger.Info($"药箱【{DrawerNo}】打开失败");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    EventType = util.EventType.OPENERROR,
 | 
				
			||||||
 | 
					                    Message = $"打开药箱异常{ex.Message}"
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                logger.Info($"打开药箱{DrawerNo}异常:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //查询药箱状态
 | 
				
			||||||
 | 
					        public async void GetBoxStatus()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (Operate)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // 查询药箱状态
 | 
				
			||||||
 | 
					                    byte[] buffer = await CheckBoxStatus();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    logger.Info($"GetBoxStatus{string.Join(",", r)}");
 | 
				
			||||||
 | 
					                    // 药箱没有关闭
 | 
				
			||||||
 | 
					                    if (DrawerState(r))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // 继续监听药箱状态
 | 
				
			||||||
 | 
					                        await Task.Delay(200);
 | 
				
			||||||
 | 
					                        GetBoxStatus();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        // 返回消息  药箱已经关闭
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            EventType = util.EventType.DRAWERCLOSE,
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                        logger.Info($"抽屉【{DrawerNo}】已关闭");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    EventType = util.EventType.OPENERROR,
 | 
				
			||||||
 | 
					                    WindowName = WindowName,
 | 
				
			||||||
 | 
					                    Message = $"GetBoxStatus异常:{ex.Message}"
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                logger.Info($"GetBoxStatus异常:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        public async void Start()
 | 
					        public async void Start()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logger.Info($"进行抽屉操作抽屉号【{DrawerNo}】类型【{BoardType}】库位【{string.Join(",", ColNos)}】窗口【{WindowName}】");
 | 
					            logger.Info($"进行抽屉操作抽屉号【{DrawerNo}】类型【{BoardType}】库位【{string.Join(",", ColNos)}】窗口【{WindowName}】");
 | 
				
			||||||
            Operate = true;
 | 
					            Operate = true;
 | 
				
			||||||
 | 
					            //开始录像
 | 
				
			||||||
 | 
					            //_chkFunction.HIKStartDVRRecord();
 | 
				
			||||||
 | 
					            logger.Info($"时间:{DateTime.Now}");
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // 储物箱直接开
 | 
					                // 储物箱直接开
 | 
				
			||||||
| 
						 | 
					@ -574,44 +683,56 @@ namespace DM_Weight.Port
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private readonly IEventAggregator _eventAggregator;
 | 
					        private readonly IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        //private CHKFunction _chkFunction;
 | 
				
			||||||
        public PortUtil(IEventAggregator eventAggregator)
 | 
					        public PortUtil(IEventAggregator eventAggregator)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
            try
 | 
					            //try
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                string DrawerPortPath = ConfigurationManager.AppSettings["DrawerPortPath"];
 | 
					            //    string DrawerPortPath = ConfigurationManager.AppSettings["DrawerPortPath"];
 | 
				
			||||||
                logger.Info($"打开抽屉串口【{DrawerPortPath}】");
 | 
					            //    logger.Info($"打开抽屉串口【{DrawerPortPath}】");
 | 
				
			||||||
                drawerSerial = new SerialPort(DrawerPortPath, 9600, Parity.None, 8);
 | 
					            //    drawerSerial = new SerialPort(DrawerPortPath, 9600, Parity.None, 8);
 | 
				
			||||||
                drawerSerial.Open();
 | 
					            //    drawerSerial.Open();
 | 
				
			||||||
                logger.Info($"抽屉串口打开结果【{drawerSerial.IsOpen}】");
 | 
					            //    logger.Info($"抽屉串口打开结果【{drawerSerial.IsOpen}】");
 | 
				
			||||||
            }
 | 
					            //}
 | 
				
			||||||
            catch (Exception e)
 | 
					            //catch (Exception e)
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                logger.Error("抽屉串口打开错误" + e.Message);
 | 
					            //    logger.Error("抽屉串口打开错误" + e.Message);
 | 
				
			||||||
            }
 | 
					            //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try
 | 
					            //try
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                string ScanCodePortPath = ConfigurationManager.AppSettings["ScanCodePortPath"];
 | 
					            //    string ScanCodePortPath = ConfigurationManager.AppSettings["ScanCodePortPath"];
 | 
				
			||||||
                logger.Info($"打开条码枪串口【{ScanCodePortPath}】");
 | 
					            //    logger.Info($"打开条码枪串口【{ScanCodePortPath}】");
 | 
				
			||||||
                scanCodeSerial = new SerialPort(ScanCodePortPath, 9600, Parity.None, 8);
 | 
					            //    scanCodeSerial = new SerialPort(ScanCodePortPath, 9600, Parity.None, 8);
 | 
				
			||||||
                scanCodeSerial.DataReceived += (object sender, System.IO.Ports.SerialDataReceivedEventArgs e) =>
 | 
					            //    scanCodeSerial.DataReceived += (object sender, System.IO.Ports.SerialDataReceivedEventArgs e) =>
 | 
				
			||||||
                {
 | 
					            //    {
 | 
				
			||||||
                    string code = scanCodeSerial.ReadExisting();
 | 
					            //        string code = scanCodeSerial.ReadExisting();
 | 
				
			||||||
                    _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
					            //        _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
 | 
				
			||||||
                    {
 | 
					            //        {
 | 
				
			||||||
                        EventType = util.EventType.CODESCAN,
 | 
					            //            EventType = util.EventType.CODESCAN,
 | 
				
			||||||
                        Code = code,
 | 
					            //            Code = code,
 | 
				
			||||||
                    });
 | 
					            //        });
 | 
				
			||||||
                };
 | 
					            //    };
 | 
				
			||||||
                scanCodeSerial.Open();
 | 
					            //    scanCodeSerial.Open();
 | 
				
			||||||
                logger.Info($"条码枪串口打开结果【{scanCodeSerial.IsOpen}】");
 | 
					            //    logger.Info($"条码枪串口打开结果【{scanCodeSerial.IsOpen}】");
 | 
				
			||||||
            }
 | 
					            //}
 | 
				
			||||||
            catch (Exception e)
 | 
					            //catch (Exception e)
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                logger.Error("条码枪串口打开错误" + e.Message);
 | 
					            //    logger.Error("条码枪串口打开错误" + e.Message);
 | 
				
			||||||
            }
 | 
					            //}
 | 
				
			||||||
 | 
					            //try
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    string FridgePortPath = ConfigurationManager.AppSettings["FridgePortPath"];
 | 
				
			||||||
 | 
					            //    logger.Info($"打开冰箱串口【{FridgePortPath}】");
 | 
				
			||||||
 | 
					            //    fridgeSerial = new SerialPort(FridgePortPath, 9600, Parity.None, 8);
 | 
				
			||||||
 | 
					            //    fridgeSerial.Open();
 | 
				
			||||||
 | 
					            //    logger.Info($"冰箱串口打开结果【{fridgeSerial.IsOpen}】");
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //catch (Exception e)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    logger.Error("冰箱串口打开错误" + e.Message);
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
            if (_canBusExsit)
 | 
					            if (_canBusExsit)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
| 
						 | 
					@ -628,7 +749,19 @@ namespace DM_Weight.Port
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                string wsdSerialPort = ConfigurationManager.AppSettings["wsdSerialPort"];
 | 
				
			||||||
 | 
					                logger.Info($"打开温湿度串口【{wsdSerialPort}】");
 | 
				
			||||||
 | 
					                wsdSerial = new SerialPort(wsdSerialPort, 9600, Parity.None, 8);
 | 
				
			||||||
 | 
					                wsdSerial.Open();
 | 
				
			||||||
 | 
					                logger.Info($"温湿度串口打开结果【{wsdSerial.IsOpen}】");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception e)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Error("温湿度串口打开错误" + e.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //_chkFunction = chkFunction;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -637,23 +770,29 @@ namespace DM_Weight.Port
 | 
				
			||||||
            byte[] buffer = new byte[length];
 | 
					            byte[] buffer = new byte[length];
 | 
				
			||||||
            // try
 | 
					            // try
 | 
				
			||||||
            // {
 | 
					            // {
 | 
				
			||||||
                int _length = 0;
 | 
					            int _length = 0;
 | 
				
			||||||
                DateTime start = DateTime.Now;
 | 
					            DateTime start = DateTime.Now;
 | 
				
			||||||
                DateTime end = DateTime.Now;
 | 
					            DateTime end = DateTime.Now;
 | 
				
			||||||
                while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
 | 
					            while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _length = serialPort.BytesToRead;
 | 
				
			||||||
 | 
					                end = DateTime.Now;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (_length != length)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (_length != 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    _length = serialPort.BytesToRead;
 | 
					                    byte[] _buffer = new byte[_length];
 | 
				
			||||||
                    end = DateTime.Now;
 | 
					                    serialPort.Read(_buffer, 0, _length);
 | 
				
			||||||
 | 
					                    logger.Info($"交互超时回复:{Convert.ToHexString(buffer)}");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (_length != length)
 | 
					                throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
 | 
				
			||||||
                {
 | 
					            }
 | 
				
			||||||
                    throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
 | 
					            serialPort.Read(buffer, 0, length);
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                serialPort.Read(buffer, 0, length);
 | 
					 | 
				
			||||||
            // }
 | 
					            // }
 | 
				
			||||||
            // catch (Exception ex)
 | 
					            // catch (Exception ex)
 | 
				
			||||||
            // {
 | 
					            // {
 | 
				
			||||||
                // logger.Error($"GetBufferByPort:{ex.Message}");
 | 
					            // logger.Error($"GetBufferByPort:{ex.Message}");
 | 
				
			||||||
            // }
 | 
					            // }
 | 
				
			||||||
            return buffer;
 | 
					            return buffer;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -671,7 +810,6 @@ namespace DM_Weight.Port
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        #region 抽屉串口操作
 | 
					        #region 抽屉串口操作
 | 
				
			||||||
        // 打开抽屉
 | 
					        // 打开抽屉
 | 
				
			||||||
        public async Task<byte[]> OpenDrawer()
 | 
					        public async Task<byte[]> OpenDrawer()
 | 
				
			||||||
| 
						 | 
					@ -696,7 +834,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
            return await GetBufferByPort(drawerSerial, 11);
 | 
					            return await GetBufferByPort(drawerSerial, 11);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool DrawerState(int[] r)
 | 
					        private bool DrawerState(int[] r)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            int index = DrawerNo > 8 ? DrawerNo - 7 : DrawerNo + 1;
 | 
					            int index = DrawerNo > 8 ? DrawerNo - 7 : DrawerNo + 1;
 | 
				
			||||||
            return r[index] == 0;
 | 
					            return r[index] == 0;
 | 
				
			||||||
| 
						 | 
					@ -725,6 +863,29 @@ namespace DM_Weight.Port
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return await GetBufferByPort(drawerSerial, 11);
 | 
					            return await GetBufferByPort(drawerSerial, 11);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        // 查询药箱状态
 | 
				
			||||||
 | 
					        public async Task<byte[]> CheckBoxStatus()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            drawerSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					            byte[] buffer = new byte[] { 0xaa, 0x42, 0xee };
 | 
				
			||||||
 | 
					            if (_drawerProtocol == 485)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (DrawerNo > 8)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    buffer = new byte[] { 0xaa, 0x22, 0xee };
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    buffer = new byte[] { 0xaa, 0x12, 0xee };
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            logger.Info($"查询抽屉状态,串口数据:{Convert.ToHexString(buffer)}");
 | 
				
			||||||
 | 
					            drawerSerial.Write(buffer, 0, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return await GetBufferByPort(drawerSerial, 11);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region can总线串口操作
 | 
					        #region can总线串口操作
 | 
				
			||||||
| 
						 | 
					@ -769,7 +930,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
            canBusSerial.Write(buffer, 0, 8);
 | 
					            canBusSerial.Write(buffer, 0, 8);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public int[] CheckStorageStatus(int[] data)
 | 
					        private int[] CheckStorageStatus(int[] data)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            int a = data[0];
 | 
					            int a = data[0];
 | 
				
			||||||
            int b = data[1];
 | 
					            int b = data[1];
 | 
				
			||||||
| 
						 | 
					@ -938,6 +1099,37 @@ namespace DM_Weight.Port
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region  药盒操作
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 打开药盒
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="ColNo"></param>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task OpenBox(int ColNo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var vlock = 321;
 | 
				
			||||||
 | 
					            decimal decolNO = (decimal)ColNo;
 | 
				
			||||||
 | 
					            var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO % 3)).ToString(), 16);
 | 
				
			||||||
 | 
					            byte[] buffer = new byte[] { 0xaa, (byte)channel, 5, (byte)vlock, 0x00, 0x00, 0x00, 0xee };
 | 
				
			||||||
 | 
					            canBusSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					            await Task.Delay(TimeSpan.FromMilliseconds(20));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询药盒状态
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="text"></param>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task<byte[]> GetBoxLockState(int ColNo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            decimal deColNo = (decimal)ColNo;
 | 
				
			||||||
 | 
					            var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(deColNo / 3)).ToString(), 16);
 | 
				
			||||||
 | 
					            byte[] buffer = new byte[] { 0xaa, (byte)channel, 2, 0, 0, 0, 0, 0xee };
 | 
				
			||||||
 | 
					            canBusSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					            return await GetBufferByPort(canBusSerial, 8);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private string trim(string text)
 | 
					        private string trim(string text)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //此处使用了转义字符如:\',\",\\,分别表示单引号,双引号,反斜杠
 | 
					            //此处使用了转义字符如:\',\",\\,分别表示单引号,双引号,反斜杠
 | 
				
			||||||
| 
						 | 
					@ -1025,7 +1217,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                canBusSerial.DiscardInBuffer();
 | 
					                canBusSerial.DiscardInBuffer();
 | 
				
			||||||
                int channel = Convert.ToInt32((drawerNo * 10 + colNo).ToString(),16);
 | 
					                int channel = Convert.ToInt32((drawerNo * 10 + colNo).ToString(), 16);
 | 
				
			||||||
                byte[] buffer = new byte[] { 0xaa, (byte)channel, 6, 0, 0, 0, 0, 0xee };
 | 
					                byte[] buffer = new byte[] { 0xaa, (byte)channel, 6, 0, 0, 0, 0, 0xee };
 | 
				
			||||||
                buffer[3] = (byte)(quantity >> 8);
 | 
					                buffer[3] = (byte)(quantity >> 8);
 | 
				
			||||||
                buffer[4] = (byte)(quantity & 0xff);
 | 
					                buffer[4] = (byte)(quantity & 0xff);
 | 
				
			||||||
| 
						 | 
					@ -1070,6 +1262,18 @@ namespace DM_Weight.Port
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 标签显示屏
 | 
				
			||||||
 | 
					        //清屏
 | 
				
			||||||
 | 
					        public void ClearContentMethod(int drawerNo, int colNo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            decimal deColNo = colNo;
 | 
				
			||||||
 | 
					            var channel = drawerNo * 10 + Math.Ceiling(deColNo / 3);
 | 
				
			||||||
 | 
					            var colNo2 = 321;
 | 
				
			||||||
 | 
					            byte[] buffer = new byte[] { 0xaa };
 | 
				
			||||||
 | 
					            canBusSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region 回收箱操作
 | 
					        #region 回收箱操作
 | 
				
			||||||
| 
						 | 
					@ -1095,7 +1299,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
                logger.Info($"操作发生异常:ex:{ex.Message}");
 | 
					                logger.Info($"操作发生异常:ex:{ex.Message}");
 | 
				
			||||||
                return null;
 | 
					                return null;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
           
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // 回收箱状态查询
 | 
					        // 回收箱状态查询
 | 
				
			||||||
        public async Task<byte[]> CheckRecoverStatus()
 | 
					        public async Task<byte[]> CheckRecoverStatus()
 | 
				
			||||||
| 
						 | 
					@ -1256,7 +1460,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                logger.Info($"操作发生异常:ex:{ex.Message},方法名:ClearCount;参数:{DrawerNo},{ColNo}");
 | 
					                logger.Info($"操作发生异常:ex:{ex.Message},方法名:ClearCount;参数:{DrawerNo},{ColNo}");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
           
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public async void SetNumCount(int DrawerNo, int ColNo, int Quantity)
 | 
					        public async void SetNumCount(int DrawerNo, int ColNo, int Quantity)
 | 
				
			||||||
| 
						 | 
					@ -1287,10 +1491,425 @@ namespace DM_Weight.Port
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                logger.Info($"操作发生异常:ex:{ex.Message},方法名:SetNumCount;参数:{DrawerNo},{ColNo},{Quantity}");
 | 
					                logger.Info($"操作发生异常:ex:{ex.Message},方法名:SetNumCount;参数:{DrawerNo},{ColNo},{Quantity}");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 冰箱使能
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task FridegOpen(int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                byte bAddress;
 | 
				
			||||||
 | 
					                if (iIndex == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x01;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x02;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD4, 0x00, 0x01, 0x0C, 0xF2 };
 | 
				
			||||||
 | 
					                //byte[] buffer = new byte[] { 0x01, 0x06, 0x10, 0xD4, 0x00, 0x01 };
 | 
				
			||||||
 | 
					                ////获取数组CRC校验码
 | 
				
			||||||
 | 
					                //byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
 | 
				
			||||||
 | 
					                ////Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                //int dataLength = buffer.Length;
 | 
				
			||||||
 | 
					                //Array.Resize(ref buffer, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                //for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    buffer[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					                logger.Info($"冰箱使能【{Convert.ToHexString(buffer)}】");
 | 
				
			||||||
 | 
					                fridgeSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					                await Task.Delay(80);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"冰箱使能发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            FridgeOperate = false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 冰箱失能
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task FridgeOff(int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                byte bAddress;
 | 
				
			||||||
 | 
					                if (iIndex == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x01;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x02;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD4, 0x00, 0x00, 0xCD, 0x32 };
 | 
				
			||||||
 | 
					                //byte[] buffer = new byte[] { 0x01, 0x06, 0x10, 0xD4, 0x00, 0x01 };
 | 
				
			||||||
 | 
					                ////获取数组CRC校验码
 | 
				
			||||||
 | 
					                //byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
 | 
				
			||||||
 | 
					                ////Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                //int dataLength = buffer.Length;
 | 
				
			||||||
 | 
					                //Array.Resize(ref buffer, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                //for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    buffer[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					                logger.Info($"冰箱失能【{Convert.ToHexString(buffer)}】");
 | 
				
			||||||
 | 
					                fridgeSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					                await Task.Delay(80);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"冰箱失能发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            FridgeOperate = false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 冰箱报警使能
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task FridgeAlarmOn(int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                byte bAddress;
 | 
				
			||||||
 | 
					                if (iIndex == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x01;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x02;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD5, 0x00, 0x01, 0x5D, 0x32 };
 | 
				
			||||||
 | 
					                //byte[] buffer = new byte[] { 0x01, 0x06, 0x10, 0xD5, 0x00, 0x01 };
 | 
				
			||||||
 | 
					                ////获取数组CRC校验码
 | 
				
			||||||
 | 
					                //byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
 | 
				
			||||||
 | 
					                ////Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                //int dataLength = buffer.Length;
 | 
				
			||||||
 | 
					                //Array.Resize(ref buffer, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                //for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    buffer[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					                logger.Info($"冰箱报警使能【{Convert.ToHexString(buffer)}】");
 | 
				
			||||||
 | 
					                fridgeSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					                await Task.Delay(80);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"冰箱报警使能发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            FridgeOperate = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 冰箱报警失能
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task FridgeAlarmOff(int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                byte bAddress;
 | 
				
			||||||
 | 
					                if (iIndex == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x01;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x02;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD5, 0x00, 0x00, 0x9C, 0xF2 };
 | 
				
			||||||
 | 
					                //byte[] buffer = new byte[] { 0x01, 0x06, 0x10, 0xD5, 0x00, 0x00 };
 | 
				
			||||||
 | 
					                ////获取数组CRC校验码
 | 
				
			||||||
 | 
					                //byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
 | 
				
			||||||
 | 
					                ////Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                //int dataLength = buffer.Length;
 | 
				
			||||||
 | 
					                //Array.Resize(ref buffer, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                //for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    buffer[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					                logger.Info($"冰箱报警失能【{Convert.ToHexString(buffer)}】");
 | 
				
			||||||
 | 
					                fridgeSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					                await Task.Delay(80);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"冰箱报警失能发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            FridgeOperate = false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 冰箱温度设定最小
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task FridgeMinSetting(float min, int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                int iMix = Convert.ToInt32(min * 10);
 | 
				
			||||||
 | 
					                fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                //byte[] bufferMin = new byte[] { 0x01, 0x06, 0x10, 0xC9, 0x00, 0x15, 0x9C, 0xFB };
 | 
				
			||||||
 | 
					                byte bAddress;
 | 
				
			||||||
 | 
					                if (iIndex == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x01;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x02;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                byte[] bufferMin = new byte[] { bAddress, 0x06, 0x10, 0xC9, 0x00, (byte)(iMix & 0xff) };
 | 
				
			||||||
 | 
					                //获取数组CRC校验码
 | 
				
			||||||
 | 
					                byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMin);
 | 
				
			||||||
 | 
					                //Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                int dataLength = bufferMin.Length;
 | 
				
			||||||
 | 
					                Array.Resize(ref bufferMin, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bufferMin[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                logger.Info($"冰箱温度设定Min:【{Convert.ToHexString(bufferMin)}】");
 | 
				
			||||||
 | 
					                fridgeSerial.Write(bufferMin, 0, 8);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 冰箱温度设定最大
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task FridgeMaxSetting(float max, int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int iMax = Convert.ToInt32(max * 10);
 | 
				
			||||||
 | 
					                fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                //byte[] bufferMin = new byte[] { 0x01, 0x06, 0x10, 0xC9, 0x00, 0x15, 0x9C, 0xFB };
 | 
				
			||||||
 | 
					                byte bAddress;
 | 
				
			||||||
 | 
					                if (iIndex == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x01;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x02;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                byte[] bufferMax = new byte[] { bAddress, 0x06, 0x10, 0xC8, 0x00, (byte)(iMax & 0xff) };
 | 
				
			||||||
 | 
					                //获取数组CRC校验码
 | 
				
			||||||
 | 
					                byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMax);
 | 
				
			||||||
 | 
					                //Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                int dataLength = bufferMax.Length;
 | 
				
			||||||
 | 
					                Array.Resize(ref bufferMax, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bufferMax[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                logger.Info($"冰箱温度设定Max:【{Convert.ToHexString(bufferMax)}】");
 | 
				
			||||||
 | 
					                fridgeSerial.Write(bufferMax, 0, 8);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 获取冰箱温度
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task<float> GetFridgeTemperature(int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            float temperature = 0.0f;
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                byte bAddress;
 | 
				
			||||||
 | 
					                if (iIndex == 1)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x01;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    bAddress = 0x02;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                byte[] buffer = new byte[] { bAddress, 0x03, 0x10, 0x02, 0x00, 0x01, 0x21, 0x0A };
 | 
				
			||||||
 | 
					                //byte[] buffer = new byte[] { 0x01, 0x03, 0x10, 0x02, 0x00, 0x01 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                ////获取数组CRC校验码
 | 
				
			||||||
 | 
					                //byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
 | 
				
			||||||
 | 
					                ////Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                //int dataLength = buffer.Length;
 | 
				
			||||||
 | 
					                //Array.Resize(ref buffer, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                //for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    buffer[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"获取冰箱温度【{Convert.ToHexString(buffer)}】");
 | 
				
			||||||
 | 
					                fridgeSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                byte[] retByte = await GetBufferByPort(fridgeSerial, 7);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"获取冰箱温度返回【{Convert.ToHexString(retByte)}】");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (retByte != null && retByte.Length >= 7)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var hight = retByte[3];
 | 
				
			||||||
 | 
					                    var low = retByte[4];
 | 
				
			||||||
 | 
					                    int iHight = Convert.ToInt32(hight << 8);
 | 
				
			||||||
 | 
					                    int iLow = Convert.ToInt32(retByte[4]);
 | 
				
			||||||
 | 
					                    temperature = Convert.ToSingle(iHight + iLow) / 10;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return temperature;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 设置冰箱温度
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task<float> SetFridgeTemperature(float temperature, int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            int tpt = (int)temperature * 10;
 | 
				
			||||||
 | 
					            byte Temperature = (byte)(tpt & 0xff);
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //if (!FridgeOperate)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                    byte bAddress;
 | 
				
			||||||
 | 
					                    if (iIndex == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        bAddress = 0x01;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        bAddress = 0x02;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    //byte[] buffer = new byte[] { 0x01, 0x03, 0x10, 0x02, 0x00, 0x01, 0x21,0x0A };
 | 
				
			||||||
 | 
					                    byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0x02, 0x00, (byte)Temperature };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //获取数组CRC校验码
 | 
				
			||||||
 | 
					                    byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
 | 
				
			||||||
 | 
					                    //Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                    int dataLength = buffer.Length;
 | 
				
			||||||
 | 
					                    Array.Resize(ref buffer, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                    for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        buffer[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    logger.Info($"设置冰箱温度【{Convert.ToHexString(buffer)}】");
 | 
				
			||||||
 | 
					                    fridgeSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    await GetBufferByPort(fridgeSerial, 8);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return temperature;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 冰箱延迟报警
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public async Task FridgeDelayWarm(int iIndex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //if (!FridgeOperate)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    fridgeSerial.DiscardInBuffer();
 | 
				
			||||||
 | 
					                    byte bAddress;
 | 
				
			||||||
 | 
					                    if (iIndex == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        bAddress = 0x01;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        bAddress = 0x02;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xCD, 0x00, 0x01, 0xDD, 0x35 };
 | 
				
			||||||
 | 
					                    //byte[] buffer = new byte[] { 0x01, 0x06, 0x10, 0xCD, 0x00, 0x01 };
 | 
				
			||||||
 | 
					                    ////获取数组CRC校验码
 | 
				
			||||||
 | 
					                    //byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
 | 
				
			||||||
 | 
					                    ////Array.Reverse(byteDate);
 | 
				
			||||||
 | 
					                    //int dataLength = buffer.Length;
 | 
				
			||||||
 | 
					                    //Array.Resize(ref buffer, dataLength + byteDate.Length);
 | 
				
			||||||
 | 
					                    //for (int i = 0; i < byteDate.Length; i++)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    buffer[dataLength + i] = byteDate[i];
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                    logger.Info($"冰箱延迟报警【{Convert.ToHexString(buffer)}】");
 | 
				
			||||||
 | 
					                    fridgeSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //FridgeOperate = false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 温湿度
 | 
				
			||||||
 | 
					        public TemperatureHumidityInfo GetWSD()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            TemperatureHumidityInfo temperatureHumidityInfo = new TemperatureHumidityInfo();
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var master = ModbusSerialMaster.CreateRtu(wsdSerial);
 | 
				
			||||||
 | 
					                int no = 1;
 | 
				
			||||||
 | 
					                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.GroupNo = "DM5";
 | 
				
			||||||
 | 
					                    temperatureHumidityInfo.Temp = temp.ToString();
 | 
				
			||||||
 | 
					                    temperatureHumidityInfo.Humi = humi.ToString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //if (wsdSerial.IsOpen)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    wsdSerial.Close();
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					                //master.Dispose();
 | 
				
			||||||
 | 
					                logger.Info($"获取温湿度{string.Join("", r)}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"获取温湿度异常{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return temperatureHumidityInfo;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,157 @@
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using DM_Weight.ViewModels;
 | 
				
			||||||
 | 
					using DM_Weight.Views;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using Mina.Core.Future;
 | 
				
			||||||
 | 
					using Mina.Core.Session;
 | 
				
			||||||
 | 
					using Mina.Filter.Codec;
 | 
				
			||||||
 | 
					using Mina.Filter.Logging;
 | 
				
			||||||
 | 
					using Mina.Transport.Socket;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Net;
 | 
				
			||||||
 | 
					using System.Speech.Synthesis;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.Port
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class SocketHelper
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(SocketHelper));
 | 
				
			||||||
 | 
					        AsyncSocketConnector acceptor = new AsyncSocketConnector();
 | 
				
			||||||
 | 
					        IConnectFuture iConnectFuture;
 | 
				
			||||||
 | 
					        public bool OpenStatus = false;
 | 
				
			||||||
 | 
					        public bool ConnectedStatus = false;
 | 
				
			||||||
 | 
					        //多线程退出标识
 | 
				
			||||||
 | 
					        public bool IsMultiThread = false;
 | 
				
			||||||
 | 
					        string ip = ConfigurationManager.AppSettings["modbusIp"].ToString();
 | 
				
			||||||
 | 
					        int port = Convert.ToInt32(ConfigurationManager.AppSettings["modbusPort"]);
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public DateTime dateTime { get; set; } = DateTime.Now;
 | 
				
			||||||
 | 
					        FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					        public SocketHelper(IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					            acceptor.ExceptionCaught += (o, e) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Error($"网口通信超时:{e.Exception}");
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = $"网口通信超时,正在重试!",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //acceptor.FilterChain.AddLast("logger", new LoggingFilter());
 | 
				
			||||||
 | 
					            acceptor.FilterChain.AddLast("encoding", new ProtocolCodecFilter(new MyMinaCodecFactory()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            acceptor.SessionIdle += (o, e) => logger.Info("IDLE " + e.Session.GetIdleCount(e.IdleStatus));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            acceptor.MessageReceived += (o, e) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                OpenStatus = (bool)e.Message;
 | 
				
			||||||
 | 
					                logger.Info("MessageReceived>>>>>>>>>>>>>>>>" + OpenStatus);
 | 
				
			||||||
 | 
					                //if(OpenStatus)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    HomeWindow.idleTimer.Stop();
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					                //else
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    HomeWindow.idleTimer.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0") * 1000;
 | 
				
			||||||
 | 
					                //    HomeWindow.idleTimer.Start();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //}    
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            acceptor.SessionClosed += new EventHandler<IoSessionEventArgs>(SessionCloseMethod);
 | 
				
			||||||
 | 
					            //acceptor.SessionClosed += (o, e) =>
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    logger.Info("SessionClosed");
 | 
				
			||||||
 | 
					            //    //Task.Delay(50).Wait();
 | 
				
			||||||
 | 
					            //    SocketConnect();
 | 
				
			||||||
 | 
					            //    Task.Factory.StartNew(() =>
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        _fingerprintUtil.FingerDisconnect();
 | 
				
			||||||
 | 
					            //    });
 | 
				
			||||||
 | 
					            //};
 | 
				
			||||||
 | 
					            this.SocketConnect();
 | 
				
			||||||
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        int i = 0;
 | 
				
			||||||
 | 
					        public void SocketConnect()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Thread.Sleep(50);
 | 
				
			||||||
 | 
					            i++;
 | 
				
			||||||
 | 
					            iConnectFuture = acceptor.Connect(new IPEndPoint(IPAddress.Parse(ip), port)).Await();
 | 
				
			||||||
 | 
					            logger.Info($"第{i}次连接结果:{iConnectFuture.Connected.ToString()}");
 | 
				
			||||||
 | 
					            if (!iConnectFuture.Connected)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (i <= 3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Thread.Sleep(50);
 | 
				
			||||||
 | 
					                    //没连上会再连两次
 | 
				
			||||||
 | 
					                    SocketConnect();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    logger.Error($"尝试{i}次连接后均连接不上");
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = $"网口连接断开!",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                i = 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            ConnectedStatus = iConnectFuture.Connected;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SessionCloseMethod(System.Object o, IoSessionEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            logger.Info($"SessionClosed");
 | 
				
			||||||
 | 
					            SocketConnect();
 | 
				
			||||||
 | 
					            Task.Factory.StartNew(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _fingerprintUtil.FingerDisconnect();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public void SocketDisConnect()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                acceptor.SessionClosed -= new EventHandler<IoSessionEventArgs>(SessionCloseMethod);
 | 
				
			||||||
 | 
					                iConnectFuture.Session.CloseNow();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch(Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info($"SocketDisConnect异常{ex.Message}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public void SendMessage(MyBaseMessage baseMessage)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!ConnectedStatus)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SocketConnect();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            iConnectFuture.Session.Write(baseMessage);
 | 
				
			||||||
 | 
					            logger.Info($"SendMessage:{baseMessage.functionCode},delay:{baseMessage.delay},lockNo:{baseMessage.lockNo}");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
 | 
				
			||||||
 | 
					        public void SpeakAsync(string textinfo)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            speechSynthesizer.Rate = 2;
 | 
				
			||||||
 | 
					            speechSynthesizer.SpeakAsync(textinfo);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -17,7 +18,7 @@ namespace DM_Weight.Report
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 定义Grid++Report报表主对象
 | 
					        // 定义Grid++Report报表主对象
 | 
				
			||||||
        public static GridppReport Report = new GridppReport();
 | 
					        public static GridppReport Report = new GridppReport();
 | 
				
			||||||
        public static string gridConnectionString =  ConfigurationManager.AppSettings["gridConnectionString"];
 | 
					        public static string gridConnectionString = ConfigurationManager.AppSettings["gridConnectionString"];
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
         * 打印预览
 | 
					         * 打印预览
 | 
				
			||||||
         * tempname: 模板文件名称
 | 
					         * tempname: 模板文件名称
 | 
				
			||||||
| 
						 | 
					@ -43,7 +44,7 @@ namespace DM_Weight.Report
 | 
				
			||||||
            //{
 | 
					            //{
 | 
				
			||||||
            //    Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
					            //    Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
            //});
 | 
					            //});
 | 
				
			||||||
            string machine_id=(ConfigurationManager.AppSettings["machineId"] ?? "DM1"); 
 | 
					            string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
            string SQL = $@"SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
 | 
					            string SQL = $@"SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
 | 
				
			||||||
                          di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity,
 | 
					                          di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manuFactory,di.`max_stock` AS baseQuantity,
 | 
				
			||||||
                          cl.`drug_id` AS drugId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` =  '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`";
 | 
					                          cl.`drug_id` AS drugId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` =  '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`";
 | 
				
			||||||
| 
						 | 
					@ -57,9 +58,9 @@ namespace DM_Weight.Report
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
 | 
					            DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
 | 
				
			||||||
            DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
 | 
					            DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
 | 
				
			||||||
            string p_machine_id= (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
					            string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
 | 
				
			||||||
            // 定义Grid++Report报表主对象
 | 
					            // 定义Grid++Report报表主对象
 | 
				
			||||||
             GridppReport Report = new GridppReport();
 | 
					            GridppReport Report = new GridppReport();
 | 
				
			||||||
            // 加载模板文件
 | 
					            // 加载模板文件
 | 
				
			||||||
            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "account_book_temp.grf");
 | 
					            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "account_book_temp.grf");
 | 
				
			||||||
            string SQL = string.Empty;
 | 
					            string SQL = string.Empty;
 | 
				
			||||||
| 
						 | 
					@ -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报表主对象
 | 
				
			||||||
| 
						 | 
					@ -146,9 +205,9 @@ namespace DM_Weight.Report
 | 
				
			||||||
                         AND dmr.`machine_id` = '{p_machine_id}' AND dmr.`operation_time` > '{p_startDate}'
 | 
					                         AND dmr.`machine_id` = '{p_machine_id}' AND dmr.`operation_time` > '{p_startDate}'
 | 
				
			||||||
                        AND dmr.`operation_time` < '{p_endDate}'";
 | 
					                        AND dmr.`operation_time` < '{p_endDate}'";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
					            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
				
			||||||
            Report.DetailGrid.Recordset.QuerySQL= SQL;
 | 
					            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Report.PrintPreview(true);
 | 
					            Report.PrintPreview(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -166,10 +225,145 @@ namespace DM_Weight.Report
 | 
				
			||||||
            GridppReport Report = new GridppReport();
 | 
					            GridppReport Report = new GridppReport();
 | 
				
			||||||
            // 加载模板文件
 | 
					            // 加载模板文件
 | 
				
			||||||
            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//machine_log.grf");
 | 
					            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//machine_log.grf");
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
            // 加载数据
 | 
					            // 加载数据
 | 
				
			||||||
            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,181 @@
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public AdditionWindowViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _dialogService = dialogService;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        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.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)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    for (int i = 0; i < selectedStock.Count; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        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(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //更新 交接柜 库存信息
 | 
				
			||||||
 | 
					                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,
 | 
				
			||||||
 | 
					                        }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).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];
 | 
				
			||||||
 | 
					                            //更新交接柜状态为 已取药未入库
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(new ChannelList()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                State = 0,
 | 
				
			||||||
 | 
					                                Id = jiaojie_it.ChannelLst.Id
 | 
				
			||||||
 | 
					                            }).UpdateColumns(it => it.State).ExecuteCommand();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        //刷新
 | 
				
			||||||
 | 
					        public DelegateCommand QueryCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() => RequestData());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //设置选中药箱的复选框状态
 | 
				
			||||||
 | 
					        private void SetIsSelected(ChannelStock channelStock)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (channelStock != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (channelStock.ChannelLst.State == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    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();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -0,0 +1,475 @@
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					using DM_Weight.msg;
 | 
				
			||||||
 | 
					using DM_Weight.Port;
 | 
				
			||||||
 | 
					using DM_Weight.util;
 | 
				
			||||||
 | 
					using DM_Weight.Views;
 | 
				
			||||||
 | 
					using log4net;
 | 
				
			||||||
 | 
					using log4net.Repository.Hierarchy;
 | 
				
			||||||
 | 
					using Prism.Commands;
 | 
				
			||||||
 | 
					using Prism.Events;
 | 
				
			||||||
 | 
					using Prism.Mvvm;
 | 
				
			||||||
 | 
					using Prism.Regions;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.ComponentModel;
 | 
				
			||||||
 | 
					using System.Configuration;
 | 
				
			||||||
 | 
					using System.Drawing.Printing;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Linq.Expressions;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class CheckOrderWindowViewModel : BindableBase,INavigationAware, IRegionMemberLifetime
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        //private int _pageNum = 1;
 | 
				
			||||||
 | 
					        //public int PageNum
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _pageNum;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        SetProperty(ref _pageNum, value);
 | 
				
			||||||
 | 
					        //        RequestData();
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private int _pageCount = 1;
 | 
				
			||||||
 | 
					        //public int PageCount
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _pageCount;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        SetProperty(ref _pageCount, value);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private int _pageSize = 8;
 | 
				
			||||||
 | 
					        //public int PageSize
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _pageSize;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        SetProperty(ref _pageSize, value);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //private int _totalCount = 0;
 | 
				
			||||||
 | 
					        //public int TotalCount
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => _totalCount;
 | 
				
			||||||
 | 
					        //    set
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        SetProperty(ref _totalCount, value);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderWindowViewModel));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int _status=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public int Status { get => _status; set => SetProperty(ref _status, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool _btnEnable=true;
 | 
				
			||||||
 | 
					        public bool BtnEnable { get => _btnEnable;set=>SetProperty(ref _btnEnable, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //抽屉号列表
 | 
				
			||||||
 | 
					        public static List<int> iList = new List<int>();
 | 
				
			||||||
 | 
					        //第几个抽屉号
 | 
				
			||||||
 | 
					        //public static int iNumber = 1;
 | 
				
			||||||
 | 
					        private List<OrderDetail> orderDetailList=new();
 | 
				
			||||||
 | 
					        public List<OrderDetail> OrderDetailList
 | 
				
			||||||
 | 
					        { 
 | 
				
			||||||
 | 
					            get=> orderDetailList;
 | 
				
			||||||
 | 
					            set=>SetProperty(ref orderDetailList, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 查询条件  处方日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string OrderDate
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return _orderDate; }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (!String.IsNullOrEmpty(value))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    SetProperty(ref _orderDate, value);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                RequestData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        public CheckOrderWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // 取消消息订阅
 | 
				
			||||||
 | 
					            //_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					            //_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand Query 
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(()=> { RequestData(); });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public void RequestData()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OrderDetailList.Clear();
 | 
				
			||||||
 | 
					            //int totalCount = 0;
 | 
				
			||||||
 | 
					            List<OrderDetail> queryData = SqlSugarHelper.Db.Queryable<OrderDetail>()
 | 
				
			||||||
 | 
					                .Includes<OrderInfo>(od => od._OrderInfo)
 | 
				
			||||||
 | 
					                .Includes<DrugInfo>(od => od.DrugInfo)
 | 
				
			||||||
 | 
					                .WhereIF(OrderDate != null, od => od._OrderInfo.RecvDate.ToString("yyyy-MM-dd") == OrderDate)
 | 
				
			||||||
 | 
					                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), od => od._OrderInfo.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
				
			||||||
 | 
					                .Where(od => od._OrderInfo.DmStatus == 0)
 | 
				
			||||||
 | 
					                .Where(od => od._OrderInfo.HisDispFlag == 0)
 | 
				
			||||||
 | 
					                .Where(od => od._OrderInfo.CancelFlag == 0)
 | 
				
			||||||
 | 
					                //.Where(od=>od._OrderInfo.OrderNo== "202312219183416")
 | 
				
			||||||
 | 
					                .Where(od=>od._OrderInfo.DoctorCode== HomeWindowViewModel.Operator.UserBarcode)
 | 
				
			||||||
 | 
					                .OrderBy(od => od.OrderId)
 | 
				
			||||||
 | 
					                .ToList();
 | 
				
			||||||
 | 
					                //.ToPageList(PageNum, PageSize, ref totalCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ICollectionView vw = CollectionViewSource.GetDefaultView(queryData);
 | 
				
			||||||
 | 
					            vw.GroupDescriptions.Add(new PropertyGroupDescription("_OrderInfo"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            OrderDetailList = queryData;
 | 
				
			||||||
 | 
					            //TotalCount = totalCount;
 | 
				
			||||||
 | 
					            //PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //核对确认
 | 
				
			||||||
 | 
					        public DelegateCommand ConfirmCommand
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                ConfirmAction();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void ConfirmAction()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //打开当前用户下的药箱
 | 
				
			||||||
 | 
					            iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5")
 | 
				
			||||||
 | 
					                .Where(cl => cl.BelongUser == HomeWindowViewModel.Operator.UserName)
 | 
				
			||||||
 | 
					                .Select(cl => cl.DrawerNo).ToList();
 | 
				
			||||||
 | 
					            if (iList.Count > 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _portUtil.SpeakAsync("正在打开药箱");
 | 
				
			||||||
 | 
					                _portUtil.DrawerNo = iList[0];
 | 
				
			||||||
 | 
					                Status = 1;
 | 
				
			||||||
 | 
					                _portUtil.OpenBox();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    switch (msg.EventType)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        // 药箱打开
 | 
				
			||||||
 | 
					        //        case EventType.DRAWEROPEN:
 | 
				
			||||||
 | 
					        //            BtnEnable = false;
 | 
				
			||||||
 | 
					        //            //记录开药箱日志
 | 
				
			||||||
 | 
					        //            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                MachineId = "DM5",
 | 
				
			||||||
 | 
					        //                DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					        //                Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					        //                OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					        //                Type = 55,
 | 
				
			||||||
 | 
					        //                InvoiceId = "药箱打开",
 | 
				
			||||||
 | 
					        //            }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            if (iNumber < iList.Count)
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                _portUtil.DrawerNo = iList[iNumber];
 | 
				
			||||||
 | 
					        //                iNumber++;
 | 
				
			||||||
 | 
					        //                if (Status == 1)
 | 
				
			||||||
 | 
					        //                {
 | 
				
			||||||
 | 
					        //                    Status = 2;
 | 
				
			||||||
 | 
					        //                }
 | 
				
			||||||
 | 
					        //                _portUtil.OpenBox();
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            else
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                iNumber = 0;
 | 
				
			||||||
 | 
					        //                _portUtil.GetBoxStatus();
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            break;
 | 
				
			||||||
 | 
					        //        // 药箱关闭
 | 
				
			||||||
 | 
					        //        case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					        //            //记录药箱操作日志
 | 
				
			||||||
 | 
					        //            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                MachineId = "DM5",
 | 
				
			||||||
 | 
					        //                DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					        //                Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					        //                OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					        //                Type = 55,
 | 
				
			||||||
 | 
					        //                InvoiceId = "药箱关闭",
 | 
				
			||||||
 | 
					        //            }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            if (Status == 2)
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                Status = 3;
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            BtnEnable = true;
 | 
				
			||||||
 | 
					        //            _portUtil.Operate = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            //减库存,生成操作记录
 | 
				
			||||||
 | 
					        //            SaveDate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            break;
 | 
				
			||||||
 | 
					        //        // 打开失败
 | 
				
			||||||
 | 
					        //        case EventType.OPENERROR:
 | 
				
			||||||
 | 
					        //            AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                Message = msg.Message,
 | 
				
			||||||
 | 
					        //                Type = MsgType.ERROR
 | 
				
			||||||
 | 
					        //            };
 | 
				
			||||||
 | 
					        //            _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            BtnEnable = true;
 | 
				
			||||||
 | 
					        //            Status = 0;
 | 
				
			||||||
 | 
					        //            _portUtil.Operate = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            //记录药箱操作日志
 | 
				
			||||||
 | 
					        //            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                MachineId = "DM5",
 | 
				
			||||||
 | 
					        //                DrawerNo = _portUtil.DrawerNo,
 | 
				
			||||||
 | 
					        //                Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					        //                OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					        //                Type = 55,
 | 
				
			||||||
 | 
					        //                InvoiceId = "药箱打开失败",
 | 
				
			||||||
 | 
					        //            }).ExecuteCommand();
 | 
				
			||||||
 | 
					        //            _portUtil.Operate = false;
 | 
				
			||||||
 | 
					        //            break;
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        //减库存,生成操作记录
 | 
				
			||||||
 | 
					        private void SaveDate()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var confirmData = OrderDetailList.Where(od => od._OrderInfo.ItemIsChecked == true).ToList();
 | 
				
			||||||
 | 
					            if(confirmData.Count > 0 )
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var f = SqlSugarHelper.Db.UseTran(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    string empChannelStock=string.Empty;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    for (int i = 0; i < confirmData.Count; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        OrderDetail od = confirmData[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        //更新处方状态
 | 
				
			||||||
 | 
					                        if(od._OrderInfo.DmStatus==0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(new OrderInfo()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                DmStatus = 1,
 | 
				
			||||||
 | 
					                                OrderNo = od.OrderNo
 | 
				
			||||||
 | 
					                            }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Insertable(new OrderFinish()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                OrderNo = od.OrderNo,
 | 
				
			||||||
 | 
					                                PatientId = od._OrderInfo.PatientId,
 | 
				
			||||||
 | 
					                                Pharmacy = od._OrderInfo.Pharmacy,
 | 
				
			||||||
 | 
					                                State = 1,
 | 
				
			||||||
 | 
					                                Operator = HomeWindowViewModel.Operator?.Nickname,
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        Expression<Func<ChannelStock, bool>> updateExp = it => it.ManuNo == od.SetManuNo && it.EffDate == od.SetEffDate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        ChannelStock cs = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs =>cs.DrugId==od.DrugId && cs.ManuNo == od.SetManuNo && cs.EffDate == od.SetEffDate && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3")).First();
 | 
				
			||||||
 | 
					                        if(cs==null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            empChannelStock += $"{od.OrderNo},{od.DrugId},{od.SetManuNo},{od.SetEffDate}";
 | 
				
			||||||
 | 
					                            continue;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        cs.Quantity = cs.Quantity - od.Quantity;
 | 
				
			||||||
 | 
					                        // 更新数据 库存信息
 | 
				
			||||||
 | 
					                        SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (cs != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                                DrawerNo = cs.DrawerNo,
 | 
				
			||||||
 | 
					                                ColNo = cs.ColNo,
 | 
				
			||||||
 | 
					                                DrugId = cs.DrugId,
 | 
				
			||||||
 | 
					                                ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
 | 
				
			||||||
 | 
					                                Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                Reviewer = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                                Quantity = od.Quantity,
 | 
				
			||||||
 | 
					                                Type = 2,
 | 
				
			||||||
 | 
					                                InvoiceId = od.OrderNo
 | 
				
			||||||
 | 
					                                //, StockQuantity = nowChannels.Sum(it => it.Quantity)
 | 
				
			||||||
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        //保存账册
 | 
				
			||||||
 | 
					                        int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            DrugId = od.DrugId,
 | 
				
			||||||
 | 
					                            Type = 2,
 | 
				
			||||||
 | 
					                            Department = od._OrderInfo.DeptName,
 | 
				
			||||||
 | 
					                            OrderNo = od.OrderNo,
 | 
				
			||||||
 | 
					                            ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                            EffDate = cs.EffDate,
 | 
				
			||||||
 | 
					                            OutQuantity = od.Quantity,
 | 
				
			||||||
 | 
					                            UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                            UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                            MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                            CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                            CreateTime = DateTime.Now,
 | 
				
			||||||
 | 
					                            InvoiceNo = od.OrderNo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
 | 
					                        //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
 | 
					                        AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
				
			||||||
 | 
					                        .Where(ab => ab.Type == 3)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.DrugId == od.DrugId)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.ManuNo == cs.ManuNo)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                        if (accountBookG2Day != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - od.Quantity;
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //生成日结存时可能没有该库位的绑定信息,需要写入日结存
 | 
				
			||||||
 | 
					                            int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                DrugId = od.DrugId,
 | 
				
			||||||
 | 
					                                Type = 3,
 | 
				
			||||||
 | 
					                                ManuNo = cs.ManuNo,
 | 
				
			||||||
 | 
					                                EffDate = cs.EffDate,
 | 
				
			||||||
 | 
					                                YQuantity = 0,
 | 
				
			||||||
 | 
					                                ManuStock = od.Quantity,
 | 
				
			||||||
 | 
					                                TotalStock = od.Quantity,
 | 
				
			||||||
 | 
					                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                                InvoiceNo = "日结存"
 | 
				
			||||||
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            if (iDayResult <= 0)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                logger.Info($"未写入日结存数据{od.DrugId}-{cs.ManuNo}-{cs.EffDate}-{cs.Quantity}");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        //修改凌晨生成的日结存与总结存数据
 | 
				
			||||||
 | 
					                        AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
 | 
				
			||||||
 | 
					                        .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["machineId"].ToString()))
 | 
				
			||||||
 | 
					                        .Where(ab => ab.Type == 4)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.DrugId == od.DrugId)
 | 
				
			||||||
 | 
					                        .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
 | 
				
			||||||
 | 
					                        if (accountBookG2Total != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - od.Quantity;
 | 
				
			||||||
 | 
					                            SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            //生成总结存时可能没有该库位的绑定信息,需要写入总结存
 | 
				
			||||||
 | 
					                            int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                DrugId = od.DrugId,
 | 
				
			||||||
 | 
					                                Type = 4,
 | 
				
			||||||
 | 
					                                YQuantity = 0,
 | 
				
			||||||
 | 
					                                ManuStock = od.Quantity,
 | 
				
			||||||
 | 
					                                TotalStock = od.Quantity,
 | 
				
			||||||
 | 
					                                UserId1 = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                                UserId2 = HomeWindowViewModel.Reviewer?.Id,
 | 
				
			||||||
 | 
					                                MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
 | 
				
			||||||
 | 
					                                CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
 | 
				
			||||||
 | 
					                                InvoiceNo = "总结存"
 | 
				
			||||||
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            if (iTotalResult <= 0)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                logger.Info($"未写入总结存数据{od.DrugId}-{od.Quantity}");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    if(!string.IsNullOrEmpty(empChannelStock))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = $"所选处方对应药品批次效期无库存{empChannelStock}",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        logger.Info($"所选处方对应药品批次效期无库存{empChannelStock}");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                if (f.Data)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    RequestData();
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "所选处方已核对完成",
 | 
				
			||||||
 | 
					                        Type = MsgType.SUCCESS,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (!f.IsSuccess)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = "处方核对失败!",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                Status = 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Message = "请勾选要核对的处方数据",
 | 
				
			||||||
 | 
					                    Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -185,9 +185,9 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                OperationTime = DateTime.Now,
 | 
					                                OperationTime = DateTime.Now,
 | 
				
			||||||
                                Quantity =  it.CheckQuantity - it.Quantity,
 | 
					                                Quantity =  it.CheckQuantity - it.Quantity,
 | 
				
			||||||
                                Type = 4,
 | 
					                                Type = 4,
 | 
				
			||||||
                                InvoiceId = InvoiceId,
 | 
					                                InvoiceId = InvoiceId
 | 
				
			||||||
                                StockQuantity = nowChannels.Sum(it => it.Quantity),
 | 
					                                //,StockQuantity = nowChannels.Sum(it => it.Quantity),
 | 
				
			||||||
                                CheckQuantity = it.CheckQuantity
 | 
					                                //CheckQuantity = it.CheckQuantity
 | 
				
			||||||
                            }).ExecuteCommand();
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,89 @@
 | 
				
			||||||
 | 
					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 System;
 | 
				
			||||||
 | 
					using System.Collections;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class EmergencyWindowViewModel : BindableBase
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindowViewModel));
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IRegionManager _regionManager;
 | 
				
			||||||
 | 
					        SocketHelper _socketHelper;
 | 
				
			||||||
 | 
					        private bool _dbConnectionFail = !App.DbConnectionFail;
 | 
				
			||||||
 | 
					        public bool DBConnectionStatus { get=>_dbConnectionFail; set => SetProperty(ref _dbConnectionFail, value); }
 | 
				
			||||||
 | 
					        public EmergencyWindowViewModel(IRegionManager regionManager, PortUtil portUtil, IEventAggregator eventAggregator, SocketHelper socketHelper)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator; 
 | 
				
			||||||
 | 
					            _regionManager = regionManager; 
 | 
				
			||||||
 | 
					            _socketHelper = socketHelper;
 | 
				
			||||||
 | 
					            CheckDBConnect();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand<string> UpdateDrawerNo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand<string>((DrawerNo) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //应急开锁
 | 
				
			||||||
 | 
					                logger.Info($"应急开锁正在打开{DrawerNo}号药箱");
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    logger.Info($"发送开{DrawerNo}号药箱指令");
 | 
				
			||||||
 | 
					                    _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(Convert.ToInt32(DrawerNo) - 1) });
 | 
				
			||||||
 | 
					                    _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
 | 
					                    logger.Info($"发开{DrawerNo}号药箱指令完成");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = $"网口连接异常,开药箱正在重试{ex.Message}",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public DelegateCommand ReturnLoginDelegate
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => new DelegateCommand(() =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //间隔1分钟查询数据库连接状态
 | 
				
			||||||
 | 
					        private void CheckDBConnect()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            new PromiseUtil<int>().taskAsyncLoop(60000, 0, async (options, next, stop) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var userList = SqlSugarHelper.Db.Queryable<UserList>()
 | 
				
			||||||
 | 
					                                        .First(u => u.UserName == "admin");
 | 
				
			||||||
 | 
					                    App.DbConnectionFail = false;
 | 
				
			||||||
 | 
					                    DBConnectionStatus = true;
 | 
				
			||||||
 | 
					                    stop();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    next();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -23,6 +23,10 @@ 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;
 | 
				
			||||||
 | 
					using MaterialDesignThemes.Wpf;
 | 
				
			||||||
 | 
					using System.Windows.Media;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -34,6 +38,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,77 +71,182 @@ 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);
 | 
				
			||||||
 | 
					                //            }
 | 
				
			||||||
 | 
					                //        }
 | 
				
			||||||
 | 
					                //    }
 | 
				
			||||||
 | 
					                if (!_socketHelper.OpenStatus)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (value != null)
 | 
					                    SetProperty(ref _selectedChildMenu, value);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ModbusHelper.SpeakAsync("请先关药箱");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private void SelectChildNavigate(PremissionDm SelectedChildMenu)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //if (!_portUtil.Operate)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            if (SelectedChildMenu != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (SelectedChildMenu.PremissionPath.Equals("TakeRecordWindow"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //定义传参变量
 | 
				
			||||||
 | 
					                    NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //添加参数,键值对格式
 | 
				
			||||||
 | 
					                    keys.Add("Type", 2);
 | 
				
			||||||
 | 
					                    _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else if (SelectedChildMenu.PremissionPath.Equals("AddRecordWindow"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //定义传参变量
 | 
				
			||||||
 | 
					                    NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //添加参数,键值对格式
 | 
				
			||||||
 | 
					                    keys.Add("Type", 1);
 | 
				
			||||||
 | 
					                    _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else if (SelectedChildMenu.PremissionPath.Equals("ReturnRecordWindow"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //定义传参变量
 | 
				
			||||||
 | 
					                    NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //添加参数,键值对格式
 | 
				
			||||||
 | 
					                    keys.Add("Type", 3);
 | 
				
			||||||
 | 
					                    _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else if (SelectedChildMenu.PremissionPath.Equals("RetrunEmptyRecordWindow"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //定义传参变量
 | 
				
			||||||
 | 
					                    NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //添加参数,键值对格式
 | 
				
			||||||
 | 
					                    keys.Add("Type", 3);
 | 
				
			||||||
 | 
					                    _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath, keys);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else if (SelectedChildMenu.PremissionPath.Equals("CheckRecordWindow"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //定义传参变量
 | 
				
			||||||
 | 
					                    NavigationParameters keys = new NavigationParameters();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //添加参数,键值对格式
 | 
				
			||||||
 | 
					                    keys.Add("Type", 4);
 | 
				
			||||||
 | 
					                    _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow") || SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow2"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if (value.PremissionPath.Equals("TakeRecordWindow"))
 | 
					                        if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            //定义传参变量
 | 
					                            _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
 | 
				
			||||||
                            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
 | 
					                        else
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2"))
 | 
					                            _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                                else
 | 
					 | 
				
			||||||
                                {
 | 
					 | 
				
			||||||
                                    _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
                                _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    SetProperty(ref _selectedChildMenu, value);
 | 
					                    //else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow"))
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
 | 
				
			||||||
 | 
					                    //    {
 | 
				
			||||||
 | 
					                    //        _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
 | 
				
			||||||
 | 
					                    //    }
 | 
				
			||||||
 | 
					                    //    else
 | 
				
			||||||
 | 
					                    //    {
 | 
				
			||||||
 | 
					                    //        _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
 | 
				
			||||||
 | 
					                    //    }
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					                    //else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
 | 
				
			||||||
 | 
					                        }));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public PremissionDm? SelectedMenu
 | 
					        public PremissionDm? SelectedMenu
 | 
				
			||||||
| 
						 | 
					@ -143,22 +268,59 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                //        SelectedChildMenu = value.Children[0];
 | 
					                //        SelectedChildMenu = value.Children[0];
 | 
				
			||||||
                //    }
 | 
					                //    }
 | 
				
			||||||
                //}
 | 
					                //}
 | 
				
			||||||
                SetProperty(ref _selectedMenu, value);
 | 
					                if (!_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					                    SetProperty(ref _selectedMenu, value);
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ModbusHelper.SpeakAsync("请先关药箱");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        //PremissionDm? PreSelectedMenu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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 != null && SelectedMenu.PremissionName != "退出")
 | 
				
			||||||
            if (SelectedMenu.PremissionName == "退出")
 | 
					            //{
 | 
				
			||||||
            {
 | 
					            //    PreSelectedMenu = SelectedMenu;
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //if (_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    if (PreSelectedMenu != null)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        SelectedMenu = PreSelectedMenu;
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					            //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是开着
 | 
				
			||||||
                logger.Info($"用户【{Operator?.Nickname}】退出登录");
 | 
					                logger.Info($"用户【{Operator?.Nickname}】退出登录");
 | 
				
			||||||
                Operator = null;
 | 
					                Operator = null;
 | 
				
			||||||
                Reviewer = null;
 | 
					                Reviewer = null;
 | 
				
			||||||
| 
						 | 
					@ -167,10 +329,24 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //SelectedMenu.Children = SelectedMenu.Children;
 | 
					                //SelectedMenu.Children = SelectedMenu.Children;
 | 
				
			||||||
                SelectedChildMenu = SelectedMenu.Children[0];
 | 
					                //SelectedChildMenu = SelectedMenu.Children[0];
 | 
				
			||||||
 | 
					                if (!_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _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 +362,57 @@ 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)
 | 
					        //private ModbusHelper _modbusHelper;
 | 
				
			||||||
 | 
					        SocketHelper _socketHelper;
 | 
				
			||||||
 | 
					        //System.Timers.Timer timer;
 | 
				
			||||||
 | 
					        //DispatcherTimer timerNew;
 | 
				
			||||||
 | 
					        public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IUnityContainer container, IDialogService dialogService, IEventAggregator eventAggregator, SocketHelper socketHelper)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _portUtil = portUtil;
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
            _regionManager = iRegionManager;
 | 
					            _regionManager = iRegionManager;
 | 
				
			||||||
            _dialogService = dialogService;
 | 
					            _dialogService = dialogService;
 | 
				
			||||||
            _container = container;
 | 
					            _container = container;
 | 
				
			||||||
            this._eventAggregator = eventAggregator;
 | 
					            this._eventAggregator = eventAggregator;
 | 
				
			||||||
            _chkFunction= cHKFunction;
 | 
					            _socketHelper = socketHelper;
 | 
				
			||||||
 | 
					            _socketHelper.dateTime=DateTime.Now;
 | 
				
			||||||
 | 
					            //timerNew = new DispatcherTimer();
 | 
				
			||||||
 | 
					            //int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
				
			||||||
 | 
					            //if (autoExit > 0)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    timerNew.Interval =new TimeSpan(0, 0, 0, 1, 0); //autoExit * 1000;
 | 
				
			||||||
 | 
					            //    timerNew.Tick += (sender, e) =>
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        if (!_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            // 无人操作鼠标键盘
 | 
				
			||||||
 | 
					            //            if ((DateTime.Now - _socketHelper.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
 | 
				
			||||||
 | 
					            //            {
 | 
				
			||||||
 | 
					            //                logger.Info($"设备内无人操作,用户【{Operator?.Nickname}】自动退出登录");
 | 
				
			||||||
 | 
					            //                Operator = null;
 | 
				
			||||||
 | 
					            //                Reviewer = null;
 | 
				
			||||||
 | 
					            //                //Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
 | 
					            //                //{
 | 
				
			||||||
 | 
					            //                //System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
 | 
					            //                //{
 | 
				
			||||||
 | 
					            //                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					            //                //}));
 | 
				
			||||||
 | 
					            //                //});
 | 
				
			||||||
 | 
					            //                timerNew.Stop();
 | 
				
			||||||
 | 
					            //                //timer.Dispose();
 | 
				
			||||||
 | 
					            //            }
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //        else
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //    };
 | 
				
			||||||
 | 
					            //    timerNew.Start();
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					           
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DelegateCommand<string> OpenFingerDialog
 | 
					        public DelegateCommand<string> OpenFingerDialog
 | 
				
			||||||
| 
						 | 
					@ -208,24 +425,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
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -247,22 +464,119 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void FindDrawerCount()
 | 
					        //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();
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //    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)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            int count = 0;
 | 
					            try
 | 
				
			||||||
            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();
 | 
					                //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;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
 | 
					                logger.Info("GetResultWD异常", new Exception($"{ex.ToString()}"));
 | 
				
			||||||
                .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            Is16Drawer = count == 16;
 | 
					            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,7 +586,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        //接收导航传过来的参数
 | 
					        //接收导航传过来的参数
 | 
				
			||||||
        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
	    _portUtil.dateTime = DateTime.Now;
 | 
					            //_eventAggregator.GetEvent<LoginOutEvent>().Subscribe(SetLoginOut);
 | 
				
			||||||
 | 
					            //_portUtil.dateTime = DateTime.Now;
 | 
				
			||||||
            //取出user
 | 
					            //取出user
 | 
				
			||||||
            UserList = navigationContext.Parameters.GetValue<UserList>("operator");
 | 
					            UserList = navigationContext.Parameters.GetValue<UserList>("operator");
 | 
				
			||||||
            Operator = UserList;
 | 
					            Operator = UserList;
 | 
				
			||||||
| 
						 | 
					@ -289,16 +604,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 +622,93 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            PremissionDmList = premissions;
 | 
					            PremissionDmList = premissions;
 | 
				
			||||||
            SelectedMenu = premissions[0];
 | 
					            SelectedMenu = premissions[0];
 | 
				
			||||||
            SelectedChildMenu = premissions[0].Children[0];
 | 
					            SelectedChildMenu = premissions[0].Children[0];
 | 
				
			||||||
            FindDrawerCount();
 | 
					            _regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
 | 
				
			||||||
 | 
					            //FindDrawerCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #region 温度查询定时
 | 
				
			||||||
 | 
					            //int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
 | 
				
			||||||
 | 
					            //if (interval > 0)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    WSDTimer = new System.Timers.Timer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //    WSDTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetWSD);
 | 
				
			||||||
 | 
					            //    WSDTimer.Interval = interval;
 | 
				
			||||||
 | 
					            //    WSDTimer.Start();
 | 
				
			||||||
 | 
					            //    //WDTimer.AutoReset = true;
 | 
				
			||||||
 | 
					            //    //WDTimer.Enabled = true;
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					            //if (stopRecord > 0)
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    System.Timers.Timer timer = new System.Timers.Timer();
 | 
				
			||||||
 | 
					            //    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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
					            int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
				
			||||||
            if (autoExit > 0)
 | 
					            if (autoExit > 0)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Timer timer = new Timer();
 | 
					                //int interval = autoExit * 1000;
 | 
				
			||||||
                timer.Interval = 1000;
 | 
					                new PromiseUtil<int>().taskAsyncLoop(1000, 0, async (options, next, stop) =>
 | 
				
			||||||
                timer.Elapsed += (sender, e) =>
 | 
					 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    // 串口无人操作
 | 
					                    try
 | 
				
			||||||
                    if (!_portUtil.Operate)
 | 
					 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        // 30秒内无人操作鼠标键盘
 | 
					                        if (!_socketHelper.OpenStatus)
 | 
				
			||||||
                        if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
 | 
					 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
 | 
					                            // 无人操作鼠标键盘
 | 
				
			||||||
                            _chkFunction.HIKStopDVRRecord();
 | 
					                            if ((DateTime.Now - _socketHelper.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
 | 
				
			||||||
                            Operator = null;
 | 
					 | 
				
			||||||
                            Reviewer = null;
 | 
					 | 
				
			||||||
                            Application.Current.Dispatcher.Invoke(() =>
 | 
					 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                                logger.Info($"设备内无人操作,用户【{Operator?.Nickname}】自动退出登录.autoExit:{autoExit};socketTime:{_socketHelper.dateTime};totalSeconds:{(DateTime.Now - _socketHelper.dateTime).TotalSeconds}{_socketHelper.dateTime};LastInputTime:{CheckComputerFreeState.GetLastInputTime()}");
 | 
				
			||||||
                                timer.Stop();
 | 
					                                Operator = null;
 | 
				
			||||||
                            });
 | 
					                                Reviewer = null;
 | 
				
			||||||
 | 
					                                //Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
 | 
					                                //{
 | 
				
			||||||
 | 
					                                stop();
 | 
				
			||||||
 | 
					                                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					                                }));
 | 
				
			||||||
 | 
					                                //});
 | 
				
			||||||
 | 
					                                //timer.Dispose();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                if (Operator == null)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    stop();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                else
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    next();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
 | 
					                            next();
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                };
 | 
					                    catch (Exception ex)
 | 
				
			||||||
                timer.Start();
 | 
					                    {
 | 
				
			||||||
 | 
					                        logger.Info($"自动退出异常:{ex.Message}");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            _chkFunction.HIKStartDVRRecord();
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
					        //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
 | 
				
			||||||
| 
						 | 
					@ -347,7 +720,38 @@ 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;
 | 
				
			||||||
 | 
					        //    try
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        //if (_socketHelper.IsMultiThread)
 | 
				
			||||||
 | 
					        //        //{
 | 
				
			||||||
 | 
					        //        //    Application.Current.Dispatcher.BeginInvoke(() =>
 | 
				
			||||||
 | 
					        //        //    {
 | 
				
			||||||
 | 
					        //        //        _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					        //        //    });
 | 
				
			||||||
 | 
					        //        //}
 | 
				
			||||||
 | 
					        //        //else
 | 
				
			||||||
 | 
					        //        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //            Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					        //            });
 | 
				
			||||||
 | 
					        //        }
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //    catch (Exception ex)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        logger.Info($"自动退出异常:{ex.Message}");
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -40,6 +40,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        IRegionManager _regionManager;
 | 
					        IRegionManager _regionManager;
 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        SocketHelper _socketHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
 | 
					        private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
 | 
				
			||||||
        private string firstLogin = ConfigurationManager.AppSettings["firstLogin"]?.ToString() ?? "operator";
 | 
					        private string firstLogin = ConfigurationManager.AppSettings["firstLogin"]?.ToString() ?? "operator";
 | 
				
			||||||
| 
						 | 
					@ -54,10 +55,17 @@ 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;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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,29 +75,48 @@ 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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool FingerMsg
 | 
					        public bool FingerMsg
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get => _fingerMsg;
 | 
					            get => _fingerMsg;
 | 
				
			||||||
            set => SetProperty(ref _fingerMsg, value);
 | 
					            set => SetProperty(ref _fingerMsg, value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        //录像机登录状态
 | 
					        /// <summary>
 | 
				
			||||||
        private bool _hikMsg;
 | 
					        /// 网口连接标识
 | 
				
			||||||
        public bool HIKMsg
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        private bool _netMsg = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool NetMsg
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get=>_hikMsg;
 | 
					            get => _netMsg;
 | 
				
			||||||
            set=>SetProperty(ref _hikMsg, value);
 | 
					            set => SetProperty(ref _netMsg, value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        //public bool FridgePortMsg
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get => !_portUtil.fridgeSerial.IsOpen;
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        //温湿度
 | 
				
			||||||
 | 
					        public bool WSDPortMsg
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => !_portUtil.wsdSerial.IsOpen;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //录像机登录状态
 | 
				
			||||||
 | 
					        //private bool _hikMsg;
 | 
				
			||||||
 | 
					        //public bool HIKMsg
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    get=>_hikMsg;
 | 
				
			||||||
 | 
					        //    set=>SetProperty(ref _hikMsg, value);
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
 | 
					        //public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
 | 
				
			||||||
        //{
 | 
					        //{
 | 
				
			||||||
| 
						 | 
					@ -98,13 +125,16 @@ 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, SocketHelper socketHelper)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //_fingerprintUtil = fingerprintUtil;
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
            _portUtil = portUtil;
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
            _chkFunction= chcFunction;
 | 
					 | 
				
			||||||
            _regionManager = regionManager;
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					            _socketHelper = socketHelper;
 | 
				
			||||||
 | 
					            FingerMsg = !_fingerprintUtil.bIsConnected;
 | 
				
			||||||
 | 
					            NetMsg = !_socketHelper.ConnectedStatus;
 | 
				
			||||||
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private DelegateCommand? _loginCommand;
 | 
					        private DelegateCommand? _loginCommand;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -155,7 +185,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 +210,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,7 +272,7 @@ _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.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
					                    _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
                }));
 | 
					                }));
 | 
				
			||||||
| 
						 | 
					@ -235,7 +288,7 @@ _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.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
					                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
                        }));
 | 
					                        }));
 | 
				
			||||||
| 
						 | 
					@ -259,7 +312,7 @@ _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.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
					                            _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
 | 
				
			||||||
                        }));
 | 
					                        }));
 | 
				
			||||||
| 
						 | 
					@ -278,6 +331,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,14 +373,15 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void Exit()
 | 
					        void Exit()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _chkFunction.HIKLoginOut();
 | 
					            //_chkFunction.HIKLoginOut();
 | 
				
			||||||
 | 
					            _socketHelper.SocketDisConnect();
 | 
				
			||||||
            Process.GetCurrentProcess().Kill();
 | 
					            Process.GetCurrentProcess().Kill();
 | 
				
			||||||
            Environment.Exit(0);
 | 
					            Environment.Exit(0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void LoginEvent(FingerprintMsg msg)
 | 
					        void LoginEvent(FingerprintMsg msg)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            logger.Info(msg.ToString());
 | 
					            logger.Info(msg.ToString()+ "LoginBtnEnable:"+ LoginBtnEnable);
 | 
				
			||||||
            if (msg.Message.Equals("CONNECT"))
 | 
					            if (msg.Message.Equals("CONNECT"))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                FingerMsg = !msg.Result;
 | 
					                FingerMsg = !msg.Result;
 | 
				
			||||||
| 
						 | 
					@ -343,6 +419,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 +460,11 @@ _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);
 | 
				
			||||||
 | 
					            //logger.Info($"LoginWindowViewModel;FingerMsg:{_fingerprintUtil.bIsConnected}");
 | 
				
			||||||
 | 
					            //_fingerprintUtil.FingerDisconnect();
 | 
				
			||||||
 | 
					            //FingerMsg = !_fingerprintUtil.bIsConnected;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,27 +1,21 @@
 | 
				
			||||||
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
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -71,8 +65,9 @@ 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);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -80,12 +75,13 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23,59,59);
 | 
					        private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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);
 | 
				
			||||||
| 
						 | 
					@ -95,22 +91,10 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    SetProperty(ref _endDate, value);
 | 
					                    SetProperty(ref _endDate, value);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                
 | 
					
 | 
				
			||||||
                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,10 @@ 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;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -30,7 +34,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //private PortUtil _portUtil;
 | 
					        //private PortUtil _portUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private ScreenUtil _screenUtil;
 | 
					        //private ScreenUtil _screenUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public SolidColorBrush Background
 | 
					        public SolidColorBrush Background
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -63,24 +67,89 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        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(MainWindowViewModel));
 | 
				
			||||||
 | 
					        SocketHelper _socketHelper;
 | 
				
			||||||
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, SocketHelper socketHelper, PortUtil portUtil)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //_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(() =>
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            if (App.DbConnectionFail)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //_container.RegisterType<object, EmergencyWindow>("EmergencyWindow");
 | 
				
			||||||
 | 
					                _regionManager.RequestNavigate("MainRegion", "EmergencyWindow");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                _container.RegisterType<object, LoginWindow>("LoginWindow");
 | 
					                _container.RegisterType<object, LoginWindow>("LoginWindow");
 | 
				
			||||||
                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                _regionManager.RegisterViewWithRegion("MainRegion", "LoginWindow");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            _socketHelper = socketHelper;
 | 
				
			||||||
 | 
					            new PromiseUtil<int>().taskAsyncLoop(1200000, 0, async (options, next, stop) =>
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _socketHelper.IsMultiThread = true;
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    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}");
 | 
				
			||||||
 | 
					                        Task.Delay(1200000);//20分钟查一次
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        logger.Info("温湿度信息返回空");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    next();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    logger.Info($"保存温湿度异常:{ex.Message}");
 | 
				
			||||||
 | 
					                    next();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            //Task.Factory.StartNew(() =>
 | 
				
			||||||
 | 
					            //{
 | 
				
			||||||
 | 
					            //    while (true)
 | 
				
			||||||
 | 
					            //    {
 | 
				
			||||||
 | 
					            //        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}");
 | 
				
			||||||
 | 
					            //            Task.Delay(1200000);//20分钟查一次
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //        else
 | 
				
			||||||
 | 
					            //        {
 | 
				
			||||||
 | 
					            //            logger.Info("温湿度信息返回空");
 | 
				
			||||||
 | 
					            //        }
 | 
				
			||||||
 | 
					            //    }
 | 
				
			||||||
 | 
					            //});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }));
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void doMyPrismEvent2(AlertMsg msg)
 | 
					        void doMyPrismEvent2(AlertMsg msg)
 | 
				
			||||||
| 
						 | 
					@ -97,7 +166,19 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
					                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            SnackbarMessageQueue.Enqueue(msg.Message);
 | 
					            if (_socketHelper.IsMultiThread)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Application.Current.Dispatcher.Invoke(new Action(() => {
 | 
				
			||||||
 | 
					                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
 | 
					                    SnackbarMessageQueue.Enqueue(msg.Message);
 | 
				
			||||||
 | 
					                }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SnackbarMessageQueue.Enqueue(msg.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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,830 @@
 | 
				
			||||||
 | 
					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.Drawing.Printing;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Security.Cryptography;
 | 
				
			||||||
 | 
					using System.Security.Cryptography.Pkcs;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.Timers;
 | 
				
			||||||
 | 
					using System.Windows.Media;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class OpenBoxNewWindowViewModel : BindableBase, IRegionMemberLifetime, INavigationAware
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        //定时查询药箱状态
 | 
				
			||||||
 | 
					        //System.Timers.Timer StateTimer = new System.Timers.Timer(5000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        #region 按钮归属变量
 | 
				
			||||||
 | 
					        private string _btn1User;
 | 
				
			||||||
 | 
					        public string Btn1User { get => _btn1User; set => SetProperty(ref _btn1User, value); }
 | 
				
			||||||
 | 
					        private string _btn2User;
 | 
				
			||||||
 | 
					        public string Btn2User { get => _btn2User; set => SetProperty(ref _btn2User, value); }
 | 
				
			||||||
 | 
					        private string _btn3User;
 | 
				
			||||||
 | 
					        public string Btn3User { get => _btn3User; set => SetProperty(ref _btn3User, value); }
 | 
				
			||||||
 | 
					        private string _btn4User;
 | 
				
			||||||
 | 
					        public string Btn4User { get => _btn4User; set => SetProperty(ref _btn4User, value); }
 | 
				
			||||||
 | 
					        private string _btn5User;
 | 
				
			||||||
 | 
					        public string Btn5User { get => _btn5User; set => SetProperty(ref _btn5User, value); }
 | 
				
			||||||
 | 
					        private string _btn6User;
 | 
				
			||||||
 | 
					        public string Btn6User { get => _btn6User; set => SetProperty(ref _btn6User, value); }
 | 
				
			||||||
 | 
					        private string _btn7User;
 | 
				
			||||||
 | 
					        public string Btn7User { get => _btn7User; set => SetProperty(ref _btn7User, value); }
 | 
				
			||||||
 | 
					        private string _btn8User;
 | 
				
			||||||
 | 
					        public string Btn8User { get => _btn8User; set => SetProperty(ref _btn8User, value); }
 | 
				
			||||||
 | 
					        private string _btn9User;
 | 
				
			||||||
 | 
					        public string Btn9User { get => _btn9User; set => SetProperty(ref _btn9User, value); }
 | 
				
			||||||
 | 
					        private string _btn10User;
 | 
				
			||||||
 | 
					        public string Btn10User { get => _btn10User; set => SetProperty(ref _btn10User, value); }
 | 
				
			||||||
 | 
					        private string _btn11User;
 | 
				
			||||||
 | 
					        public string Btn11User { get => _btn11User; set => SetProperty(ref _btn11User, value); }
 | 
				
			||||||
 | 
					        private string _btn12User;
 | 
				
			||||||
 | 
					        public string Btn12User { get => _btn12User; set => SetProperty(ref _btn12User, value); }
 | 
				
			||||||
 | 
					        private string _btn13User;
 | 
				
			||||||
 | 
					        public string Btn13User { get => _btn13User; set => SetProperty(ref _btn13User, value); }
 | 
				
			||||||
 | 
					        private string _btn14User;
 | 
				
			||||||
 | 
					        public string Btn14User { get => _btn14User; set => SetProperty(ref _btn14User, value); }
 | 
				
			||||||
 | 
					        private string _btn15User;
 | 
				
			||||||
 | 
					        public string Btn15User { get => _btn15User; set => SetProperty(ref _btn15User, value); }
 | 
				
			||||||
 | 
					        private string _btn16User;
 | 
				
			||||||
 | 
					        public string Btn16User { get => _btn16User; set => SetProperty(ref _btn16User, value); }
 | 
				
			||||||
 | 
					        private string _btn17User;
 | 
				
			||||||
 | 
					        public string Btn17User { get => _btn17User; set => SetProperty(ref _btn17User, value); }
 | 
				
			||||||
 | 
					        private string _btn18User;
 | 
				
			||||||
 | 
					        public string Btn18User { get => _btn18User; set => SetProperty(ref _btn18User, value); }
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					        //抽屉号列表
 | 
				
			||||||
 | 
					        public static ChannelList iList = new ChannelList();
 | 
				
			||||||
 | 
					        //第几个抽屉号
 | 
				
			||||||
 | 
					        //public static int iNumber = 1;
 | 
				
			||||||
 | 
					        //private PortUtil _portUtil;
 | 
				
			||||||
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
 | 
					        SocketHelper _socketHelper;
 | 
				
			||||||
 | 
					        public OpenBoxNewWindowViewModel(IEventAggregator eventAggregator, SocketHelper socketHelper)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					            _socketHelper = socketHelper;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #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;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #region 设置按钮归属
 | 
				
			||||||
 | 
					        private void SetBtnUser(int drawerNo, string name)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //查询药箱归属并将名字显示出来
 | 
				
			||||||
 | 
					            switch (drawerNo)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case 1:
 | 
				
			||||||
 | 
					                    Btn1User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 2:
 | 
				
			||||||
 | 
					                    Btn2User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 3:
 | 
				
			||||||
 | 
					                    Btn3User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 4:
 | 
				
			||||||
 | 
					                    Btn4User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 5:
 | 
				
			||||||
 | 
					                    Btn5User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 6:
 | 
				
			||||||
 | 
					                    Btn6User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 7:
 | 
				
			||||||
 | 
					                    Btn7User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 8:
 | 
				
			||||||
 | 
					                    Btn8User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 9:
 | 
				
			||||||
 | 
					                    Btn9User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 10:
 | 
				
			||||||
 | 
					                    Btn10User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 11:
 | 
				
			||||||
 | 
					                    Btn11User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 12:
 | 
				
			||||||
 | 
					                    Btn12User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 13:
 | 
				
			||||||
 | 
					                    Btn13User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 14:
 | 
				
			||||||
 | 
					                    Btn14User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 15:
 | 
				
			||||||
 | 
					                    Btn15User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 16:
 | 
				
			||||||
 | 
					                    Btn16User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 17:
 | 
				
			||||||
 | 
					                    Btn17User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case 18:
 | 
				
			||||||
 | 
					                    Btn18User = name;
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        #endregion
 | 
				
			||||||
 | 
					        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 (chl != null && chl.EffDate != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SetBtnColor(chl.DrawerNo);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    //DrawerType== 1为公共药箱
 | 
				
			||||||
 | 
					                    if (chl.DrawerType == 1)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        SetBtnEnable(chl.DrawerNo);
 | 
				
			||||||
 | 
					                        SetBtnUser(chl.DrawerNo, "公共药箱");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (chl != null && chl.BelongUser != null)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            string userName = SqlSugarHelper.Db.Queryable<UserList>().Where(ul => ul.UserBarcode == chl.BelongUser).First().Nickname;
 | 
				
			||||||
 | 
					                            SetBtnUser(chl.DrawerNo, userName);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            SetBtnUser(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 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()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //bool[] bools = ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					            //bool allFalse = Array.TrueForAll(bools, b => b == false);
 | 
				
			||||||
 | 
					            //if (!allFalse)
 | 
				
			||||||
 | 
					            if (_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
 | 
				
			||||||
 | 
					                _socketHelper.speechSynthesizer.Resume();
 | 
				
			||||||
 | 
					                _socketHelper.SpeakAsync("请关闭药箱后再打开");
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            iList = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType && cl.DrawerNo == DrawerNo)
 | 
				
			||||||
 | 
					                .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).First();
 | 
				
			||||||
 | 
					            // .Select(cl => cl.DrawerNo).ToList();
 | 
				
			||||||
 | 
					            if (iList != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                //_portUtil.SpeakAsync("正在打开药箱");
 | 
				
			||||||
 | 
					                //_portUtil.DrawerNo = iList[iNumber];
 | 
				
			||||||
 | 
					                //iNumber++;
 | 
				
			||||||
 | 
					                //_portUtil.OpenBox();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //for (int i = 0; i < iList.Count; i++)
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                ChannelList channelList = iList;
 | 
				
			||||||
 | 
					                //记录开药箱日志
 | 
				
			||||||
 | 
					                SqlSugarHelper.Db.Insertable(new MachineRecord()
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    MachineId = "DM5",
 | 
				
			||||||
 | 
					                    DrawerNo = channelList.DrawerNo,
 | 
				
			||||||
 | 
					                    Operator = HomeWindowViewModel.Operator?.Id,
 | 
				
			||||||
 | 
					                    OperationTime = DateTime.Now,
 | 
				
			||||||
 | 
					                    Type = 55,
 | 
				
			||||||
 | 
					                    InvoiceId = $"打开{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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //ModbusHelper.SpeakAsync($"正在打开{DrawerNo}号药箱");
 | 
				
			||||||
 | 
					                _socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
 | 
				
			||||||
 | 
					                _socketHelper.speechSynthesizer.Resume();
 | 
				
			||||||
 | 
					                _socketHelper.SpeakAsync($"正在打开{DrawerNo}号药箱");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    logger.Info($"发送开{DrawerNo}号药箱指令");
 | 
				
			||||||
 | 
					                    _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo - 1) });
 | 
				
			||||||
 | 
					                    _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
 | 
					                    logger.Info($"发开{DrawerNo}号药箱指令完成");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception ex)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = $"网口连接异常,开药箱正在重试{ex.Message}",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                _socketHelper.OpenStatus = true;
 | 
				
			||||||
 | 
					                //_socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo - 1) });
 | 
				
			||||||
 | 
					                //_socketHelper.OpenStatus = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //int i = 10;
 | 
				
			||||||
 | 
					                //new PromiseUtil<int>().taskAsyncLoop(500, 0, async (options, next, stop) =>
 | 
				
			||||||
 | 
					                //{
 | 
				
			||||||
 | 
					                //    i--;
 | 
				
			||||||
 | 
					                //    if (_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					                //    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //        //bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					                //        _socketHelper.SendMessage(new MyBaseMessage() { lockNo = 0x33, functionCode = 4, delay = 2 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //        //ModbusHelper.SpeakAsync($"i为{i};状态为:{_socketHelper.OpenStatus}");
 | 
				
			||||||
 | 
					                //        //bool state = Array.TrueForAll(boolsl, b => b == false);
 | 
				
			||||||
 | 
					                //        if (_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					                //        {
 | 
				
			||||||
 | 
					                //            if (i == 0)
 | 
				
			||||||
 | 
					                //            {
 | 
				
			||||||
 | 
					                //                ModbusHelper.SpeakAsync("请及时关闭药箱");
 | 
				
			||||||
 | 
					                //                i = 10;
 | 
				
			||||||
 | 
					                //            }
 | 
				
			||||||
 | 
					                //            next();
 | 
				
			||||||
 | 
					                //        }
 | 
				
			||||||
 | 
					                //        else
 | 
				
			||||||
 | 
					                //        {
 | 
				
			||||||
 | 
					                //            stop();
 | 
				
			||||||
 | 
					                //        }
 | 
				
			||||||
 | 
					                //    }
 | 
				
			||||||
 | 
					                //    else
 | 
				
			||||||
 | 
					                //    {
 | 
				
			||||||
 | 
					                //        stop();
 | 
				
			||||||
 | 
					                //    }
 | 
				
			||||||
 | 
					                //});
 | 
				
			||||||
 | 
					                Thread.Sleep(100);
 | 
				
			||||||
 | 
					                int i = 80;
 | 
				
			||||||
 | 
					                int iException = 0;
 | 
				
			||||||
 | 
					                new PromiseUtil<int>().taskAsyncLoop(100, 0, async (options, next, stop) =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _socketHelper.IsMultiThread = true;
 | 
				
			||||||
 | 
					                    try
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        i--;
 | 
				
			||||||
 | 
					                        if (_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            //bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					                            _socketHelper.SendMessage(new MyBaseMessage() { lockNo = 0x33, functionCode = 4, delay = 2 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            //ModbusHelper.SpeakAsync($"i为{i};状态为:{_socketHelper.OpenStatus}");
 | 
				
			||||||
 | 
					                            //bool state = Array.TrueForAll(boolsl, b => b == false);
 | 
				
			||||||
 | 
					                            if (_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                if (i == 0)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    _socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
 | 
				
			||||||
 | 
					                                    _socketHelper.speechSynthesizer.Resume();
 | 
				
			||||||
 | 
					                                    _socketHelper.SpeakAsync("请及时关闭药箱");
 | 
				
			||||||
 | 
					                                    i = 80;
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                next();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            else
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                _socketHelper.IsMultiThread = false;
 | 
				
			||||||
 | 
					                                _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
 | 
					                                //_socketHelper.OpenStatus = false;
 | 
				
			||||||
 | 
					                                stop();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _socketHelper.IsMultiThread = false;
 | 
				
			||||||
 | 
					                            _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
 | 
					                            //_socketHelper.OpenStatus = false;
 | 
				
			||||||
 | 
					                            stop();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        iException = 0;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    catch (Exception ex)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        iException++;
 | 
				
			||||||
 | 
					                        if (iException >= 3)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            _socketHelper.OpenStatus = false;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Message = $"网口连接异常,查状态正在重试{ex.Message}",
 | 
				
			||||||
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        logger.Info($"网口连接异常,查状态正在重试{ex.Message}");
 | 
				
			||||||
 | 
					                        next();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                //StateTimer.Start();
 | 
				
			||||||
 | 
					                SelfStatus = 0;
 | 
				
			||||||
 | 
					                //PublicEnable = true;
 | 
				
			||||||
 | 
					                //SelfEnable = true;
 | 
				
			||||||
 | 
					                //DrawerType = -1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //private void OnTimerElapsed(object sender, ElapsedEventArgs e)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					        //    bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
 | 
				
			||||||
 | 
					        //    logger.Info($"进入定时查询状态方法{allTrue}");
 | 
				
			||||||
 | 
					        //    if (allTrue)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        //药箱全部关闭,停止查询
 | 
				
			||||||
 | 
					        //        StateTimer.Stop();
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //    else
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        _portUtil.SpeakAsync("药箱已打开,请及时关闭");
 | 
				
			||||||
 | 
					        //        //Console.Beep(800, 1100);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        //void DoMyPrismEvent(DeviceMsg msg)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    switch (msg.EventType)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        case EventType.DRAWERCLOSE:
 | 
				
			||||||
 | 
					        //            SelfEnable = false;
 | 
				
			||||||
 | 
					        //            break;
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        public void OnNavigatedTo(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // _eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					            RequestData();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool IsNavigationTarget(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void OnNavigatedFrom(NavigationContext navigationContext)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue