From 3df79378b772b7463a4678ed0321e2e480b75d11 Mon Sep 17 00:00:00 2001
From: maqiao <625215135@qq.com>
Date: Sun, 4 Feb 2024 13:35:45 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=8D=E5=88=B7=E6=96=B0?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E3=80=81=E6=96=B0=E5=A2=9E=E5=A4=9A=E6=89=B9?=
=?UTF-8?q?=E6=AC=A1=E5=85=A5=E5=BA=93=E3=80=81=E4=BF=AE=E6=94=B9=E8=B0=83?=
=?UTF-8?q?=E6=8B=A8=E5=85=A5=E5=BA=93=E3=80=81=E6=B7=BB=E5=8A=A0=E8=B4=A6?=
=?UTF-8?q?=E5=86=8C=E9=A1=B5=E9=9D=A2=E3=80=81=E4=BF=AE=E6=94=B9=E7=9B=98?=
=?UTF-8?q?=E7=82=B9=E9=A1=B5=E9=9D=A2=E3=80=81=E6=B7=BB=E5=8A=A0=E7=9B=98?=
=?UTF-8?q?=E7=82=B9=E8=AE=B0=E5=BD=95=E9=A1=B5=E7=AD=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DM_Weight/App.config | 20 +-
DM_Weight/App.xaml | 2 +-
DM_Weight/App.xaml.cs | 67 +-
DM_Weight/Converter/GroupSumConverter.cs | 10 +-
DM_Weight/Converter/TotalCountConverter.cs | 33 +
DM_Weight/DM_Weight.csproj | 13 +
DM_Weight/Finger/FingerprintUtil.cs | 34 +-
DM_Weight/Models/AccountModel.cs | 87 ++
DM_Weight/Models/AccountType.cs | 23 +
DM_Weight/Models/ChannelList.cs | 184 +++++
DM_Weight/Models/ChannelStock.cs | 7 +
DM_Weight/Models/ChannelStockCount.cs | 25 +
DM_Weight/Models/CheckRecordStock.cs | 94 +++
DM_Weight/Models/Class1.cs | 77 ++
DM_Weight/Models/InOutInvoice.cs | 6 +
DM_Weight/Models/MachineRecord.cs | 10 +
DM_Weight/Port/PortUtil.cs | 136 +++-
DM_Weight/Report/GridReportUtil.cs | 74 +-
DM_Weight/ReportTemp/account_book_temp.grf | 23 +-
DM_Weight/ReportTemp/machine_log_add.grf | 1 -
DM_Weight/ReportTemp/machine_log_check.grf | 25 +-
.../ReportTemp/machine_log_check_new.grf | 313 ++++++++
.../ReportTemp/machine_log_check_new2.grf | 278 +++++++
DM_Weight/ReportTemp/machine_log_return.grf | 1 -
DM_Weight/ReportTemp/machine_log_take.grf | 1 -
DM_Weight/ReportTemp/stock_template.grf | 1 -
DM_Weight/Services/ChannelStockService.cs | 37 +
DM_Weight/Services/MachineRecordService.cs | 79 ++
DM_Weight/Services/UserService.cs | 54 ++
.../ViewModels/AccountWindowViewModel.cs | 414 ++++++++++
.../ViewModels/AddDrugControlViewModel.cs | 545 +++++++++++++
.../BindingChannelDialogViewModel.cs | 47 +-
.../BindingChannelNewDialogViewModel.cs | 544 +++++++++++++
.../ViewModels/ChangeShiftsDialogViewModel.cs | 38 +-
.../ChangeShiftsListWindowViewModel.cs | 10 +-
.../ChangeShiftsRecordWindowViewModel.cs | 4 +-
.../ViewModels/ChangeShiftsWindowViewModel.cs | 26 +-
.../CheckRecordDetailDialogViewModel.cs | 198 +++++
.../CheckRecordNewWindowViewModel.cs | 211 +++++
.../CheckStockNew2WindowViewModel.cs | 604 ++++++++++++++
.../CheckStockNewWindowViewModel.cs | 647 +++++++++++++++
.../ViewModels/CheckStockWindowViewModel.cs | 21 +-
.../DrawerAddDrugWindowViewModel.cs | 68 +-
.../DrawerTakeDrugWindowViewModel.cs | 72 +-
.../ViewModels/DrugListWindowViewModel.cs | 114 ++-
.../ViewModels/EditUserDialogViewModel.cs | 16 +-
.../ViewModels/FingerprintDialogViewModel.cs | 2 +-
DM_Weight/ViewModels/HomeWindowViewModel.cs | 310 +++++--
.../ViewModels/InvoiceAddDialogViewModel.cs | 122 ++-
.../InvoiceInNewWindow2ViewModel.cs | 626 +++++++++++++++
.../ViewModels/InvoiceInNewWindowViewModel.cs | 754 ++++++++++++++++++
.../ViewModels/InvoiceInWindowViewModel.cs | 36 +-
.../ViewModels/InvoiceOutWindowViewModel.cs | 11 +-
.../ViewModels/InvoiceTakeDialogViewModel.cs | 49 +-
DM_Weight/ViewModels/LoginWindowViewModel.cs | 141 ++--
.../MachineRecordWindowViewModel.cs | 77 +-
DM_Weight/ViewModels/MainWindowViewModel.cs | 26 +-
DM_Weight/ViewModels/MaskDialogViewModel.cs | 33 +
.../ViewModels/OrderReturnDialogViewModel.cs | 71 +-
.../ViewModels/OrderTakeDialogViewModel.cs | 94 ++-
.../OrderTakeDrugWindowViewModel.cs | 47 +-
.../ViewModels/ReturnDrugDialogViewModel.cs | 27 +-
.../ViewModels/ReturnDrugWindow2ViewModel.cs | 12 +-
.../ViewModels/ReturnDrugWindowViewModel.cs | 10 +-
.../ViewModels/ReturnEmptyDialogViewModel.cs | 18 +-
.../ViewModels/ReturnEmptyWindowViewModel.cs | 9 +-
.../ViewModels/RoleManagerWindowViewModel.cs | 61 +-
.../ViewModels/SelfAddDialogViewModel.cs | 86 +-
.../SelfAddWindowViewModel - 复制.cs | 211 +++++
.../ViewModels/SelfAddWindowViewModel.cs | 86 +-
.../ViewModels/SelfTakeDialogViewModel.cs | 69 +-
.../ViewModels/SelfTakeDrugWindowViewModel.cs | 74 +-
.../ViewModels/SettingWindowViewModel.cs | 4 +-
.../StockListAccountDialogViewModel.cs | 136 ++++
.../ViewModels/StockListWindowViewModel.cs | 148 +++-
DM_Weight/ViewModels/TestCheckBoxViewModel.cs | 22 -
.../ViewModels/UserManagerWindowViewModel.cs | 9 +-
DM_Weight/Views/AccountWindow.xaml | 257 ++++++
DM_Weight/Views/AccountWindow.xaml.cs | 53 ++
DM_Weight/Views/AddDrugControl.xaml | 395 +++++++++
DM_Weight/Views/AddDrugControl.xaml.cs | 41 +
DM_Weight/Views/CheckRecordNewWindow.xaml | 203 +++++
DM_Weight/Views/CheckRecordNewWindow.xaml.cs | 28 +
DM_Weight/Views/CheckStockNew2Window.xaml | 195 +++++
DM_Weight/Views/CheckStockNew2Window.xaml.cs | 60 ++
DM_Weight/Views/CheckStockNewWindow.xaml | 220 +++++
DM_Weight/Views/CheckStockNewWindow.xaml.cs | 60 ++
.../Views/Dialog/BindingChannelNewDialog.xaml | 237 ++++++
.../Dialog/BindingChannelNewDialog.xaml.cs | 48 ++
.../Views/Dialog/CheckRecordDetailDialog.xaml | 122 +++
.../Dialog/CheckRecordDetailDialog.xaml.cs | 28 +
DM_Weight/Views/Dialog/MaskDialog.xaml | 12 +
DM_Weight/Views/Dialog/MaskDialog.xaml.cs | 28 +
.../Views/Dialog/StockListAccountDialog.xaml | 59 ++
.../Dialog/StockListAccountDialog.xaml.cs | 28 +
DM_Weight/Views/DrawerAddDrugWindow.xaml | 13 +-
DM_Weight/Views/HomeWindow.xaml | 37 +-
DM_Weight/Views/InvoiceInNewWindow.xaml | 309 +++++++
DM_Weight/Views/InvoiceInNewWindow.xaml.cs | 40 +
DM_Weight/Views/LoginWindow.xaml | 4 +-
DM_Weight/Views/MachineRecordWindow.xaml | 16 +-
DM_Weight/Views/OrderTakeDrugWindow.xaml | 40 +-
DM_Weight/Views/SelfAddWindow - 复制.xaml | 238 ++++++
DM_Weight/Views/SelfAddWindow - 复制.xaml.cs | 28 +
DM_Weight/Views/SelfAddWindow.xaml | 116 +--
DM_Weight/Views/SelfTakeDrugWindow.xaml | 111 +--
DM_Weight/Views/StockListWindow.xaml | 108 ++-
DM_Weight/Views/StockListWindow.xaml.cs | 36 +-
DM_Weight/msg/AddDrugEvent.cs | 14 +
109 files changed, 11038 insertions(+), 821 deletions(-)
create mode 100644 DM_Weight/Converter/TotalCountConverter.cs
create mode 100644 DM_Weight/Models/AccountModel.cs
create mode 100644 DM_Weight/Models/AccountType.cs
create mode 100644 DM_Weight/Models/ChannelList.cs
create mode 100644 DM_Weight/Models/ChannelStockCount.cs
create mode 100644 DM_Weight/Models/CheckRecordStock.cs
create mode 100644 DM_Weight/Models/Class1.cs
create mode 100644 DM_Weight/ReportTemp/machine_log_check_new.grf
create mode 100644 DM_Weight/ReportTemp/machine_log_check_new2.grf
create mode 100644 DM_Weight/Services/ChannelStockService.cs
create mode 100644 DM_Weight/Services/MachineRecordService.cs
create mode 100644 DM_Weight/Services/UserService.cs
create mode 100644 DM_Weight/ViewModels/AccountWindowViewModel.cs
create mode 100644 DM_Weight/ViewModels/AddDrugControlViewModel.cs
create mode 100644 DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
create mode 100644 DM_Weight/ViewModels/CheckRecordDetailDialogViewModel.cs
create mode 100644 DM_Weight/ViewModels/CheckRecordNewWindowViewModel.cs
create mode 100644 DM_Weight/ViewModels/CheckStockNew2WindowViewModel.cs
create mode 100644 DM_Weight/ViewModels/CheckStockNewWindowViewModel.cs
create mode 100644 DM_Weight/ViewModels/InvoiceInNewWindow2ViewModel.cs
create mode 100644 DM_Weight/ViewModels/InvoiceInNewWindowViewModel.cs
create mode 100644 DM_Weight/ViewModels/MaskDialogViewModel.cs
create mode 100644 DM_Weight/ViewModels/SelfAddWindowViewModel - 复制.cs
create mode 100644 DM_Weight/ViewModels/StockListAccountDialogViewModel.cs
delete mode 100644 DM_Weight/ViewModels/TestCheckBoxViewModel.cs
create mode 100644 DM_Weight/Views/AccountWindow.xaml
create mode 100644 DM_Weight/Views/AccountWindow.xaml.cs
create mode 100644 DM_Weight/Views/AddDrugControl.xaml
create mode 100644 DM_Weight/Views/AddDrugControl.xaml.cs
create mode 100644 DM_Weight/Views/CheckRecordNewWindow.xaml
create mode 100644 DM_Weight/Views/CheckRecordNewWindow.xaml.cs
create mode 100644 DM_Weight/Views/CheckStockNew2Window.xaml
create mode 100644 DM_Weight/Views/CheckStockNew2Window.xaml.cs
create mode 100644 DM_Weight/Views/CheckStockNewWindow.xaml
create mode 100644 DM_Weight/Views/CheckStockNewWindow.xaml.cs
create mode 100644 DM_Weight/Views/Dialog/BindingChannelNewDialog.xaml
create mode 100644 DM_Weight/Views/Dialog/BindingChannelNewDialog.xaml.cs
create mode 100644 DM_Weight/Views/Dialog/CheckRecordDetailDialog.xaml
create mode 100644 DM_Weight/Views/Dialog/CheckRecordDetailDialog.xaml.cs
create mode 100644 DM_Weight/Views/Dialog/MaskDialog.xaml
create mode 100644 DM_Weight/Views/Dialog/MaskDialog.xaml.cs
create mode 100644 DM_Weight/Views/Dialog/StockListAccountDialog.xaml
create mode 100644 DM_Weight/Views/Dialog/StockListAccountDialog.xaml.cs
create mode 100644 DM_Weight/Views/InvoiceInNewWindow.xaml
create mode 100644 DM_Weight/Views/InvoiceInNewWindow.xaml.cs
create mode 100644 DM_Weight/Views/SelfAddWindow - 复制.xaml
create mode 100644 DM_Weight/Views/SelfAddWindow - 复制.xaml.cs
create mode 100644 DM_Weight/msg/AddDrugEvent.cs
diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 641ab62..f36dcbe 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -3,7 +3,7 @@
-
+
+
+
+
+
-
+
@@ -24,7 +28,7 @@
-
+
@@ -36,11 +40,11 @@
-
+
-
+
-
+
-
+
-
+
diff --git a/DM_Weight/App.xaml b/DM_Weight/App.xaml
index ef8d445..704fc50 100644
--- a/DM_Weight/App.xaml
+++ b/DM_Weight/App.xaml
@@ -6,7 +6,7 @@
d1p1:Ignorable="d"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:DM_Weight"
- xmlns:prism="http://prismlibrary.com/">
+ xmlns:prism="http://prismlibrary.com/" Startup="PrismApplication_Startup">
diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs
index 3327878..3015529 100644
--- a/DM_Weight/App.xaml.cs
+++ b/DM_Weight/App.xaml.cs
@@ -26,6 +26,9 @@ using System.Timers;
using DM_Weight.Models;
using SqlSugar;
using Microsoft.Extensions.DependencyInjection;
+using DM_Weight.Services;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
namespace DM_Weight
{
@@ -114,7 +117,7 @@ namespace DM_Weight
// 串口工具
containerRegistry.RegisterSingleton();
// 指纹机工具
- //containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
// 组态屏工具
containerRegistry.RegisterSingleton();
@@ -164,6 +167,8 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation();
// 调拨加药页面
containerRegistry.RegisterForNavigation();
+ // 调拨加药页面
+ containerRegistry.RegisterForNavigation();
// 调拨取药模态框
containerRegistry.RegisterDialog();
@@ -173,6 +178,8 @@ namespace DM_Weight
// 自选加药模态框
containerRegistry.RegisterDialog();
containerRegistry.RegisterForNavigation();
+ //多批次抽屉加药
+ containerRegistry.RegisterForNavigation();
#endregion
#region 还药
@@ -200,11 +207,24 @@ namespace DM_Weight
// 库位绑定模态框
containerRegistry.RegisterDialog();
containerRegistry.RegisterForNavigation();
+
+ // 库位绑定模态框
+ containerRegistry.RegisterDialog();
+ containerRegistry.RegisterForNavigation();
// 库存盘点页面
containerRegistry.RegisterForNavigation();
+ containerRegistry.RegisterDialog();
+ containerRegistry.RegisterForNavigation();
+ // 库存盘点页面--新(类似库存列表页面)
+ containerRegistry.RegisterForNavigation();
+ // 库存盘点页面--新(类似库存列表页面)
+ containerRegistry.RegisterForNavigation();
+ // 库存盘点页面--新(类似库存列表页面)
+ containerRegistry.RegisterForNavigation();
// 药品列表页面
containerRegistry.RegisterForNavigation();
-
+ //库存列表导出账册弹窗
+ containerRegistry.RegisterForNavigation();
#endregion
#region 系统设置
@@ -239,9 +259,48 @@ namespace DM_Weight
containerRegistry.RegisterSingleton(() => SqlSugarHelperNew.GetInstance());
- containerRegistry.RegisterForNavigation();
-
+ //账册页面
+ containerRegistry.RegisterForNavigation();
+ //账册服务类
+ containerRegistry.Register();
}
+
+ private void PrismApplication_Startup(object sender, StartupEventArgs e)
+ {
+ //获取欲启动程序名
+ string processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
+ //检查程序是否已经启动,已经启动则显示提示退出程序
+ if (System.Diagnostics.Process.GetProcessesByName(processName).Length > 1)
+ {
+ //系统在运行
+ 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);
//protected IServiceProvider ConfigureServices(IServiceCollection services)
//{
// // 创建 SqlSugar 实例
diff --git a/DM_Weight/Converter/GroupSumConverter.cs b/DM_Weight/Converter/GroupSumConverter.cs
index 3907e37..9917c8b 100644
--- a/DM_Weight/Converter/GroupSumConverter.cs
+++ b/DM_Weight/Converter/GroupSumConverter.cs
@@ -23,7 +23,15 @@ namespace DM_Weight.Converter
foreach (var item in items)
{
var de = item as ChannelStock;
- total += de.Quantity;
+ try
+ {
+ total += de.Quantity;
+ }
+ catch (Exception)
+ {
+ var de2 = item as CheckRecordStock;
+ total = de2.quantity;
+ }
}
}
return "总库存:" + total;
diff --git a/DM_Weight/Converter/TotalCountConverter.cs b/DM_Weight/Converter/TotalCountConverter.cs
new file mode 100644
index 0000000..0c996e7
--- /dev/null
+++ b/DM_Weight/Converter/TotalCountConverter.cs
@@ -0,0 +1,33 @@
+using DM_Weight.Models;
+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 TotalCountConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ var total = 0;
+ if (value is List items)
+ {
+ foreach (var item in items)
+ {
+ var de = item as ChannelStock;
+ total += de.Quantity;
+ }
+ }
+ return total;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/DM_Weight/DM_Weight.csproj b/DM_Weight/DM_Weight.csproj
index 588c057..962e012 100644
--- a/DM_Weight/DM_Weight.csproj
+++ b/DM_Weight/DM_Weight.csproj
@@ -70,6 +70,7 @@
+
@@ -87,6 +88,12 @@
+
+
+ Code
+
+
+
Never
@@ -106,6 +113,12 @@
Always
+
+ Always
+
+
+ Always
+
Always
diff --git a/DM_Weight/Finger/FingerprintUtil.cs b/DM_Weight/Finger/FingerprintUtil.cs
index 27cf4eb..6388b71 100644
--- a/DM_Weight/Finger/FingerprintUtil.cs
+++ b/DM_Weight/Finger/FingerprintUtil.cs
@@ -20,22 +20,22 @@ namespace DM_Weight.Finger
{
private readonly ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
- public zkemkeeper.CZKEMClass axCZKEM1; //= new zkemkeeper.CZKEMClass();
+ public zkemkeeper.CZKEMClass axCZKEM1;// = new zkemkeeper.CZKEMClass();
public bool bIsConnected = false;
- private string fingerIp = ConfigurationManager.AppSettings["fingerIp"]?.ToString()??"";
+ private string fingerIp = ConfigurationManager.AppSettings["fingerIp"]?.ToString() ?? "";
private int fingerPort = 4370;
- private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"]?.ToString()??"0");
- private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"]?.ToString()??"0");
+ private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"]?.ToString() ?? "0");
+ private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"]?.ToString() ?? "0");
private readonly IEventAggregator _eventAggregator;
public FingerprintUtil(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
logger.Info($"进入构造器,开始连接指纹机");
- Task.Run(() =>
- {
+ // Task.Factory.StartNew(() =>
+ //{
ConnectionMain();
- });
+ //});
}
public void ConnectionMain()
@@ -47,7 +47,7 @@ namespace DM_Weight.Finger
logger.Info($"连接指纹机,IP:{fingerIp},端口:{fingerPort},机器号:{machineNumber},连接结果:{bIsConnected}");
if (bIsConnected)
{
- if (axCZKEM1.RegEvent(machineNumber, 65535))
+ if (axCZKEM1.RegEvent(machineNumber, 9))
{
this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
//this.axCZKEM1.OnEnrollFinger += new zkemkeeper._IZKEMEvents_OnEnrollFingerEventHandler(axCZKEM1_OnEnrollFinger);
@@ -62,7 +62,7 @@ namespace DM_Weight.Finger
Result = bIsConnected,
});
}
- catch(Exception ex)
+ catch (Exception ex)
{
logger.Info($"连接指纹机异常{ex.Message.ToString()}");
}
@@ -90,10 +90,10 @@ namespace DM_Weight.Finger
Id = iEnrollNumber,
FingerIndex = iFingerIndex
};
-
+
axCZKEM1.StartIdentify();
axCZKEM1.RefreshData(1);
-
+
logger.Info($"触发用户登记指纹事件,用户id:{iEnrollNumber}指纹索引:{iFingerIndex}登记结果:{(iActionResult == 0)}");
message.Result = (iActionResult == 0);
_eventAggregator.GetEvent().Publish(message);
@@ -161,8 +161,16 @@ namespace DM_Weight.Finger
bool result = false;
// 取消其他操作
bool res2 = axCZKEM1.CancelOperation();
- // 删除源指纹
- bool res = axCZKEM1.DelUserTmp(machineNumber, Id, FingerIndex);
+ if (machineType == 1)
+ {
+ // 删除源指纹
+ bool res = axCZKEM1.DelUserTmp(machineNumber, Id, FingerIndex);
+ }
+ else
+ {
+ // 删除源指纹
+ bool res = axCZKEM1.SSR_DelUserTmp(machineNumber, Id.ToString(), FingerIndex);
+ }
// 添加新指纹
result = axCZKEM1.StartEnrollEx(Id.ToString(), FingerIndex, 3);
return result;
diff --git a/DM_Weight/Models/AccountModel.cs b/DM_Weight/Models/AccountModel.cs
new file mode 100644
index 0000000..ff8fab5
--- /dev/null
+++ b/DM_Weight/Models/AccountModel.cs
@@ -0,0 +1,87 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Models
+{
+ ///
+ /// 账册
+ ///
+ public class AccountModel
+ {
+ ///
+ /// 总结存
+ ///
+ public int StockQuantity { get; set; }
+ ///
+ /// 借入数量
+ ///
+ public int InQuantity { get; set; }
+ ///
+ /// 发出数量
+ ///
+ public int OutQuantity { get; set; }
+ ///
+ /// 日期
+ ///
+ public string OperationTime { get; set; }
+ ///
+ /// 凭证号
+ ///
+ public string InvoiceId { get;set; }
+ ///
+ /// 药品名称
+ ///
+ public string DrugName { get; set; }
+ ///
+ /// 药品ID
+ ///
+ public string DrugId { get; set; }
+ ///
+ /// 单位
+ ///
+ public string PackUnit { get; set; }
+ ///
+ /// 剂型
+ ///
+ public string Dosage { get; set; }
+ ///
+ /// 厂家
+ ///
+ public string Manufactory { get; set; }
+ ///
+ /// 批次
+ ///
+ public string ManuNo { get;set; }
+ ///
+ /// 效期
+ ///
+ public string EffDate { get; set; }
+ ///
+ /// 操作人
+ ///
+ public string OperatorName { get;set; }
+ ///
+ /// 复核人
+ ///
+ public string ReviewerName { get; set; }
+ ///
+ /// 规格
+ ///
+ public string DrugSpec { get; set; }
+
+ public DrugInfo DrugInfo { get; set; }
+
+ ///
+ /// 供应单位
+ ///
+ public string SupplierDept { get; set; }
+ ///
+ /// 领用部门
+ ///
+ public string ReceiveDept { get; set; }
+ }
+}
diff --git a/DM_Weight/Models/AccountType.cs b/DM_Weight/Models/AccountType.cs
new file mode 100644
index 0000000..54509cf
--- /dev/null
+++ b/DM_Weight/Models/AccountType.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Models
+{
+ ///
+ /// 账册类型
+ ///
+ public class AccountType
+ {
+ ///
+ /// 账册类型名称
+ ///
+ public string AccountTypeName { get; set; }
+ ///
+ /// 账册类型值
+ ///
+ public int AccountTypeValue { get; set; }
+ }
+}
diff --git a/DM_Weight/Models/ChannelList.cs b/DM_Weight/Models/ChannelList.cs
new file mode 100644
index 0000000..8124e4f
--- /dev/null
+++ b/DM_Weight/Models/ChannelList.cs
@@ -0,0 +1,184 @@
+using Prism.Commands;
+using Prism.Mvvm;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Models
+{
+ [SugarTable("channel_list")]
+ public class ChannelList : BindableBase
+ {
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "chnguid", IsPrimaryKey = true)]
+ //[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
+ public string Id { get; set; }
+
+ ///
+ ///
+ /// 默认值: NULL
+ ///
+ [SugarColumn(ColumnName = "machine_id")]
+ public string MachineId { get; set; }
+ ///
+ ///
+ /// 默认值: NULL
+ ///
+ [SugarColumn(ColumnName = "row_no")]
+ public int DrawerNo { get; set; }
+ ///
+ ///
+ /// 默认值: NULL
+ ///
+ [SugarColumn(ColumnName = "col_no")]
+ public int ColNo { get; set; }
+ ///
+ ///
+ /// 默认值: NULL
+ ///
+ [SugarColumn(ColumnName = "pos_no")]
+ public int PosNo { get; set; }
+
+
+ ///
+ ///
+ /// 默认值: NULL
+ ///
+ [SugarColumn(ColumnName = "drug_id")]
+ public string DrugId { get; set; }
+
+ /////
+ /////
+ ///// 默认值: NULL
+ /////
+ //[SugarColumn(ColumnName = "manu_no")]
+ //public string ManuNo { get; set; }
+ /////
+ /////
+ ///// 默认值: NULL
+ /////
+ //[SugarColumn(ColumnName = "eff_date")]
+ //public string EffDate { get; set; }
+ /////
+ /////
+ ///// 默认值: NULL
+ /////
+ //[SugarColumn(ColumnName = "quantity")]
+ //public int Quantity { get; set; }
+
+ ///
+ ///
+ /// 默认值: 1
+ ///
+ [SugarColumn(ColumnName = "drawer_type")]
+ public int DrawerType { get; set; }
+ ///
+ ///
+ /// 默认值: 1
+ ///
+ [SugarColumn(ColumnName = "board_type")]
+ public int BoardType { get; set; }
+ ///
+ ///
+ /// 默认值: 1
+ ///
+ [SugarColumn(ColumnName = "state")]
+ public int? State { get; set; }
+
+ [SugarColumn(IsIgnore = true)]
+ public bool IsSelected { get; set; }
+
+ [SugarColumn(IsIgnore = true)]
+ public InOutInvoice Invoice { get; set; }
+
+ [SugarColumn(IsIgnore = true)]
+ public string Location
+ {
+ get => DrawerNo + "-" + ColNo;
+ }
+ //private int _addQuantity = 0;
+ //[SugarColumn(IsIgnore = true)]
+ //public int AddQuantity
+ //{
+ // get => _addQuantity;
+ // set
+ // {
+ // SetProperty(ref _addQuantity, value);
+ // }
+ //}
+
+ //private int _takeQuantity = 0;
+
+ //[SugarColumn(IsIgnore = true)]
+ //public int TakeQuantity
+ //{
+ // get => _takeQuantity;
+ // set
+ // {
+ // if (value > Quantity)
+ // {
+ // throw new ArgumentException("取药数量不能大于库存");
+ // }
+ // SetProperty(ref _takeQuantity, value);
+ // }
+ //}
+ //private int _returnQuantity = 0;
+
+ //[SugarColumn(IsIgnore = true)]
+ //public int ReturnQuantity
+ //{
+ // get => _returnQuantity;
+ // set
+ // {
+ // SetProperty(ref _returnQuantity, value);
+ // }
+ //}
+
+ //private int _checkQuantity = 0;
+
+
+ //[SugarColumn(IsIgnore = true)]
+ //public int CheckQuantity
+ //{
+ // get => _checkQuantity;
+ // set
+ // {
+ // if (value < 0)
+ // {
+ // throw new ArgumentException("盘点数量不能是负数");
+ // }
+ // SetProperty(ref _checkQuantity, value);
+ // }
+ //}
+
+
+ //[SugarColumn(IsIgnore = true)]
+ //public int? CanReturnQuantity { get; set; }
+
+ private DrugInfo? _DrugInfo;
+ [Navigate(NavigateType.ManyToOne, nameof(DrugId))]
+ public DrugInfo Drug { get => _DrugInfo; set => SetProperty(ref _DrugInfo, value); }
+
+ //[SugarColumn(IsIgnore = true)]
+ //public int process { get; set; } = 0;
+
+
+ private DrugManuNo? _drugManuNo;
+ [SugarColumn(IsIgnore = true)]
+ public DrugManuNo? drugManuNo { get => _drugManuNo; set => SetProperty(ref _drugManuNo, value); }
+
+ private List? _channelStocks;
+ [Navigate(NavigateType.OneToMany, nameof(ChannelStock.Chnguid))]
+ public List channelStocks { get => _channelStocks; set => SetProperty(ref _channelStocks, value); }
+
+ public int _totalCount;
+ [SugarColumn(IsIgnore = true)]
+ public int totalCount { get => _totalCount;set=> SetProperty(ref _totalCount, value); }
+
+ }
+}
diff --git a/DM_Weight/Models/ChannelStock.cs b/DM_Weight/Models/ChannelStock.cs
index 9046e1c..80c14c5 100644
--- a/DM_Weight/Models/ChannelStock.cs
+++ b/DM_Weight/Models/ChannelStock.cs
@@ -19,6 +19,8 @@ namespace DM_Weight.Models
//[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
public string Id { get; set; }
+ [SugarColumn(ColumnName = "chnguid")]
+ public string Chnguid { get; set; }
///
///
/// 默认值: NULL
@@ -185,5 +187,10 @@ namespace DM_Weight.Models
//private string _manuNoEffDate;
//[SugarColumn(IsIgnore = true)]
//public string ManuNoEffDate { get => _manuNoEffDate; set => SetProperty(ref _manuNoEffDate, value); }
+
+
+ private ChannelList? _channelList;
+ [Navigate(NavigateType.ManyToOne, nameof(Chnguid))]
+ public ChannelList ChannelLst { get => _channelList; set => SetProperty(ref _channelList, value); }
}
}
\ No newline at end of file
diff --git a/DM_Weight/Models/ChannelStockCount.cs b/DM_Weight/Models/ChannelStockCount.cs
new file mode 100644
index 0000000..97e41ab
--- /dev/null
+++ b/DM_Weight/Models/ChannelStockCount.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Models
+{
+ public class ChannelStockCount
+ {
+ public int DrawerNo { get; set; }
+ public int ColNo { get; set; }
+ public string DrugId { get; set; }
+ public string ManuNo { get;set; }
+ public int Quantity { get;set; }
+ public string EffDate { get; set; }
+ public string DrugName { get; set; }
+ public string DrugSpec { get; set; }
+ public string Dosage { get;set; }
+ public string ManuFactory { get;set; }
+ public string SmallUnit { get;set; }
+ public string PackUnit { get; set; }
+ public string MachineId { get; set; }
+ }
+}
diff --git a/DM_Weight/Models/CheckRecordStock.cs b/DM_Weight/Models/CheckRecordStock.cs
new file mode 100644
index 0000000..4054257
--- /dev/null
+++ b/DM_Weight/Models/CheckRecordStock.cs
@@ -0,0 +1,94 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Models
+{
+ ///
+ /// 盘点后药品库存数
+ ///
+ [SugarTable("check_stock")]
+ public class CheckRecordStock
+ {
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
+ public int ID { get; set; }
+ ///
+ /// 抽屉号
+ ///
+ [SugarColumn(ColumnName = "row_no")]
+ public int rowNo { get; set; }
+ ///
+ /// 列号
+ ///
+ [SugarColumn(ColumnName = "col_no")]
+ public int colNo { get; set; }
+ ///
+ /// 数量
+ ///
+ [SugarColumn(ColumnName = "quantity")]
+ public int quantity { get; set; }
+ ///
+ /// 批次
+ ///
+ [SugarColumn(ColumnName = "manu_no")]
+ public string manuNo { get; set; }
+ ///
+ /// 效期
+ ///
+ [SugarColumn(ColumnName = "eff_date")]
+ public string effDate { get; set; }
+ ///
+ /// 药品名称
+ ///
+ [SugarColumn(ColumnName = "drug_name")]
+ public string drugName { get; set; }
+ ///
+ /// 规格
+ ///
+ [SugarColumn(ColumnName = "drug_spec")]
+ public string drugSpec { get; set; }
+ //
+ [SugarColumn(ColumnName = "pack_unit")]
+ public string packUnit { get; set; }
+ ///
+ /// 厂商
+ ///
+ [SugarColumn(ColumnName = "manufactory")]
+ public string manufactory { get; set; }
+ [SugarColumn(ColumnName = "max_stock")]
+ public int maxStock { get; set; }
+ [SugarColumn(ColumnName = "drug_id")]
+ public string drugId { get; set; }
+ [SugarColumn(ColumnName = "machine_id")]
+ public string MachineId { get; set; }
+ ///
+ /// 批次总库存
+ ///
+ [SugarColumn(ColumnName = "manuQuantity")]
+ public int ManuQuantity { get; set; }
+ ///
+ /// 操作时间
+ ///
+ [SugarColumn(ColumnName = "optdate")]
+ public string optdate { get; set; }
+ ///
+ /// 操作人
+ ///
+ [SugarColumn(ColumnName = "operator")]
+ public string operatorUser { get; set; }
+ ///
+ /// 审核人
+ ///
+ [SugarColumn(ColumnName = "reviewer")]
+ public string reviewerUser { get; set; }
+
+ [SugarColumn(IsIgnore =true)]
+ public List manuNoDetails { get;set; }
+
+ [Navigate(NavigateType.ManyToOne, nameof(drugId))]
+ public DrugInfo DrugInfo { get; set; }
+ }
+}
diff --git a/DM_Weight/Models/Class1.cs b/DM_Weight/Models/Class1.cs
new file mode 100644
index 0000000..e03f93d
--- /dev/null
+++ b/DM_Weight/Models/Class1.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Models
+{
+ internal class Class1
+ {
+ }
+ /// /// 行政区表
+ /// ///
+ public class DistrictModel
+ { /// /// 主键 ///
+ private int id; /// /// 代码 ///
+ private int code; /// /// 名称 ///
+ private string name;
+ public int Id { get { return id; } set { id = value; } }
+ /// /// 代码 ///
+ public int Code { get { return code; } set { code = value; } }
+ /// /// 名称 ///
+ public string Name { get { return name; } set { name = value; } }
+ }
+ /// /// 表 ///
+ public class MapSpotModel
+ {
+ private int id; //名称
+
+ private string name; //代码
+ private int code; //个数
+ private int allNumber; //面积
+ private double allArea;
+
+
+ private int hCTureNumber;
+
+ private double hCTrueArea;
+
+ ///
+ /// 通过个数
+ ///
+ private int hCTruePassNumber; //不通过个数
+ private int hCTrueNoPassNumber; //通过率
+ private string hCTruePassingRate; //个数
+ private int jLTureNumber; //面积
+ private double jLTrueArea; //通过个数
+ private int jLTruePassNumber; //不通过个数
+ private int jLTrueNoPassNumber; //通过率
+ private string jLTruePassingRate;
+ private DistrictModel districtModels;
+ public int Id { get { return id; } set { id = value; } }
+ /// /// 名称 ///
+ public string Name { get { return name; } set { name = value; } } /// /// 代码 ///
+ public int Code { get { return code; } set { code = value; } } /// /// 个数 ///
+ public int AllNumber { get { return allNumber; } set { allNumber = value; } } /// /// 面积 ///
+ public double AllArea { get { return allArea; } set { allArea = value; } } /// /// 个数 ///
+ public int HCTureNumber { get { return hCTureNumber; } set { hCTureNumber = value; } } /// /// 面积 ///
+ public double HCTrueArea { get { return hCTrueArea; } set { hCTrueArea = value; } }
+ /// /// 通过个数 ///
+ public int HCTruePassNumber { get { return hCTruePassNumber; } set { hCTruePassNumber = value; } }
+ /// /// /// 不通过个数 ///
+ public int HCTrueNoPassNumber { get { return hCTrueNoPassNumber; } set { hCTrueNoPassNumber = value; } }
+ /// /// /// 通过率 ///
+ public string HCTruePassingRate { get { return hCTruePassingRate; } set { hCTruePassingRate = value; } } /// /// 个数 ///
+ public int JLTureNumber { get { return jLTureNumber; } set { jLTureNumber = value; } }
+ /// /// 面积 ///
+ public double JLTrueArea { get { return jLTrueArea; } set { jLTrueArea = value; } }
+ /// /// /// 通过个数 ///
+ public int JLTruePassNumber { get { return jLTruePassNumber; } set { jLTruePassNumber = value; } }
+ /// /// /// 不通过个数 ///
+ public int JLTrueNoPassNumber { get { return jLTrueNoPassNumber; } set { jLTrueNoPassNumber = value; } }
+ /// /// /// 监理单位已审核图斑-通过率 ///
+ public string JLTruePassingRate { get { return jLTruePassingRate; } set { jLTruePassingRate = value; } }
+ public DistrictModel DistrictModels { get { return districtModels; } set { districtModels = value; } }
+ }
+}
diff --git a/DM_Weight/Models/InOutInvoice.cs b/DM_Weight/Models/InOutInvoice.cs
index 0680abd..ca8fa2c 100644
--- a/DM_Weight/Models/InOutInvoice.cs
+++ b/DM_Weight/Models/InOutInvoice.cs
@@ -145,5 +145,11 @@ namespace DM_Weight.Models
[SugarColumn(ColumnName = "cancel_flag")]
public int CancelFlag { get; set; }
+ [SugarColumn(IsIgnore =true)]
+ public int CountNum { get; set; }
+
+ [SugarColumn(IsIgnore =true)]
+ public int SumQuantity { get; set; }
+
}
}
diff --git a/DM_Weight/Models/MachineRecord.cs b/DM_Weight/Models/MachineRecord.cs
index 01f58b2..f9cb957 100644
--- a/DM_Weight/Models/MachineRecord.cs
+++ b/DM_Weight/Models/MachineRecord.cs
@@ -143,5 +143,15 @@ namespace DM_Weight.Models
///
[SugarColumn(ColumnName = "manunoQuantity")]
public int? ManunoQuantity { get; set; }
+ ///
+ /// 供应单位
+ ///
+ [SugarColumn(ColumnName = "supplierDept")]
+ public string SupplierDept { get; set; }
+ ///
+ /// 领用部门
+ ///
+ [SugarColumn(ColumnName = "receiveDept")]
+ public string ReceiveDept { get; set; }
}
}
diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs
index f9fe969..8ce57bf 100644
--- a/DM_Weight/Port/PortUtil.cs
+++ b/DM_Weight/Port/PortUtil.cs
@@ -63,9 +63,9 @@ namespace DM_Weight.Port
// 取药操作的窗口名【处方取药、抽屉取药、自选取药、调拨出库】
private string[] TakeNames = new string[] { "DrawerTakeDrugWindow", "OrderTakeDrugWindow", "SelfTakeDrugWindow", "InvoiceTakeDrugWindow" };
// 加药操作的窗口名【自选加药、抽屉加药、还药】
- private string[] AddNames = new string[] { "SelfAddWindow", "ReturnDrugWindow", "ReturnDrug1Window", "DrawerAddDrugWindow" };
+ private string[] AddNames = new string[] { "SelfAddWindow", "ReturnDrugWindow", "ReturnDrug1Window", "DrawerAddDrugWindow", "AddDrugControl" };
// 盘点操作的窗口名【盘点】
- private string[] CheckNames = new string[] { "CheckStockWindow" };
+ private string[] CheckNames = new string[] { "CheckStockWindow", "CheckStockNewWindow" };
// 归还空瓶操作的窗口名【盘点】
private string[] ReturnEmptyNames = new string[] { "ReturnEmptyWindow" };
@@ -85,7 +85,7 @@ namespace DM_Weight.Port
public DateTime dateTime { get; set; } = DateTime.Now;
- public async void ResetData()
+ public async Task ResetData()
{
logger.Info($"重新设置串口数据状态【{statue}】,抽屉【{DrawerNo}】");
if (!"HomeWindow".Equals(WindowName) && statue == 1)
@@ -112,7 +112,7 @@ namespace DM_Weight.Port
}
if (BoardType == 5)
{
- await WriteQuantityArray();
+ //await WriteQuantityArray();
}
}
Operate = false;
@@ -139,9 +139,10 @@ namespace DM_Weight.Port
if (BoardType == 4)
{
byte[] result = await OpenStorage();
+ logger.Info($"储物箱使能返回:" + Convert.ToHexString(result));
int[] r = result.Select(it => Convert.ToInt32(it)).ToArray();
- logger.Info($"储物箱使能返回:" + string.Join("", r));
+ logger.Info($"储物箱使能返回:{Convert.ToHexString(result)}");
if (r[4] != 0)
{
logger.Info($"储物箱使能成功");
@@ -151,6 +152,7 @@ namespace DM_Weight.Port
else
{
string _WindowName = WindowName;
+ logger.Info($"储物箱使能失败r:" + string.Join("", r));
// 重新初始化数据
ResetData();
// 指令发送错误,未打开
@@ -161,7 +163,6 @@ namespace DM_Weight.Port
WindowName = _WindowName,
Message = "储物箱使能失败"
});
- logger.Info($"储物箱使能失败r:" + string.Join("", r));
}
}
else
@@ -190,6 +191,7 @@ namespace DM_Weight.Port
else
{
string _WindowName = WindowName;
+ logger.Info($"回收箱打开失败");
// 重新初始化数据
ResetData();
// 返回消息开启失败
@@ -200,7 +202,6 @@ namespace DM_Weight.Port
WindowName = _WindowName,
Message = "回收箱打开失败"
});
- logger.Info($"回收箱打开失败");
}
}
}
@@ -300,6 +301,7 @@ namespace DM_Weight.Port
{
string _WindowName = WindowName;
statue = 1;
+ logger.Info(ex.Message);
// 重新初始化数据
ResetData();
// 返回消息 抽屉打开失败
@@ -309,7 +311,6 @@ namespace DM_Weight.Port
WindowName = _WindowName,
Message = $"操作异常{ex.Message}"
});
- logger.Info(ex.Message);
}
}
@@ -439,15 +440,16 @@ namespace DM_Weight.Port
await BoxLockLightOff2();
}
string _WindowName = WindowName;
+ logger.Info($"抽屉【{DrawerNo}】已关闭");
+
// 重新初始化数据
- ResetData();
+ await ResetData();
// 返回消息 抽屉已经关闭
_eventAggregator.GetEvent().Publish(new util.DeviceMsg()
{
EventType = util.EventType.DRAWERCLOSE,
WindowName = _WindowName,
});
- logger.Info($"抽屉【{DrawerNo}】已关闭");
}
}
@@ -456,6 +458,7 @@ namespace DM_Weight.Port
{
string _WindowName = WindowName;
+ logger.Info($"GetDrawerStatus异常:{ex.Message}");
// 重新初始化数据
ResetData();
_eventAggregator.GetEvent().Publish(new util.DeviceMsg()
@@ -464,7 +467,6 @@ namespace DM_Weight.Port
WindowName = _WindowName,
Message = $"GetDrawerStatus异常:{ex.Message}"
});
- logger.Info($"GetDrawerStatus异常:{ex.Message}");
}
}
@@ -552,9 +554,9 @@ namespace DM_Weight.Port
statue = 2;
string _WindowName = WindowName;
+ logger.Info($"储物箱关闭");
// 重新初始化数据
ResetData();
- logger.Info($"储物箱关闭");
_eventAggregator.GetEvent().Publish(new util.DeviceMsg()
{
EventType = util.EventType.DRAWERCLOSE,
@@ -587,6 +589,8 @@ namespace DM_Weight.Port
catch (Exception ex)
{
logger.Info($"GetBackDoorState异常{ex.Message}");
+ // 重新初始化数据
+ ResetData();
}
}
@@ -665,7 +669,44 @@ namespace DM_Weight.Port
}
if (_length != length)
{
- throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
+ if(_length!=0)
+ {
+ byte[] _buffer = new byte[_length];
+ serialPort.Read(_buffer, 0, _length);
+ logger.Info($"交互超时回复:{Convert.ToHexString(buffer)}");
+ }
+ throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
+ }
+ serialPort.Read(buffer, 0, length);
+ //}
+ //catch (Exception ex)
+ //{
+ // logger.Error($"GetBufferByPort:{ex.Message}");
+ //}
+ return buffer;
+ }
+ private byte[] GetBufferByPort(SerialPort serialPort, int length, int timeout,string operation)
+ {
+ byte[] buffer = new byte[length];
+ //try
+ //{
+ int _length = 0;
+ DateTime start = DateTime.Now;
+ DateTime end = DateTime.Now;
+ while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
+ {
+ _length = serialPort.BytesToRead;
+ end = DateTime.Now;
+ }
+ if (_length != length)
+ {
+ if (_length != 0)
+ {
+ byte[] _buffer = new byte[_length];
+ serialPort.Read(_buffer, 0, _length);
+ logger.Info($"交互超时回复:{Convert.ToHexString(buffer)},{operation}");
+ }
+ throw new TimeoutException($"串口【{serialPort.PortName}】交互超时,操作为{operation}");
}
serialPort.Read(buffer, 0, length);
//}
@@ -681,6 +722,11 @@ namespace DM_Weight.Port
return Task.Run(() => GetBufferByPort(serialPort, length, 3000));
}
+ private Task GetBufferByPort(SerialPort serialPort, int length,string operation)
+ {
+
+ return Task.Run(() => GetBufferByPort(serialPort, length, 3000,operation));
+ }
public static SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
public void SpeakAsync(string textinfo)
@@ -764,9 +810,9 @@ namespace DM_Weight.Port
canBusSerial.DiscardInBuffer();
byte[] buffer = new byte[] { 0xaa, (byte)(_doorAddr), 0x01, (byte)_storageBoxAddr, 0x00, 0x00, 0x00, 0xee };
canBusSerial.Write(buffer, 0, 8);
- logger.Info($"OpenStorage:{string.Join("", buffer)}");
+ logger.Info($"OpenStorage:{Convert.ToHexString(buffer)}");
- return await GetBufferByPort(canBusSerial, 8);
+ return await GetBufferByPort(canBusSerial, 8,"开储物箱");
}
// 关闭电控门储物箱(有灯失能)
public void CloseStorage()
@@ -806,9 +852,9 @@ namespace DM_Weight.Port
Array.Reverse(schar);
int[] iArray = Array.ConvertAll(schar, c => (int)Char.GetNumericValue(c));
int[] addArray = new int[8 - iArray.Length];
- if(iArray.Length<8)
+ if (iArray.Length < 8)
{
- for (int i = 0; i < 8- iArray.Length; i++)
+ for (int i = 0; i < 8 - iArray.Length; i++)
{
addArray[i] = 0;
}
@@ -837,7 +883,7 @@ namespace DM_Weight.Port
byte[] buffer = new byte[] { 0xaa, (byte)(0xf0 + DrawerNo), 0x01, 0x00, 0x00, 0x00, 0x00, 0xee };
- logger.Info($"单支板发送库位数量查询【{string.Join(",", buffer)}】");
+ logger.Info($"单支板发送库位数量查询【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
return await GetBufferByPort(canBusSerial, 13);
@@ -969,6 +1015,7 @@ namespace DM_Weight.Port
{
try
{
+ logger.Info($"写标签数据:{type}-{content}-{drawerNo}-{colNo}");
canBusSerial.DiscardInBuffer();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content));
@@ -1071,6 +1118,39 @@ namespace DM_Weight.Port
}
// 写入数量
public void WriteQuantity(int drawerNo, int colNo, int quantity)
+ {
+ try
+ {
+ logger.Info($"写入数量:{drawerNo}-{colNo}-{quantity}");
+ canBusSerial.DiscardInBuffer();
+ int channel = ((drawerNo > 8 ? (drawerNo - 8) * 2 : (drawerNo * 2 - 1)) - 1) * this.labelCount + 10 + colNo;
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x21, 0, 0, 0, 0, 0xee };
+ buffer[5] = (byte)(quantity >> 8);
+ buffer[6] = (byte)(quantity & 0xff);
+ logger.Info($"写入数量buffer:{Convert.ToHexString(buffer)}");
+ canBusSerial.Write(buffer, 0, 8);
+ Task task = GetBufferByPort(canBusSerial, 8);
+ if (task.Status == TaskStatus.Created)
+ {
+ task.Start();
+
+ }
+ byte[] bytes = task.Result;
+ logger.Info($"写入数量返回:" + Convert.ToHexString(bytes));
+ }
+ catch (Exception ex)
+ {
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.OPENERROR,
+ WindowName = WindowName,
+ Message = $"操作发生异常{ex.InnerException}"
+ });
+ logger.Info($"操作发生异常:ex:{ex.InnerException}");
+ }
+ }
+ // 写入数量
+ public async void WriteQuantityAsync(int drawerNo, int colNo, int quantity)
{
try
{
@@ -1080,6 +1160,8 @@ namespace DM_Weight.Port
buffer[5] = (byte)(quantity >> 8);
buffer[6] = (byte)(quantity & 0xff);
canBusSerial.Write(buffer, 0, 8);
+ byte[] bufferReturn=await GetBufferByPort(canBusSerial, 8);
+ logger.Info($"写入数量返回:" + Convert.ToHexString(bufferReturn));
}
catch (Exception ex)
{
@@ -1114,7 +1196,7 @@ namespace DM_Weight.Port
byte[] buffer = new byte[] { 0xAA, 0x9A, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEE };
canBusSerial.Write(buffer, 0, 8);
- return await GetBufferByPort(canBusSerial, 8);
+ return await GetBufferByPort(canBusSerial, 8, "打开回收箱");
}
catch (Exception ex)
{
@@ -1188,14 +1270,14 @@ namespace DM_Weight.Port
canBusSerial.DiscardInBuffer();
var channel = Convert.ToInt32((DrawerNo * 10 + 1).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x28, 0x00, 0x00, 0x00, 0x00, 0xee };
- logger.Info($"称重发送库位数量查询1【{string.Join(",", buffer)}】");
+ logger.Info($"称重发送库位数量查询1【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
byte[] result1 = await GetBufferByPort(canBusSerial, 8);
var channel2 = Convert.ToInt32((DrawerNo * 10 + 2).ToString(), 16);
byte[] buffer2 = new byte[] { 0xaa, (byte)(channel2), 0x28, 0x00, 0x00, 0x00, 0x00, 0xee };
- logger.Info($"称重发送库位数量查询2【{string.Join(",", buffer2)}】");
+ logger.Info($"称重发送库位数量查询2【{Convert.ToHexString(buffer2)}】");
canBusSerial.Write(buffer2, 0, 8);
byte[] result2 = await GetBufferByPort(canBusSerial, 8);
@@ -1221,10 +1303,10 @@ namespace DM_Weight.Port
var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x27, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
- logger.Info($"称重发送库位数量查询1【{string.Join(",", buffer)}】");
+ logger.Info($"称重发送库位数量查询1【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
byte[] result = await GetBufferByPort(canBusSerial, 8);
- logger.Info($"称重发送库位数量查询1返回结果【{string.Join(",", result)}】");
+ logger.Info($"称重发送库位数量查询1返回结果【{Convert.ToHexString(result)}】");
byte[] hl = result.Skip(3).Take(2).ToArray();
int quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
res[ColNos[i] - 1] = quantity;
@@ -1243,7 +1325,7 @@ namespace DM_Weight.Port
var lock1 = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x03, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
- logger.Info($"称重发送药盒使能【{string.Join(",", buffer)}】");
+ logger.Info($"称重发送药盒使能【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(TimeSpan.FromMilliseconds(500));
}
@@ -1258,7 +1340,7 @@ namespace DM_Weight.Port
var lock1 = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x04, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
- logger.Info($"称重发送药盒失能【{string.Join(",", buffer)}】");
+ logger.Info($"称重发送药盒失能【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(TimeSpan.FromMilliseconds(50));
}
@@ -1274,7 +1356,7 @@ namespace DM_Weight.Port
var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x25, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
- logger.Info($"称重发送清空计数【{string.Join(",", buffer)}】");
+ logger.Info($"称重发送清空计数【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
}
catch (Exception ex)
@@ -1305,7 +1387,7 @@ namespace DM_Weight.Port
buffer[5] = (byte)(Quantity & 0xff);
- logger.Info($"称重发送数量【{string.Join(",", buffer)}】");
+ logger.Info($"称重发送数量【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
}
catch (Exception ex)
diff --git a/DM_Weight/Report/GridReportUtil.cs b/DM_Weight/Report/GridReportUtil.cs
index e4b3aad..ed7148b 100644
--- a/DM_Weight/Report/GridReportUtil.cs
+++ b/DM_Weight/Report/GridReportUtil.cs
@@ -53,7 +53,32 @@ namespace DM_Weight.Report
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(true);
}
- public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate,string drug_id)
+ ///
+ /// 导出盘点后库存信息
+ ///
+ ///
+ ///
+ public static void PrintReportStockNew(DateTime? startDate, DateTime? endDate)
+ {
+ DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
+ DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
+ // 定义Grid++Report报表主对象
+ GridppReport Report = new GridppReport();
+ //Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() =>
+ //{
+ // Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
+ //});
+ string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
+ string SQL = $@"SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
+ `drug_name` AS drugName,`drug_spec` AS drugSpec,`pack_unit` AS packUnit,`manufactory` AS manuFactory,`max_stock` AS baseQuantity,
+ cl.`drug_id` AS drugId,cl.manuquantity, cl.`optdate` FROM check_stock cl WHERE cl.`machine_id` = '{machine_id}' AND cl.`optdate` > '{p_startDate}' AND cl.`optdate` < '{p_endDate}' ORDER BY cl.`optdate` desc, cl.`drug_id`";
+ // 加载模板文件
+ Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_check_new2.grf");
+ Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
+ Report.DetailGrid.Recordset.QuerySQL = SQL;
+ Report.PrintPreview(true);
+ }
+ public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate,int type,string drug_id)
{
DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
@@ -71,19 +96,36 @@ namespace DM_Weight.Report
Report.ParameterByName("endDate").Value = endDate ?? DateTime.Now.AddDays(1);
});
//Report.DetailGrid.Recordset.QuerySQL = SQL;
- SQL = $@"SELECT mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
+ SQL = $@"SELECT TYPE, stockQuantity,inQuantity,outQuantity,operationTime,invoiceId,drugName,drugId,drugSpec,packUnit,dosage,manufactory,manuNo,effDate,
+ operatorName,reviewerName,supplierDept,receiveDept,bigUnit FROM
+ (SELECT mr.type, mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0)) AS `outQuantity`,
mr.`operation_time` AS `operationTime`,IF(mr.`type`=1,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
- di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`,
- mr.`manu_no` AS `manuNo`, mr.`eff_date` AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName` FROM
+ di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`,di.big_unit as bigUnit, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`,
+ mr.`manu_no` AS `manuNo`, mr.`eff_date` AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName`,mr.supplierDept,mr.receiveDept FROM
dm_machine_record mr LEFT JOIN drug_info di ON mr.`drug_id` = di.`drug_id` LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`
LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id` WHERE mr.`machine_id` = '{p_machine_id}' AND mr.`operation_time` > '{p_startDate}'
- AND mr.`operation_time` < '{p_endDate}' ";
+ AND mr.`operation_time` < '{p_endDate}' and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999 ";
if(!string.IsNullOrEmpty(drug_id))
{
SQL+= " AND mr.drug_id='"+ drug_id+"' ";
}
- SQL+="ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`";
+ SQL+= " ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`) AS T";
+ if (type > 0)
+ {
+ if (type == 1)
+ {
+ SQL += " WHERE inQuantity>0 ";
+ }
+ if (type == 2)
+ {
+ SQL += " WHERE outQuantity>0 ";
+ }
+ if (type == 5)
+ {
+ SQL += " WHERE type=5 ";
+ }
+ }
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(true);
}
@@ -203,5 +245,25 @@ namespace DM_Weight.Report
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(true);
}
+
+ ///
+ /// 盘点页面导出记录,按选中行进行导出
+ ///
+ ///
+ ///
+ ///
+ public static void PrintReportMechineRecordForSelect(List data)
+ {
+ // 定义Grid++Report报表主对象
+ GridppReport Report = new GridppReport();
+ // 加载模板文件
+ Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//machine_log_check.grf");
+ Dictionary> records = new Dictionary>();
+ records.Add("table", data);
+ string str= JsonConvert.SerializeObject(records);
+ Report.LoadDataFromXML(str);
+ // 加载数据
+ Report.PrintPreview(true);
+ }
}
}
diff --git a/DM_Weight/ReportTemp/account_book_temp.grf b/DM_Weight/ReportTemp/account_book_temp.grf
index 50a66eb..d509b10 100644
--- a/DM_Weight/ReportTemp/account_book_temp.grf
+++ b/DM_Weight/ReportTemp/account_book_temp.grf
@@ -15,7 +15,6 @@
},
"DetailGrid":{
"CenterView":true,
- "AppendBlankRow":true,
"Recordset":{
"Field":[
{
@@ -75,7 +74,7 @@
},
{
"Name":"单位",
- "DBFieldName":"packUnit"
+ "DBFieldName":"bigUnit"
},
{
"Name":"剂型",
@@ -105,6 +104,14 @@
{
"Name":"凭证号",
"DBFieldName":"invoiceId"
+ },
+ {
+ "Name":"供应单位",
+ "DBFieldName":"supplierDept"
+ },
+ {
+ "Name":"领用部门",
+ "DBFieldName":"receiveDept"
}
]
},
@@ -222,11 +229,11 @@
"FreeCell":true,
"Control":[
{
- "Type":"StaticBox",
- "Name":"StaticBox6",
+ "Type":"FieldBox",
+ "Name":"FieldBox14",
"Dock":"Fill",
"TextAlign":"MiddleCenter",
- "Text":"药库"
+ "DataField":"供应单位"
}
]
},
@@ -235,11 +242,11 @@
"FreeCell":true,
"Control":[
{
- "Type":"StaticBox",
- "Name":"StaticBox7",
+ "Type":"FieldBox",
+ "Name":"FieldBox15",
"Dock":"Fill",
"TextAlign":"MiddleCenter",
- "Text":"门诊药房11"
+ "DataField":"领用部门"
}
]
}
diff --git a/DM_Weight/ReportTemp/machine_log_add.grf b/DM_Weight/ReportTemp/machine_log_add.grf
index bf9031e..4542aee 100644
--- a/DM_Weight/ReportTemp/machine_log_add.grf
+++ b/DM_Weight/ReportTemp/machine_log_add.grf
@@ -13,7 +13,6 @@
},
"DetailGrid":{
"CenterView":true,
- "AppendBlankRow":true,
"Recordset":{
"QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n dmr.`quantity` AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 1 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
"Field":[
diff --git a/DM_Weight/ReportTemp/machine_log_check.grf b/DM_Weight/ReportTemp/machine_log_check.grf
index 8521095..f909608 100644
--- a/DM_Weight/ReportTemp/machine_log_check.grf
+++ b/DM_Weight/ReportTemp/machine_log_check.grf
@@ -13,7 +13,6 @@
},
"DetailGrid":{
"CenterView":true,
- "AppendBlankRow":true,
"Recordset":{
"QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n dmr.`quantity` AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 4 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
"Field":[
@@ -60,6 +59,10 @@
"Name":"type2",
"Type":"Integer",
"DBFieldName":"type"
+ },
+ {
+ "Name":"规格",
+ "DBFieldName":"drugSpec"
}
]
},
@@ -80,6 +83,10 @@
"Name":"药品名称",
"Width":4.63021
},
+ {
+ "Name":"规格",
+ "Width":1.69333
+ },
{
"Name":"数量",
"Width":1.98438
@@ -119,6 +126,10 @@
"TextAlign":"MiddleCenter",
"DataField":"药品名称"
},
+ {
+ "Column":"规格",
+ "DataField":"规格"
+ },
{
"Column":"数量",
"TextAlign":"MiddleCenter",
@@ -210,6 +221,18 @@
"TextAlign":"MiddleCenter",
"Text":"药品名称"
},
+ {
+ "GroupTitle":false,
+ "Column":"规格",
+ "Font":{
+ "Name":"宋体",
+ "Size":120000,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"规格"
+ },
{
"GroupTitle":false,
"Column":"数量",
diff --git a/DM_Weight/ReportTemp/machine_log_check_new.grf b/DM_Weight/ReportTemp/machine_log_check_new.grf
new file mode 100644
index 0000000..c666ba5
--- /dev/null
+++ b/DM_Weight/ReportTemp/machine_log_check_new.grf
@@ -0,0 +1,313 @@
+{
+ "Version":"6.3.0.1",
+ "Font":{
+ "Name":"宋体",
+ "Size":105000,
+ "Weight":400,
+ "Charset":134
+ },
+ "Printer":{
+ "Oriention":"Landscape"
+ },
+ "DetailGrid":{
+ "CenterView":true,
+ "PrintAdaptMethod":"ResizeToFit",
+ "Recordset":{
+ "QuerySQL":"SELECT \r\n cl.`row_no` AS drawerNo,\r\n cl.`col_no` AS colNo,\r\n cl.`quantity` AS quantity,\r\n cl.`manu_no` AS manuNo,\r\n cl.`eff_date` AS effDate,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n cl.`drug_id` AS drugId\r\nFROM\r\n channel_stock cl\r\nINNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id`\r\nWHERE cl.`machine_id` = :machine_id\r\n AND cl.`drawer_type` = 1\r\n ORDER BY cl.`drug_id`",
+ "Field":[
+ {
+ "Name":"drugName"
+ },
+ {
+ "Name":"drugSpec"
+ },
+ {
+ "Name":"manuFactory"
+ },
+ {
+ "Name":"quantityCount",
+ "Type":"Integer"
+ },
+ {
+ "Name":"manuNo"
+ },
+ {
+ "Name":"effDate"
+ },
+ {
+ "Name":"quantity",
+ "Type":"Integer",
+ "Format":"0"
+ },
+ {
+ "Name":"drawerNo"
+ },
+ {
+ "Name":"drugId"
+ },
+ {
+ "Name":"baseQuantity",
+ "Type":"Integer"
+ },
+ {
+ "Name":"manuquantity",
+ "Type":"Integer"
+ },
+ {
+ "Name":"optDate",
+ "DBFieldName":"optdate"
+ }
+ ]
+ },
+ "Column":[
+ {
+ "Name":"optDate",
+ "Width":4.20688
+ },
+ {
+ "Name":"drugName",
+ "Width":4.57729
+ },
+ {
+ "Name":"drugSpec"
+ },
+ {
+ "Name":"manuFactory",
+ "Width":4.60375
+ },
+ {
+ "Name":"quantityCount",
+ "Width":2.19604
+ },
+ {
+ "Name":"manuNo"
+ },
+ {
+ "Name":"effDate",
+ "Width":2.61938
+ },
+ {
+ "Name":"quantity",
+ "Width":1.42875
+ }
+ ],
+ "ColumnContent":{
+ "Height":0.79375,
+ "ColumnContentCell":[
+ {
+ "Column":"optDate",
+ "DataField":"optDate"
+ },
+ {
+ "Column":"drugName",
+ "TextAlign":"MiddleCenter",
+ "DataField":"drugName"
+ },
+ {
+ "Column":"drugSpec",
+ "TextAlign":"MiddleCenter",
+ "DataField":"drugSpec"
+ },
+ {
+ "Column":"manuFactory",
+ "TextAlign":"MiddleCenter",
+ "DataField":"manuFactory"
+ },
+ {
+ "Column":"quantityCount",
+ "FreeCell":true,
+ "Control":[
+ {
+ "Type":"MemoBox",
+ "Name":"MemoBox1",
+ "Dock":"Fill",
+ "Text":"[#Sum(manuquantity)#]"
+ }
+ ]
+ },
+ {
+ "Column":"manuNo",
+ "TextAlign":"MiddleCenter",
+ "DataField":"manuNo"
+ },
+ {
+ "Column":"effDate",
+ "TextAlign":"MiddleCenter",
+ "DataField":"effDate"
+ },
+ {
+ "Column":"quantity",
+ "TextAlign":"MiddleCenter",
+ "DataField":"manuquantity"
+ }
+ ]
+ },
+ "ColumnTitle":{
+ "Height":1.19063,
+ "RepeatStyle":"OnPage",
+ "ColumnTitleCell":[
+ {
+ "GroupTitle":false,
+ "Column":"optDate",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"盘点日期"
+ },
+ {
+ "GroupTitle":false,
+ "Column":"drugName",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"药品名称"
+ },
+ {
+ "GroupTitle":false,
+ "Column":"drugSpec",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"规格"
+ },
+ {
+ "GroupTitle":false,
+ "Column":"manuFactory",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"厂家"
+ },
+ {
+ "GroupTitle":false,
+ "Column":"quantityCount",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"总库存"
+ },
+ {
+ "GroupTitle":false,
+ "Column":"manuNo",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"批次"
+ },
+ {
+ "GroupTitle":false,
+ "Column":"effDate",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"效期"
+ },
+ {
+ "GroupTitle":false,
+ "Column":"quantity",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"数量"
+ }
+ ]
+ },
+ "Group":[
+ {
+ "Name":"Group2",
+ "ByFields":"optDate",
+ "GroupHeader":{
+ "Height":0.635,
+ "OccupyColumn":true,
+ "OccupiedColumns":"optDate",
+ "VAlign":"Middle"
+ },
+ "GroupFooter":{
+ "Visible":false,
+ "Height":0
+ }
+ },
+ {
+ "Name":"drugId",
+ "ByFields":"drugId",
+ "GroupHeader":{
+ "Visible":false,
+ "Height":0.79375,
+ "RepeatOnPage":true,
+ "OccupyColumn":true,
+ "IncludeFooter":true,
+ "OccupiedColumns":"drugName;drugSpec;manuFactory;quantityCount",
+ "VAlign":"Middle"
+ },
+ "GroupFooter":{
+ "Visible":false,
+ "Height":0
+ }
+ }
+ ]
+ },
+ "Parameter":[
+ {
+ "Name":"machine_id",
+ "Value":"DM1"
+ }
+ ],
+ "ReportHeader":[
+ {
+ "Name":"ReportHeader1",
+ "Height":2.40771,
+ "Control":[
+ {
+ "Type":"StaticBox",
+ "Name":"StaticBox1",
+ "Center":"Horizontal",
+ "Left":8.22854,
+ "Top":0.608542,
+ "Width":9.18104,
+ "Height":1.21708,
+ "Font":{
+ "Name":"宋体",
+ "Size":217500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"毒麻药品盘点后库存信息"
+ }
+ ],
+ "RepeatOnPage":true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/DM_Weight/ReportTemp/machine_log_check_new2.grf b/DM_Weight/ReportTemp/machine_log_check_new2.grf
new file mode 100644
index 0000000..4de9e86
--- /dev/null
+++ b/DM_Weight/ReportTemp/machine_log_check_new2.grf
@@ -0,0 +1,278 @@
+{
+ "Version":"6.3.0.1",
+ "Font":{
+ "Name":"宋体",
+ "Size":105000,
+ "Weight":400,
+ "Charset":134
+ },
+ "Printer":{
+ "LeftMargin":1,
+ "TopMargin":1,
+ "RightMargin":1,
+ "BottomMargin":1
+ },
+ "DetailGrid":{
+ "Recordset":{
+ "Field":[
+ {
+ "Name":"盘点日期",
+ "DBFieldName":"optDate"
+ },
+ {
+ "Name":"药品名称",
+ "DBFieldName":"drugName"
+ },
+ {
+ "Name":"drugId"
+ },
+ {
+ "Name":"规格",
+ "DBFieldName":"drugSpec"
+ },
+ {
+ "Name":"厂家",
+ "DBFieldName":"manuFactory"
+ },
+ {
+ "Name":"总库存",
+ "DBFieldName":"quantity"
+ },
+ {
+ "Name":"批次",
+ "DBFieldName":"manuNo"
+ },
+ {
+ "Name":"效期",
+ "DBFieldName":"effDate"
+ },
+ {
+ "Name":"数量",
+ "DBFieldName":"manuquantity"
+ }
+ ]
+ },
+ "Column":[
+ {
+ "Name":"盘点日期",
+ "Width":2.56646
+ },
+ {
+ "Name":"药品名称",
+ "Width":2.80458
+ },
+ {
+ "Name":"规格",
+ "Width":2.01083
+ },
+ {
+ "Name":"厂家",
+ "Width":2.98979
+ },
+ {
+ "Name":"总库存",
+ "Width":1.69333
+ },
+ {
+ "Name":"批次",
+ "Width":2.06375
+ },
+ {
+ "Name":"效期",
+ "Width":2.19604
+ },
+ {
+ "Name":"数量",
+ "Width":1.69333
+ }
+ ],
+ "ColumnContent":{
+ "Height":0.79375,
+ "ColumnContentCell":[
+ {
+ "Column":"盘点日期",
+ "DataField":"盘点日期"
+ },
+ {
+ "Column":"药品名称",
+ "DataField":"药品名称"
+ },
+ {
+ "Column":"规格",
+ "DataField":"规格"
+ },
+ {
+ "Column":"厂家",
+ "DataField":"厂家"
+ },
+ {
+ "Column":"总库存",
+ "DataField":"总库存"
+ },
+ {
+ "Column":"批次",
+ "DataField":"批次"
+ },
+ {
+ "Column":"效期",
+ "DataField":"效期"
+ },
+ {
+ "Column":"数量",
+ "DataField":"数量"
+ }
+ ]
+ },
+ "ColumnTitle":{
+ "Height":1.19063,
+ "RepeatStyle":"OnPage",
+ "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":"规格",
+ "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":"总库存"
+ },
+ {
+ "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":"数量",
+ "Font":{
+ "Name":"宋体",
+ "Size":142500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"数量"
+ }
+ ]
+ },
+ "Group":[
+ {
+ "Name":"Group1",
+ "ByFields":"盘点日期",
+ "GroupHeader":{
+ "Height":0.635,
+ "OccupyColumn":true,
+ "OccupiedColumns":"盘点日期",
+ "VAlign":"Middle"
+ },
+ "GroupFooter":{
+ "Height":0
+ }
+ },
+ {
+ "Name":"Group2",
+ "ByFields":"drugId",
+ "GroupHeader":{
+ "Height":0.635,
+ "OccupyColumn":true,
+ "OccupiedColumns":"药品名称;厂家;规格;总库存",
+ "VAlign":"Middle"
+ },
+ "GroupFooter":{
+ "Height":0
+ }
+ }
+ ]
+ },
+ "ReportHeader":[
+ {
+ "Name":"ReportHeader1",
+ "Height":1.32292,
+ "Control":[
+ {
+ "Type":"MemoBox",
+ "Name":"MemoBox1",
+ "Dock":"Fill",
+ "Font":{
+ "Name":"宋体",
+ "Size":157500,
+ "Bold":true,
+ "Charset":134
+ },
+ "TextAlign":"MiddleCenter",
+ "Text":"毒麻药品盘点后库存信息"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/DM_Weight/ReportTemp/machine_log_return.grf b/DM_Weight/ReportTemp/machine_log_return.grf
index 493f661..f02bef4 100644
--- a/DM_Weight/ReportTemp/machine_log_return.grf
+++ b/DM_Weight/ReportTemp/machine_log_return.grf
@@ -13,7 +13,6 @@
},
"DetailGrid":{
"CenterView":true,
- "AppendBlankRow":true,
"Recordset":{
"QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n CONCAT(dmr.`quantity`,IF(dmr.`type`=32,\"(空瓶)\",\"\")) AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` in (31, 32)\r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
"Field":[
diff --git a/DM_Weight/ReportTemp/machine_log_take.grf b/DM_Weight/ReportTemp/machine_log_take.grf
index 32fe037..d0d31a4 100644
--- a/DM_Weight/ReportTemp/machine_log_take.grf
+++ b/DM_Weight/ReportTemp/machine_log_take.grf
@@ -13,7 +13,6 @@
},
"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":[
diff --git a/DM_Weight/ReportTemp/stock_template.grf b/DM_Weight/ReportTemp/stock_template.grf
index 6a2d5fb..2b53449 100644
--- a/DM_Weight/ReportTemp/stock_template.grf
+++ b/DM_Weight/ReportTemp/stock_template.grf
@@ -12,7 +12,6 @@
"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":[
diff --git a/DM_Weight/Services/ChannelStockService.cs b/DM_Weight/Services/ChannelStockService.cs
new file mode 100644
index 0000000..a871464
--- /dev/null
+++ b/DM_Weight/Services/ChannelStockService.cs
@@ -0,0 +1,37 @@
+using DM_Weight.Models;
+using DM_Weight.util;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Services
+{
+ public class ChannelStockService
+ {
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ //public ChannelStockService(SqlSugarScope sqlSugarScope)
+ //{
+ // //this.SqlSugarHelper.Db = sqlSugarScope;
+ //}
+ public List GetAll()
+ {
+ string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
+ string SQL = $@"SELECT CS.drug_id as DrugId,CS.manu_no as ManuNo,sum(quantity) as Quantity,CS.eff_date as EffDate,DI.drug_name as DrugName,
+ DI.drug_spec as DrugSpec,DI.dosage as Dosage,DI.manufactory as ManuFactory,DI.small_unit as SmallUnit,DI.pack_unit as PackUnit,
+ CS.machine_id as MachineId FROM channel_stock CS
+ INNER JOIN drug_info DI ON CS.drug_id=DI.drug_id where CS.machine_id='{p_machine_id}' AND quantity>0 GROUP BY CS.drug_id,CS.manu_no ";
+
+ List accountList = SqlSugarHelper.Db.SqlQueryable(SQL).ToList();
+ //List accountList = SqlSugarHelper.Db.Queryable().Includes(cs=>cs.DrugInfo)
+ // .GroupBy(cs=>new { cs.DrugId, cs.ManuNo })
+ // .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"]??"DM1"))
+ // .Where(cs=>cs.Quantity>0)
+ // .ToList();
+ return accountList;
+ }
+ }
+}
diff --git a/DM_Weight/Services/MachineRecordService.cs b/DM_Weight/Services/MachineRecordService.cs
new file mode 100644
index 0000000..2809a39
--- /dev/null
+++ b/DM_Weight/Services/MachineRecordService.cs
@@ -0,0 +1,79 @@
+using DM_Weight.Models;
+using DM_Weight.util;
+using DM_Weight.Views.Dialog;
+using gregn6Lib;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Services
+{
+ ///
+ /// 账册服务类
+ ///
+ public class MachineRecordService
+ {
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ public MachineRecordService()
+ {
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
+ }
+ public List ReportAccountBook(DateTime? startDate, DateTime? endDate,int type, string drug_id="")
+ {
+ DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
+ DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
+ string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
+ string SQL = $@"SELECT TYPE, stockQuantity,inQuantity,outQuantity,operationTime,invoiceId,drugName,drugId,drugSpec,packUnit,dosage,manufactory,manuNo,effDate,
+ operatorName,reviewerName,supplierDept,receiveDept FROM
+ (SELECT mr.type,mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
+ AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0)) AS `outQuantity`,
+ DATE_FORMAT(mr.`operation_time`,'%m/%d') AS `operationTime`,IF(mr.`type`=1,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
+ di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`,
+ mr.`manu_no` AS `manuNo`, DATE_FORMAT(mr.`eff_date`,'%y/%m/%d') AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName`,mr.supplierDept,mr.receiveDept FROM
+ dm_machine_record mr LEFT JOIN drug_info di ON mr.`drug_id` = di.`drug_id` LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`
+ LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id` WHERE mr.`machine_id` = '{p_machine_id}' AND mr.`operation_time` > '{p_startDate}'
+ AND mr.`operation_time` < '{p_endDate}' and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999 ";
+ if (!string.IsNullOrEmpty(drug_id))
+ {
+ SQL += " AND mr.drug_id='" + drug_id + "' ";
+ }
+ SQL += " ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`) AS T";
+ if(type>0)
+ {
+ if(type==1)
+ {
+ SQL += " WHERE inQuantity>0 ";
+ }
+ if(type==2)
+ {
+ SQL += " WHERE outQuantity>0 ";
+ }
+ if(type==5)
+ {
+ SQL += " WHERE type=5 ";
+ }
+ }
+
+
+ //ChannelStocks = q.Select(it => { it.CheckQuantity = it.Quantity; return it; }).ToList();
+
+ List accountList = SqlSugarHelper.Db.SqlQueryable(SQL)
+ .AddParameters(new
+ {
+ machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
+ })
+ //.Select(it => new { o = new AccountModel(), i = new DrugInfo() })
+ //.Select(it=>new AccountModel())
+ //.Select("*") //让上面一行不生成sql
+ .ToList();
+
+ //List accountList=new List();
+ return accountList;
+ }
+ }
+}
diff --git a/DM_Weight/Services/UserService.cs b/DM_Weight/Services/UserService.cs
new file mode 100644
index 0000000..4d457a4
--- /dev/null
+++ b/DM_Weight/Services/UserService.cs
@@ -0,0 +1,54 @@
+using DM_Weight.Models;
+using MySqlConnector;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.Services
+{
+ public class UserService
+ {
+ //public static string connStr = ConfigurationManager.AppSettings["database"].ToString();
+ public static string connStr = ConfigurationManager.ConnectionStrings["database"].ToString();
+ public UserList CheckUserByFingerPrinter(int fingerPrinterId)
+ {
+ UserList? user = null;
+
+ using (MySqlConnection con = new MySqlConnection(connStr))
+ {
+ con.Open();
+ string sql = @"select ul.id as id,ul.User_name as userName,r.id,r.role_name,r.permissions,r.machine_id from user_list ul
+ INNER JOIN role r on ul.machine_role_id=r.id where ul.Id=@ID and ul.machine_id=@machine_id and r.machine_id=@machine_id;";
+ MySqlCommand cmd = new MySqlCommand(sql, con);
+ cmd.Parameters.Clear();
+ MySqlParameter[] mySqlParameter = new MySqlParameter[] {new MySqlParameter("ID", fingerPrinterId),new MySqlParameter("machine_id", (ConfigurationManager.AppSettings["machineId"] ?? "DM1")) };
+ cmd.Parameters.AddRange(mySqlParameter);
+ //执行语句
+ MySqlDataReader reader = cmd.ExecuteReader();
+ while (reader.Read())
+ {
+ user = new UserList();
+ user.Id = reader.GetInt32("id");
+ user.UserName = reader["userName"] is DBNull ? "" : reader.GetString("userName");
+ //user.UserName = reader["id"] is DBNull ? "" : reader.GetString("id");
+ user.Nickname= reader["userName"] is DBNull ? "" : reader.GetString("userName");
+ user.MachineId = reader["machine_id"] is DBNull ? "" : reader.GetString("machine_id");
+ RoleDm role= new RoleDm();
+ role.Id= reader.GetInt32("id");
+ //role.Permissions = reader["permissions"] is DBNull ? "" : reader.GetString("permissions");
+ role.RoleName = reader["role_name"] is DBNull ? "" : reader.GetString("role_name");
+ role.Permissions = JsonConvert.DeserializeObject>(reader["permissions"] is DBNull ? "" : reader.GetString("permissions")); // JsonConvert.SerializeObject(reader.GetString("permissions")).ToList();
+ user.Role = role;
+ }
+ reader.Close();
+
+ return user;
+ }
+
+ }
+ }
+}
diff --git a/DM_Weight/ViewModels/AccountWindowViewModel.cs b/DM_Weight/ViewModels/AccountWindowViewModel.cs
new file mode 100644
index 0000000..848db2f
--- /dev/null
+++ b/DM_Weight/ViewModels/AccountWindowViewModel.cs
@@ -0,0 +1,414 @@
+using DM_Weight.Models;
+using DM_Weight.msg;
+using DM_Weight.Report;
+using DM_Weight.Services;
+using DM_Weight.util;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Configuration;
+using System.Drawing.Printing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace DM_Weight.ViewModels
+{
+ public class AccountWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
+ {
+ public static AccountWindowViewModel vm;
+ //private int _pageNum = 1;
+ //public int PageNum
+ //{
+ // get => _pageNum;
+ // set
+ // {
+ // SetProperty(ref _pageNum, value);
+ // RequestData();
+ // }
+ //}
+
+ //private int _pageCount = 1;
+ //public int PageCount
+ //{
+ // get => _pageCount;
+ // set
+ // {
+ // SetProperty(ref _pageCount, value);
+ // }
+ //}
+
+ //private int _pageSize = 8;
+ //public int PageSize
+ //{
+ // get => _pageSize;
+ // set
+ // {
+ // SetProperty(ref _pageSize, value);
+ // }
+ //}
+
+ //private int _totalCount = 0;
+ //public int TotalCount
+ //{
+ // get => _totalCount;
+ // set
+ // {
+ // SetProperty(ref _totalCount, value);
+ // }
+ //}
+ private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
+
+ private DateTime? nowDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
+
+ public DateTime? StartDate
+ {
+ get => _startDate;
+ set
+ {
+ if (value != null)
+ {
+ SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
+ }
+ else
+ {
+ SetProperty(ref _startDate, value);
+ }
+ RequestData();
+ }
+ }
+
+ private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
+
+ public DateTime? EndDate
+ {
+ get => _endDate;
+ set
+ {
+ if (value != null)
+ {
+ TimeSpan ershisi = new TimeSpan(23, 59, 59);
+ SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
+ }
+ else
+ {
+ SetProperty(ref _endDate, value);
+ }
+
+ RequestData();
+ }
+ }
+ private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ ///
+ /// 账册
+ ///
+ private List _accountList = new();
+
+ public List AccountList
+ {
+ get => _accountList;
+ set => SetProperty(ref _accountList, value);
+ }
+ ///
+ /// 药品
+ ///
+ private List? _drugInfos;
+
+ public List? DrugInfos
+ {
+ get => _drugInfos;
+ set => SetProperty(ref _drugInfos, value);
+ }
+ private DrugInfo? _drugInfo;
+
+ public DrugInfo? DrugInfo
+ {
+ get => _drugInfo;
+ set
+ {
+ SetProperty(ref _drugInfo, value);
+ //if (_drugInfo != null)
+ //{
+ //DrugManuNos = _drugInfo.DrugManuNos.OrderByDescending(dm => dm.ManuNo).ToList();
+ //}
+ RequestData();
+ }
+ }
+ ///
+ /// 账册类型1入2出3总结存
+ ///
+ private List _accountTypeList = new List() {
+ new AccountType
+ {
+ AccountTypeName="借入",
+ AccountTypeValue=1
+ },
+ new AccountType
+ {
+ AccountTypeName="发出",
+ AccountTypeValue=2
+ },
+ new AccountType
+ {
+ AccountTypeName="日结存",
+ AccountTypeValue=5
+ }
+ };
+ public List? AccountTypeList
+ {
+ get => _accountTypeList;
+ set
+ {
+ SetProperty(ref _accountTypeList, value);
+ RequestData();
+ }
+ }
+ private AccountType? _accountType;
+ public AccountType AccountType
+ {
+ get => _accountType;
+ set
+ {
+ SetProperty(ref _accountType, value);
+ RequestData();
+ }
+ }
+
+ MachineRecordService _machineRecordService;
+ ChannelStockService _channelStockService;
+ IEventAggregator _eventAggregator;
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ public AccountWindowViewModel(MachineRecordService machineRecord, ChannelStockService channelStockService, IEventAggregator eventAggregator)
+ {
+ _machineRecordService = machineRecord;
+ _channelStockService = channelStockService;
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
+ _eventAggregator = eventAggregator;
+ vm = this;
+ }
+ void RequestData()
+ {
+ int totalCount = 0;
+ AccountList = _machineRecordService.ReportAccountBook(StartDate, EndDate, AccountType == null ? 0 : AccountType.AccountTypeValue, DrugInfo == null ? "" : DrugInfo.DrugId ?? "");
+ //for (int i = 0; i < accountList.Count; i++)
+ //{
+ // if (accountList[i].DrugInfo is null)
+ // {
+ // DrugInfo drug= new DrugInfo();
+ // drug.DrugId = accountList[i].DrugId;
+ // drug.DrugName = accountList[i].DrugName;
+ // drug.DrugSpec = accountList[i].DrugSpec;
+ // drug.Dosage= accountList[i].Dosage;
+ // drug.PackUnit= accountList[i].PackUnit;
+ // drug.Manufactory= accountList[i].Manufactory;
+ // accountList[i].DrugInfo= drug;
+ // }
+ //}
+ //ICollectionView vw = CollectionViewSource.GetDefaultView(accountList);
+ //vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo"));
+
+ }
+ private void GetAllDrugInfos()
+ {
+ var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
+ DrugInfos = list;
+ DrugInfo = list[0];
+ }
+
+ ///
+ /// 生成日结存
+ ///
+ public DelegateCommand DayAccountBook
+ {
+ get => new DelegateCommand(() =>
+ {
+ DayAccountAction();
+ RequestData();
+ });
+ }
+ //生成一条当日没有记录的账册记录
+ private void DayAccountAction()
+ {
+ try
+ {
+
+ //查询账册中所有记录,与库存中的记录做比校,如果账册中没有,则添加一条
+ List accountList = _machineRecordService.ReportAccountBook(nowDate, null, 0);
+ //库存中的记录
+ List channelStockList = _channelStockService.GetAll();
+ //List channelStockInsert = new List();
+ if (accountList != null && accountList.Count() > 0)
+ {
+ //账册中有记录则与库存记录对比
+
+ for (int i = 0; i < channelStockList.Count; i++)
+ {
+ int Count = accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId && cs.ManuNo == channelStockList[i].ManuNo).Count();
+ if (Count <= 0)
+ {
+ //没有直接插入
+ // 保存数据 出/入库记录
+ string InvoiceId = "Account_" + CurrentTimeMillis();
+ SqlSugarHelper.Db.Insertable(new MachineRecord()
+ {
+ MachineId = channelStockList[i].MachineId,
+ DrawerNo = 0,//channelStockList[i].DrawerNo,
+ ColNo = 0,// channelStockList[i].ColNo,FV
+ DrugId = channelStockList[i].DrugId,
+ ManuNo = channelStockList[i].ManuNo,
+ EffDate = !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ Operator = HomeWindowViewModel.Operator?.Id,
+ Reviewer = HomeWindowViewModel.Reviewer?.Id,
+ OperationTime = DateTime.Now,
+ Quantity = 0,
+ Type = 5,
+ InvoiceId = string.Empty,//InvoiceId,
+ StockQuantity = channelStockList[i].Quantity,
+ ManunoQuantity = 0,
+ SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
+ ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
+ }).ExecuteCommand();
+
+ }
+ }
+ }
+ else
+ {
+ for (int i = 0; i < channelStockList.Count; i++)
+ {
+ //账册中没有记录则把库存中的所有数据都要生成一条账册记录
+ // 保存数据 出/入库记录
+ string InvoiceId = "Account_" + CurrentTimeMillis();
+ SqlSugarHelper.Db.Insertable(new MachineRecord()
+ {
+ MachineId = channelStockList[i].MachineId,
+ DrawerNo = 0,//channelStockList[i].DrawerNo,
+ ColNo = 0,//channelStockList[i].ColNo,
+ DrugId = channelStockList[i].DrugId,
+ ManuNo = channelStockList[i].ManuNo,
+ EffDate = !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ Operator = HomeWindowViewModel.Operator?.Id,
+ Reviewer = HomeWindowViewModel.Reviewer?.Id,
+ OperationTime = DateTime.Now,
+ Quantity = 0,
+ Type = 5,
+ InvoiceId = string.Empty,//InvoiceId,
+ StockQuantity = channelStockList[i].Quantity,
+ ManunoQuantity = 0,
+ SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
+ ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
+ }).ExecuteCommand();
+ }
+ }
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "日结存已生成完成",
+ Type = MsgType.SUCCESS,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ catch (Exception ex)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "生成日结存失败",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ RequestData();
+ }
+ public long CurrentTimeMillis()
+ {
+ return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
+ }
+ //public void InsertDayAccount()
+ //{
+ // // 保存数据 出/入库记录
+ // SqlSugarHelper.Db.Insertable(new MachineRecord()
+ // {
+ // MachineId = it.MachineId,
+ // DrawerNo = it.DrawerNo,
+ // ColNo = it.ColNo,
+ // DrugId = it.DrugId,
+ // ManuNo = it.ManuNo,
+ // EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ // Operator = HomeWindowViewModel.Operator?.Id,
+ // Reviewer = HomeWindowViewModel.Reviewer?.Id,
+ // OperationTime = DateTime.Now,
+ // Quantity = it.AddQuantity,
+ // Type = 1,
+ // InvoiceId = InvoiceId,
+ // StockQuantity = nowChannels.Sum(it => it.Quantity),
+ // ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
+ // SupplierDept = Invoice.PharmacyName1 ?? ConfigurationManager.AppSettings["supplierDept"].ToString(),
+ // ReceiveDept = Invoice.PharmacyName2 ?? ConfigurationManager.AppSettings["receiveDept"].ToString()
+ // }).ExecuteCommand();
+ //}
+ ///
+ /// 导出账册
+ ///
+ public DelegateCommand DownloadAccountBook
+ {
+ get => new DelegateCommand(() =>
+ {
+ GridReportUtil.PrintReportAccountBook(StartDate, EndDate, AccountType == null ? 0 : AccountType.AccountTypeValue, DrugInfo == null ? "" : DrugInfo.DrugId);
+
+ });
+ }
+ ///
+ /// 刷新
+ ///
+ public DelegateCommand Query
+ {
+ get => new DelegateCommand(() =>
+ {
+ RequestData();
+ });
+ }
+
+ public bool KeepAlive => true;
+
+ public void UpdateComboBoxItems(string text)
+ {
+ string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
+ d.manufactory,d.max_stock FROM `drug_info` d";
+ if (string.IsNullOrEmpty(text))
+ {
+ DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
+ return;
+ }
+ if (DrugInfos != null)
+ {
+ DrugInfos.Clear();
+ }
+
+ DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text) || di.DrugId.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
+
+ }
+
+ public void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ //药品信息
+ GetAllDrugInfos();
+ //查询表格数据
+ RequestData();
+ }
+
+ public bool IsNavigationTarget(NavigationContext navigationContext)
+ {
+ return true;
+ }
+
+ public void OnNavigatedFrom(NavigationContext navigationContext)
+ {
+ }
+
+ }
+}
diff --git a/DM_Weight/ViewModels/AddDrugControlViewModel.cs b/DM_Weight/ViewModels/AddDrugControlViewModel.cs
new file mode 100644
index 0000000..d6a90ed
--- /dev/null
+++ b/DM_Weight/ViewModels/AddDrugControlViewModel.cs
@@ -0,0 +1,545 @@
+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;
+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(AddDrugControlViewModel));
+ private List _drawerNoList = new List();
+ public static AddDrugControlViewModel vm;
+ //凭证号
+ private string _pzh;
+ public string PZH { get => _pzh; set { SetProperty(ref _pzh, value); } }
+
+ private List? _channelLsts;
+
+ public List? ChannelLsts
+ {
+ get => _channelLsts;
+ set => SetProperty(ref _channelLsts, value);
+ }
+ private List __channelStocks = new List();
+ public List 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;
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ public AddDrugControlViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator)
+ {
+ _dialogService = DialogService;
+ _portUtil = portUtil;
+ _eventAggregator = eventAggregator;
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
+ vm = this;
+ }
+ public DelegateCommand SelectionChangedCommand => new DelegateCommand(selectionAction);
+
+ private async void selectionAction()
+ {
+ if (CStock != null)
+ {
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("addManuno", CStock);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "AddManunoDialog", dialogParameters, DoDialogResult, "RootDialog");
+
+ }
+
+ }
+ private void DoDialogResult(IDialogResult dialogResult)
+ {
+ // 委托 被动执行 被子窗口执行
+ // dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
+ //if(dialogResult.Result == ButtonResult.OK)
+ //{
+ CStock = null;
+ RequestData();
+ //}
+ //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
+ }
+ void DoMyPrismEvent(DeviceMsg msg)
+ {
+ if (msg.WindowName == "AddDrugControl")
+ {
+ switch (msg.EventType)
+ {
+ // 抽屉打开
+ case EventType.DRAWEROPEN:
+ if (Status == 1)
+ {
+ Status = 2;
+ }
+
+ break;
+ // 抽屉关闭
+ case EventType.DRAWERCLOSE:
+ if (Status == 2)
+ {
+ Status = 3;
+ }
+ break;
+ // 数量变化
+ case EventType.UPDATEQUANTITY:
+ if (Status == 2)
+ {
+ //ChannelStocks.ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
+ }
+ break;
+ // 打开失败
+ case EventType.OPENERROR:
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = msg.Message,
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().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 UpdateDrawerNo
+ {
+ get => new DelegateCommand((DrawerNo) =>
+ {
+ this.DrawerNo = Convert.ToInt32(DrawerNo);
+ RequestData();
+ }, (DrawerNo) => Status == 0
+ );
+ }
+ public DelegateCommand OpenDrawer
+
+ {
+ get => new DelegateCommand(() =>
+ {
+ Status = 1;
+ _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
+
+ try
+ {
+ //List singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
+ List singleChannels = ChannelLsts.FindAll(it => it.BoardType != 1);
+
+ _portUtil.WindowName = "AddDrugControl";
+ _portUtil.Operate = true;
+ _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
+ _portUtil.ColNos = new int[] { };// 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 record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
+ if (record.Count > 0)
+ {
+ //string InvoiceId = "DRAWER_" + CurrentTimeMillis();
+ string InvoiceId = PZH;
+ //List repeatList = new List();
+ List stockRepeats = new List();
+ 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 csCount = SqlSugarHelper.Db.Queryable().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 nowChannels = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.MachineId.Equals(it.MachineId))
+ .Where(cs => cs.DrugId.Equals(it.DrugId))
+ .Where(cs => cs.DrawerType == 1)
+ .ToList();
+
+ // 保存数据 入库记录
+ SqlSugarHelper.Db.Insertable(new MachineRecord()
+ {
+ MachineId = it.MachineId,
+ DrawerNo = it.DrawerNo,
+ ColNo = it.ColNo,
+ DrugId = it.DrugId,
+ ManuNo = it.ManuNo,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ Operator = HomeWindowViewModel.Operator?.Id,
+ Reviewer= HomeWindowViewModel.Reviewer?.Id,
+ OperationTime = DateTime.Now,
+ Quantity = it.AddQuantity,
+ Type = 1,
+ InvoiceId = InvoiceId,
+ StockQuantity = nowChannels.Sum(it => it.Quantity),
+ ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
+ }).ExecuteCommand();
+ }
+ return true;
+ });
+ //ChannelStocks.Clear();
+ if (stockRepeats.Count == record.Count)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = $"该抽屉已存在此药品批次{string.Join(',', stockRepeats.Select(r=>r.ManuNo).ToArray())},请选择其他批次",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ else
+ {
+ if (f.Data)
+ {
+
+ string msg = string.Empty;
+ MsgType type = MsgType.SUCCESS;
+ 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 singleChannels = record.FindAll(it => it.BoardType != 1);
+ List singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
+ .GroupBy(it => it.ColNo)
+ .Select(it =>
+ {
+ var ret = it.First();
+ ret.Quantity = it.Sum(itx => itx.Quantity);
+ ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
+ ret.EffDate = it.Min(it => it.EffDate);
+ ret.ManuNo = it.OrderBy(it=>it.ManuNo).Select(it=>it.ManuNo).First().ToString();
+ return ret;
+ })
+ .OrderBy(it=>it.EffDate)
+ .ToList();
+ singleChannels = singleChannels.Where(it => it.AddQuantity > 0).ToList();
+ if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
+ {
+ //将库位多批次的总库存数更新标签
+ //_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) + singleChannels.Sum(it => it.AddQuantity));
+
+ singleChannels.ForEach(it =>
+ {
+
+ _portUtil.WriteChannelInfo(6, it.EffDate == null ? "" : it.EffDate, it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
+ _portUtil.WriteChannelInfo(5, it.ManuNo, it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
+ _portUtil.ShowContent(it.DrawerNo, it.ColNo);
+
+ Thread.Sleep(500);
+
+ //写库存数量
+ _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
+
+ });
+ }
+ RequestData();
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = msg,
+ Type = type,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ else
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "更新库存失败",
+ Type = MsgType.SUCCESS,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ }
+ Status = 0;
+ _isFinishClick = false;
+
+ PZH = string.Empty;
+
+ ChannelStocks.Clear();
+ }
+ else
+ {
+ _isFinishClick = false;
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "没有填写加药数量",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+
+ }
+
+ });
+ }
+
+ // 取消按钮
+ public DelegateCommand CancleTake
+ {
+ get => new DelegateCommand(() =>
+ {
+ _portUtil.ResetData();
+ Status = 0;
+ });
+ }
+
+ public bool KeepAlive => true;
+
+
+
+ //添加批次
+ 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)
+ {
+ 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().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;
+ List stockList = new List();
+ stockList.AddRange(channelLS.channelStocks);
+ stockList.Add(cls);
+ channelLS.channelStocks = stockList;
+ }
+ }
+
+ public long CurrentTimeMillis()
+ {
+ return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
+ }
+
+ public void FindDrawerCount()
+ {
+ int count = SqlSugarHelper.Db.Queryable().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 continuationCallback)
+ {
+ continuationCallback(true);
+ }
+ public void RequestData()
+ {
+ List queryData = SqlSugarHelper.Db.Queryable()
+ .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(queryData);
+ ChannelLsts.ForEach(cl => cl.channelStocks.ForEach(cs => cs.DrugInfo = cl.Drug));
+ }
+
+ //接收导航传过来的参数 现在是在此处初始化了表格数据
+ public void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
+ _eventAggregator.GetEvent().Subscribe(AddAction);
+ FindDrawerCount();
+ RequestData();
+ }
+
+
+ //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
+ public bool IsNavigationTarget(NavigationContext navigationContext)
+ {
+ return true;
+ }
+
+ //这个方法用于拦截请求
+ public void OnNavigatedFrom(NavigationContext navigationContext)
+ {
+ // 取消消息订阅
+ _eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
+ _eventAggregator.GetEvent().Unsubscribe(AddAction);
+ }
+ }
+}
diff --git a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs
index 1acbb96..ef6f52a 100644
--- a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs
+++ b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs
@@ -21,7 +21,7 @@ using System.Threading;
namespace DM_Weight.ViewModels
{
- public class BindingChannelDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
+ public class BindingChannelDialogViewModel : BindableBase, IDialogAware
{
public string Title => "库位绑定";
@@ -50,14 +50,14 @@ namespace DM_Weight.ViewModels
IEventAggregator _eventAggregator;
PortUtil _portUtil;
//ScreenUtil _screenUtil;
- private SqlSugarScope _sqlSugarScope1;
- public BindingChannelDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil, SqlSugarScope sqlSugarScope//, ScreenUtil screenUtil
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ public BindingChannelDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
)
{
_eventAggregator = eventAggregator;
_portUtil = portUtil;
//_screenUtil = screenUtil;
- this._sqlSugarScope1 = sqlSugarScope;
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
}
public int DrawerNo
@@ -110,13 +110,13 @@ namespace DM_Weight.ViewModels
List DrugList = null;
if (!string.IsNullOrEmpty(pycode))
{
- //DrugList = _sqlSugarScope1.Queryable().Includes(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
- DrugList = _sqlSugarScope1.Queryable().Includes(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
+ //DrugList = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
+ DrugList = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
}
else
{
- //DrugList = _sqlSugarScope1.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
- DrugList = _sqlSugarScope1.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
+ //DrugList = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
+ DrugList = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
}
return DrugList;
}
@@ -209,8 +209,8 @@ namespace DM_Weight.ViewModels
private void GetAllDrugInfos()
{
- //var list = _sqlSugarScope1.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
- var list = _sqlSugarScope1.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
+ //var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
+ var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugInfos = list;
DrugInfos_PY = list;
}
@@ -219,14 +219,14 @@ namespace DM_Weight.ViewModels
{
Channels?.Clear();
int totalCount = 0;
- //var list = _sqlSugarScope1.Queryable()
+ //var list = SqlSugarHelper.Db.Queryable()
// .Includes(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);
- var list = _sqlSugarScope1.Queryable()
+ var list = SqlSugarHelper.Db.Queryable()
.Includes(cs => cs.DrugInfo)
.WhereIF(DrawerNo > 0, cs => cs.DrawerNo == DrawerNo)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
@@ -268,7 +268,7 @@ namespace DM_Weight.ViewModels
{
if (DrugInfo != null)
{
- int count = _sqlSugarScope1.Queryable().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
+ int count = SqlSugarHelper.Db.Queryable().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];
@@ -278,8 +278,8 @@ namespace DM_Weight.ViewModels
item.PosNo = 0;
}
item.DrugId = DrugInfo.DrugId.ToString();
- //_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
- _sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
+ //SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
+ SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
GetChannelsByDrawerNo();
if (item.BoardType == 5)
@@ -339,7 +339,7 @@ namespace DM_Weight.ViewModels
// item.ManuNo = DrugManuNo.ManuNo;
// item.DrugInfo = DrugInfo;
// item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
- // _sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
+ // SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// if (item.BoardType == 5)
// {
@@ -369,7 +369,7 @@ namespace DM_Weight.ViewModels
// item.ManuNo = DrugManuNo.ManuNo;
// item.DrugInfo = DrugInfo;
// item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
- // _sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
+ // SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// if (item.BoardType == 5)
// {
@@ -402,8 +402,8 @@ namespace DM_Weight.ViewModels
item.ManuNo = DrugManuNo.ManuNo;
item.DrugInfo = DrugInfo;
item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
- //_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
- _sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
+ //SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
+ SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
if (item.BoardType == 5)
{
@@ -460,8 +460,8 @@ namespace DM_Weight.ViewModels
item.ManuNo = null;
item.EffDate = null;
item.DrugInfo = null;
- //_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
- _sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
+ //SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
+ SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
if (item.BoardType == 5)
{
// 清除显示屏库位信息
@@ -499,8 +499,8 @@ namespace DM_Weight.ViewModels
item.ManuNo = null;
item.EffDate = null;
item.DrugInfo = null;
- //_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
- _sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
+ //SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
+ SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
if (item.BoardType == 5)
{
// 清除显示屏库位信息
@@ -532,7 +532,6 @@ namespace DM_Weight.ViewModels
});
}
- public bool KeepAlive => false;
string message = string.Empty;
private void DoMyPrismEvent(DeviceMsg msg)
{
diff --git a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
new file mode 100644
index 0000000..9303581
--- /dev/null
+++ b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
@@ -0,0 +1,544 @@
+using MaterialDesignThemes.Wpf;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+using DM_Weight.Models;
+using DM_Weight.msg;
+using DM_Weight.Port;
+using DM_Weight.util;
+using log4net;
+using System.Threading;
+using System.Reflection.Metadata.Ecma335;
+
+namespace DM_Weight.ViewModels
+{
+ public class BindingChannelNewDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
+ {
+
+ public string Title => "库位绑定";
+
+ public event Action 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;
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ public static BindingChannelNewDialogViewModel vm;
+ public BindingChannelNewDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
+ )
+ {
+ _eventAggregator = eventAggregator;
+ _portUtil = portUtil;
+ //_screenUtil = screenUtil;
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
+ 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 List? _drugInfos;
+ public List? DrugInfos
+ {
+ get => _drugInfos;
+ set => SetProperty(ref _drugInfos, value);
+ }
+ ////拼音码对应药品实体
+ //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 GetDrugByDrugPY(string pycode)
+ //{
+ // List DrugList = null;
+ // if (!string.IsNullOrEmpty(pycode))
+ // {
+ // DrugList = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
+ // }
+ // else
+ // {
+ // DrugList = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
+ // }
+ // return DrugList;
+ //}
+ //private List? _drugInfos_py;
+ //public List? DrugInfos_PY
+ //{
+ // get => _drugInfos_py;
+ // set => SetProperty(ref _drugInfos_py, value);
+ //}
+ //#endregion 根据药品拼音码查询药品名称
+
+
+ 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(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
+ return;
+ }
+ if (DrugInfos != null)
+ {
+ DrugInfos.Clear();
+ }
+
+ DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text) || di.DrugId.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
+
+ }
+ //private List? _drugInfos;
+
+ //public List? DrugInfos
+ //{
+ // get => _drugInfos;
+ // set => SetProperty(ref _drugInfos, value);
+ //}
+
+ //private DrugManuNo? _drugManuNo;
+
+ //public DrugManuNo? DrugManuNo
+ //{
+ // get => _drugManuNo;
+ // set => SetProperty(ref _drugManuNo, value);
+ //}
+ //private List? _drugManuNos;
+
+ //public List? DrugManuNos
+ //{
+ // get => _drugManuNos;
+ // set => SetProperty(ref _drugManuNos, value);
+ //}
+
+
+ private List? _channels;
+
+ public List? 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().Unsubscribe(DoMyPrismEvent);
+ }
+
+ private void GetAllDrugInfos()
+ {
+ //var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
+ //DrugInfos = list;
+ //DrugInfos_PY = 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)as drug_name_spec FROM `drug_info` d";
+ DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
+
+ }
+
+ private void GetChannelsByDrawerNo()
+ {
+ Channels?.Clear();
+ int totalCount = 0;
+ var list = SqlSugarHelper.Db.Queryable()
+ .Includes(cl => cl.Drug)
+ .Includes(cs => cs.channelStocks)
+ .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);
+ if(list!=null&&list.Count>0)
+ {
+ for (int i = 0; i < list.Count; i++)
+ {
+ if(list[i].channelStocks!=null&& list[i].channelStocks.Count>0)
+ {
+ for (int j = 0; j < list[i].channelStocks.Count; j++)
+ {
+ list[i].totalCount += list[i].channelStocks[j].Quantity;
+ }
+ }
+ }
+ }
+ Channels = list;
+ TotalCount = totalCount;
+ }
+ public void OnDialogOpened(IDialogParameters parameters)
+ {
+ if (parameters.ContainsKey("DrawerNo"))
+ {
+ DrawerNo = parameters.GetValue("DrawerNo");
+ }
+ GetAllDrugInfos();
+ GetChannelsByDrawerNo();
+ _eventAggregator.GetEvent().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().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.Length>10? DrugInfo.Manufactory.Substring(0, 10): 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)
+ {
+ if(c>1)
+ {
+ SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
+ SnackbarMessageQueue.Enqueue("同一药品不可绑多个库位");
+ return;
+ }
+ //else
+ //{
+ // int count = SqlSugarHelper.Db.Queryable()
+ // .Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString()))
+ // .Where(cs => cs.DrawerType == 1)
+ // .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
+ // .Where(cs=>cs.DrawerNo=)
+ // .Count();
+
+ // if (count > 0)
+ // {
+ // SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
+ // SnackbarMessageQueue.Enqueue("该药品已绑定库位,不可绑定多个库位");
+ // return;
+ // }
+ //}
+
+ for (int i = 0; i < SelectChannels.Count; i++)
+ {
+ var item = SelectChannels[i];
+ int count = SqlSugarHelper.Db.Queryable()
+ .Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString()))
+ .Where(cs => cs.DrawerType == 1)
+ .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
+ .Where(cs => cs.DrawerNo == item.DrawerNo)
+ .Count();
+
+ if (count > 0)
+ {
+ SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
+ SnackbarMessageQueue.Enqueue("该药品已绑定库位,不可绑定多个库位");
+ return;
+ }
+ var channelStock = SqlSugarHelper.Db.Queryable().Where(cs => cs.Chnguid == item.Id&&cs.Quantity>0).ToList();
+ if(channelStock.Count>0)
+ {
+ //有库存,不能解绑
+
+ SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
+ SnackbarMessageQueue.Enqueue($"库位{item.DrawerNo}-{item.ColNo}中还存在药品,不能绑定其他药品");
+ continue;
+ }
+ if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
+ {
+ item.PosNo = 0;
+ }
+
+ item.DrugId = DrugInfo.DrugId.ToString();
+ //item.ManuNo = DrugManuNo.ManuNo;
+ item.Drug = DrugInfo;
+ //item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
+ SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
+
+ if (item.BoardType == 5)
+ {
+ _portUtil.WindowName = "BindingChannelDialog";
+ // 向显示屏写入库位信息
+ _portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
+ await Task.Delay(200);
+ //Thread.Sleep(200);
+ _portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
+ await Task.Delay(200);
+ //Thread.Sleep(200);
+ _portUtil.WriteChannelInfo(8, DrugInfo.Manufactory.Length > 10 ? DrugInfo.Manufactory.Substring(0, 10) : 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().Where(cs => cs.Chnguid == item.Id && cs.Quantity > 0).ToList();
+ if (channelStock.Count > 0)
+ {
+ SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
+ SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品【库位还存在药品】");
+ //该药品下的批次还有库存则不能解绑
+ return;
+ }
+
+ item.DrugId = null;
+ //item.ManuNo = null;
+ //item.EffDate = null;
+ item.Drug = null;
+ SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId }).ExecuteCommand();
+ SqlSugarHelper.Db.Updateable().SetColumns(it =>new ChannelStock { DrugId = null, ManuNo = null, EffDate = null} ).Where(it=>it.Chnguid==item.Id).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 => true;
+ 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().Publish(alertMsg);
+ }
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/DM_Weight/ViewModels/ChangeShiftsDialogViewModel.cs b/DM_Weight/ViewModels/ChangeShiftsDialogViewModel.cs
index 3a5804b..037030e 100644
--- a/DM_Weight/ViewModels/ChangeShiftsDialogViewModel.cs
+++ b/DM_Weight/ViewModels/ChangeShiftsDialogViewModel.cs
@@ -29,7 +29,7 @@ namespace DM_Weight.ViewModels
{
public string Title => "交接班";
- public bool KeepAlive => false;
+ public bool KeepAlive => true;
//交班人 发药人
public UserList Operator { get; set; }
private bool _operatorLogin = false;
@@ -164,10 +164,10 @@ namespace DM_Weight.ViewModels
//{
DateTime dt = DateTime.Now;
//保存交接班信息(查询当前值班人的最后一条交接班信息(如有则修改状态,没有则插入一条)并写入一条接班人信息)
- //var f = _sqlSugarScope1.UseTran(() =>
- var f = _sqlSugarScope1.UseTran(() =>
+ //var f = SqlSugarHelper.Db.UseTran(() =>
+ var f = SqlSugarHelper.Db.UseTran(() =>
{
- List listHkcChangeShifts = _sqlSugarScope1.Queryable()
+ List listHkcChangeShifts = SqlSugarHelper.Db.Queryable()
.Where(cs => cs.State == "0")
.WhereIF(Operator != null && !string.IsNullOrEmpty(Operator.UserName), cs => cs.FromOperator == Operator.UserName)
.WhereIF(Reviewer != null && !string.IsNullOrEmpty(Reviewer.UserName), cs => cs.FromRviewer == Reviewer.UserName)
@@ -177,7 +177,7 @@ namespace DM_Weight.ViewModels
if (listHkcChangeShifts != null && listHkcChangeShifts.Count > 0)
{
//存在则修改,不存在则插入一条
- _sqlSugarScope1.Updateable(new HkcChangeShifts()
+ SqlSugarHelper.Db.Updateable(new HkcChangeShifts()
{
Id = listHkcChangeShifts[0].Id,
ToOperator = JieOperator == null ? "" : JieOperator.UserName,
@@ -188,7 +188,7 @@ namespace DM_Weight.ViewModels
}
else
{
- _sqlSugarScope1.Insertable(new HkcChangeShifts()
+ SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
{
FromOperator = Operator == null ? "" : Operator.UserName,
FromRviewer = Reviewer == null ? "" : Reviewer.UserName,
@@ -201,7 +201,7 @@ namespace DM_Weight.ViewModels
}).ExecuteCommand();
}
- _sqlSugarScope1.Insertable(new HkcChangeShifts()
+ SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
{
FromOperator = JieOperator == null ? "" : JieOperator.UserName,
FromRviewer = JieReviewer == null ? "" : JieReviewer.UserName,
@@ -225,7 +225,7 @@ namespace DM_Weight.ViewModels
ORDER BY d2.operation_time DESC,d2.id DESC LIMIT 1) AS beforeNum from (SELECT drug_id,manu_no, SUM(IF(d1.`type` = 1, d1.quantity, 0)) AS getNum,SUM(IF(d1.`type` = 2, d1.quantity, 0)) AS useNum FROM dm_machine_record d1
WHERE d1.`type` IN (1, 2) AND d1.`operation_time` >= @startDate and d1.`operation_time` <=@endDate and d1.machine_id=@machineId GROUP BY d1.Drug_ID ,d1.manu_no) d
LEFT JOIN drug_info drug on d.drug_id=drug.drug_id left JOIN channel_stock c on c.drug_id=d.drug_id and c.manu_no=d.manu_no AND c.machine_id=@machineId GROUP BY d.Drug_ID ,d.manu_no ";
- List shiftsReports = _sqlSugarScope1.SqlQueryable(strSql)
+ List shiftsReports = SqlSugarHelper.Db.SqlQueryable(strSql)
.AddParameters(new
{
machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
@@ -240,7 +240,7 @@ namespace DM_Weight.ViewModels
for (int i = 0; i < shiftsReports.Count; i++)
{
- _sqlSugarScope1.Insertable(new ShiftsReport()
+ SqlSugarHelper.Db.Insertable(new ShiftsReport()
{
OptDate = dt,
DrugName = shiftsReports[i].DrugName,
@@ -312,7 +312,7 @@ namespace DM_Weight.ViewModels
LoginBtnEnable = false;
if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
{
- UserList userList = _sqlSugarScope1.Queryable()
+ UserList userList = SqlSugarHelper.Db.Queryable()
.Includes(u => u.Role)
.InnerJoin((u, r) => u.RoleId == r.Id)
.First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
@@ -508,7 +508,7 @@ namespace DM_Weight.ViewModels
{
if (msg.Message.Equals("LOGIN"))
{
- UserList userList = _sqlSugarScope1.Queryable()
+ UserList userList = SqlSugarHelper.Db.Queryable()
.Includes(u => u.Role)
.First(u => u.Id == msg.Id);
@@ -609,11 +609,11 @@ namespace DM_Weight.ViewModels
}
IEventAggregator _eventAggregator;
- private SqlSugarScope _sqlSugarScope1;
- public ChangeShiftsDialogViewModel(IEventAggregator eventAggregator,SqlSugarScope sqlSugarScope)
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ public ChangeShiftsDialogViewModel(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
- this._sqlSugarScope1 = sqlSugarScope;
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
}
public bool CanCloseDialog()
@@ -631,8 +631,8 @@ namespace DM_Weight.ViewModels
HkcChangeShifts changeOperator = GetOperator();
if (changeOperator != null)
{
- Operator = _sqlSugarScope1.Queryable().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromOperator);
- Reviewer = _sqlSugarScope1.Queryable().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromRviewer);
+ Operator = SqlSugarHelper.Db.Queryable().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromOperator);
+ Reviewer = SqlSugarHelper.Db.Queryable().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromRviewer);
}
FingerMsg = false;// !_fingerprintUtil.bIsConnected;
@@ -642,11 +642,11 @@ namespace DM_Weight.ViewModels
private HkcChangeShifts GetOperator()
{
//查询发药人及审核人
- HkcChangeShifts changeOperator = _sqlSugarScope1.Queryable().Single(change => change.State == "0");
+ HkcChangeShifts changeOperator = SqlSugarHelper.Db.Queryable().Single(change => change.State == "0");
//if (changeOperator != null)
//{
- // Operator = _sqlSugarScope1.Queryable().Single(u => u.UserName == changeOperator.FromOperator);
- // Reviewer = _sqlSugarScope1.Queryable().Single(u => u.UserName == changeOperator.ToOperator);
+ // Operator = SqlSugarHelper.Db.Queryable().Single(u => u.UserName == changeOperator.FromOperator);
+ // Reviewer = SqlSugarHelper.Db.Queryable().Single(u => u.UserName == changeOperator.ToOperator);
//}
return changeOperator;
}
diff --git a/DM_Weight/ViewModels/ChangeShiftsListWindowViewModel.cs b/DM_Weight/ViewModels/ChangeShiftsListWindowViewModel.cs
index 6bfaee8..556d35d 100644
--- a/DM_Weight/ViewModels/ChangeShiftsListWindowViewModel.cs
+++ b/DM_Weight/ViewModels/ChangeShiftsListWindowViewModel.cs
@@ -104,7 +104,7 @@ namespace DM_Weight.ViewModels
set { SetProperty(ref hkcChangeShifts, value); }
}
- public bool KeepAlive => false;
+ public bool KeepAlive => true;
IDialogService _dialogService;
//交接班
@@ -124,11 +124,11 @@ namespace DM_Weight.ViewModels
{
GridReportUtil.PrintChangeShiftsReport(StartDate, EndDate);
}
- private SqlSugarScope _sqlSugarScope1;
- public ChangeShiftsListWindowViewModel(IDialogService dialogService,SqlSugarScope sqlSugarScope)
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ public ChangeShiftsListWindowViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
- this._sqlSugarScope1 = sqlSugarScope;
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
}
void RequestData()
{
@@ -147,7 +147,7 @@ namespace DM_Weight.ViewModels
sqlStr += " and c.optdate<=@endOptDate ";
}
sqlStr+=" group by c.id";
- HkcChangeShifts = _sqlSugarScope1.SqlQueryable(sqlStr)
+ HkcChangeShifts = SqlSugarHelper.Db.SqlQueryable(sqlStr)
.AddParameters(new
{
machineId = machineId,
diff --git a/DM_Weight/ViewModels/ChangeShiftsRecordWindowViewModel.cs b/DM_Weight/ViewModels/ChangeShiftsRecordWindowViewModel.cs
index 07a1aed..93b0c49 100644
--- a/DM_Weight/ViewModels/ChangeShiftsRecordWindowViewModel.cs
+++ b/DM_Weight/ViewModels/ChangeShiftsRecordWindowViewModel.cs
@@ -102,7 +102,7 @@ namespace DM_Weight.ViewModels
set { SetProperty(ref machineRecords, value); }
}
- public bool KeepAlive => false;
+ public bool KeepAlive => true;
IDialogService _dialogService;
//交接班
@@ -124,7 +124,7 @@ namespace DM_Weight.ViewModels
{
int totalCount = 0;
string machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
- //MachineRecords = _sqlSugarScope1.Queryable()
+ //MachineRecords = SqlSugarHelper.Db.Queryable()
// .Includes(mr => mr.DrugInfo)
// .Includes(mr => mr.User)
// .Where(mr => mr.MachineId == machineId)
diff --git a/DM_Weight/ViewModels/ChangeShiftsWindowViewModel.cs b/DM_Weight/ViewModels/ChangeShiftsWindowViewModel.cs
index 278c59f..bc258f3 100644
--- a/DM_Weight/ViewModels/ChangeShiftsWindowViewModel.cs
+++ b/DM_Weight/ViewModels/ChangeShiftsWindowViewModel.cs
@@ -79,7 +79,7 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IRegionManager _regionManager;
IEventAggregator _eventAggregator;
- public bool KeepAlive => false;
+ public bool KeepAlive => true;
private bool _fingerMsg;
@@ -88,13 +88,13 @@ namespace DM_Weight.ViewModels
get => _fingerMsg;
set => SetProperty(ref _fingerMsg, value);
}
- private SqlSugarScope _sqlSugarScope1;
- public ChangeShiftsWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil,SqlSugarScope sqlSugarScope)
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ public ChangeShiftsWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil)
{
_portUtil = portUtil;
_regionManager = regionManager;
_eventAggregator = eventAggregator;
- this._sqlSugarScope1 = sqlSugarScope;
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
}
#region 交班确认按钮
@@ -188,22 +188,22 @@ namespace DM_Weight.ViewModels
if ((JiaoBanFYRFlag || JiaoBanSHRFlag) && (JieBanFYRFlag || JieBanSHRFlag))
{
//保存交接班信息(查询当前值班人的最后一条交接班信息(如有则修改状态,没有则插入一条)并写入一条接班人信息)
- var f = _sqlSugarScope1.UseTran(() =>
+ var f = SqlSugarHelper.Db.UseTran(() =>
{
- List listHkcChangeShifts = _sqlSugarScope1.Queryable()
+ List listHkcChangeShifts = SqlSugarHelper.Db.Queryable()
.Where(cs => cs.State == "0")
.WhereIF(App.CurrentFaUserList != null && !string.IsNullOrEmpty(App.CurrentFaUserList.UserName), cs => cs.FromOperator == App.CurrentFaUserList.UserName)
.WhereIF(App.CurrentShenUserList != null && !string.IsNullOrEmpty(App.CurrentShenUserList.UserName), cs => cs.FromRviewer == App.CurrentShenUserList.UserName)
.OrderByDescending(cs => cs.OptState)
.ToList();
- //List listMachineRecord=_sqlSugarScope1.Queryable()
+ //List listMachineRecord=SqlSugarHelper.Db.Queryable()
//.Where(m=>)
if (listHkcChangeShifts != null && listHkcChangeShifts.Count > 0)
{
//存在则修改,不存在则插入一条
- _sqlSugarScope1.Updateable(new HkcChangeShifts()
+ SqlSugarHelper.Db.Updateable(new HkcChangeShifts()
{
Id = listHkcChangeShifts[0].Id,
ToOperator = Operator == null ? "" : Operator.UserName,
@@ -215,7 +215,7 @@ namespace DM_Weight.ViewModels
}
else
{
- _sqlSugarScope1.Insertable(new HkcChangeShifts()
+ SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
{
FromOperator = App.CurrentFaUserList.UserName,
FromRviewer = App.CurrentShenUserList.UserName,
@@ -227,7 +227,7 @@ namespace DM_Weight.ViewModels
}).ExecuteCommand();
}
- _sqlSugarScope1.Insertable(new HkcChangeShifts()
+ SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
{
FromOperator = App.CurrentFaUserList.UserName,
FromRviewer = App.CurrentShenUserList.UserName,
@@ -266,7 +266,7 @@ namespace DM_Weight.ViewModels
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(passWord))
{
{
- UserList userList = _sqlSugarScope1.Queryable()
+ UserList userList = SqlSugarHelper.Db.Queryable()
.Includes(u => u.Role)
.InnerJoin((u, r) => u.RoleId == r.Id)
.First(u => u.UserName == userName && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
@@ -350,7 +350,7 @@ namespace DM_Weight.ViewModels
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(passWord))
{
{
- UserList userList = _sqlSugarScope1.Queryable()
+ UserList userList = SqlSugarHelper.Db.Queryable()
.Includes(u => u.Role)
.InnerJoin((u, r) => u.RoleId == r.Id)
.First(u => u.UserName == userName && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
@@ -419,7 +419,7 @@ namespace DM_Weight.ViewModels
{
if (msg.Message.Equals("LOGIN"))
{
- UserList userList = _sqlSugarScope1.Queryable()
+ UserList userList = SqlSugarHelper.Db.Queryable()
.Includes(u => u.Role)
.First(u => u.Id == msg.Id);
diff --git a/DM_Weight/ViewModels/CheckRecordDetailDialogViewModel.cs b/DM_Weight/ViewModels/CheckRecordDetailDialogViewModel.cs
new file mode 100644
index 0000000..f2add79
--- /dev/null
+++ b/DM_Weight/ViewModels/CheckRecordDetailDialogViewModel.cs
@@ -0,0 +1,198 @@
+using DM_Weight.Models;
+using DM_Weight.msg;
+using DM_Weight.Port;
+using DM_Weight.Report;
+using DM_Weight.util;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace DM_Weight.ViewModels
+{
+ public class CheckRecordDetailDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
+ {
+ public string Title => "盘点记录明细";
+ private int _pageNum = 1;
+ public int PageNum
+ {
+ get => _pageNum;
+ set
+ {
+ SetProperty(ref _pageNum, value);
+ RequestData();
+ }
+ }
+
+ private int _pageCount = 1;
+ public int PageCount
+ {
+ get => _pageCount;
+ set
+ {
+ SetProperty(ref _pageCount, value);
+ }
+ }
+
+ private int _pageSize = 8;
+ public int PageSize
+ {
+ get => _pageSize;
+ set
+ {
+ SetProperty(ref _pageSize, value);
+ }
+ }
+
+ private int _totalCount = 0;
+ public int TotalCount
+ {
+ get => _totalCount;
+ set
+ {
+ SetProperty(ref _totalCount, value);
+ }
+ }
+ private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
+
+ public DateTime? StartDate
+ {
+ get => _startDate;
+ set
+ {
+ if (value != null)
+ {
+ SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
+ }
+ else
+ {
+ SetProperty(ref _startDate, value);
+ }
+ RequestData();
+ }
+ }
+
+ private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
+
+ public DateTime? EndDate
+ {
+ get => _endDate;
+ set
+ {
+ if (value != null)
+ {
+ TimeSpan ershisi = new TimeSpan(23, 59, 59);
+ SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
+ }
+ else
+ {
+ SetProperty(ref _endDate, value);
+ }
+
+ RequestData();
+ }
+ }
+
+ private string _optDate;
+ public string OptDate
+ {
+ get => _optDate;
+ set
+ {
+ SetProperty(ref _optDate, value);
+ }
+ }
+
+ private ObservableCollection _obsCheckRecordStock = new ObservableCollection();
+ public ObservableCollection obsCheckRecordStock
+ {
+ get => _obsCheckRecordStock;
+ set => SetProperty(ref _obsCheckRecordStock, value);
+ }
+ private CheckRecordStock _checkRecordStock = new CheckRecordStock();
+ public CheckRecordStock checkRecordStock
+ {
+ get => _checkRecordStock;
+ set => SetProperty(ref _checkRecordStock, value);
+ }
+
+ private List? _channelStocks = new();
+
+ public List? ChannelStocks
+ {
+ get => _channelStocks;
+ set => SetProperty(ref _channelStocks, value);
+ }
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ private PortUtil _portUtil;
+ IEventAggregator _eventAggregator;
+
+ public event Action RequestClose;
+
+ public CheckRecordDetailDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService dialogService)
+ {
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
+ _portUtil = portUtil;
+ _eventAggregator = eventAggregator;
+ }
+ public void RequestData()
+ {
+
+ ChannelStocks.Clear();
+ obsCheckRecordStock.Clear();
+ //string strSql = "SELECT optDate AS optdate,U.User_name AS operatorUser,R.User_name AS reviewerUser,Drug_ID AS drugId,Drug_name AS drugName FROM check_stock C LEFT JOIN user_list U ON C.operator=U.ID LEFT JOIN user_list R ON C.reviewer=R.ID WHERE 1=1";
+ //if (StartDate != null)
+ //{
+ // strSql += " AND C.optDate=@OPTSTARTDATE ";
+ //}
+ //strSql += " GROUP BY C.optdate,Drug_id ORDER BY C.OPTDATE DESC";
+ List checkList = SqlSugarHelper.Db.Queryable()
+ .Includes(cs => cs.DrugInfo)
+ .Where(cs => cs.optdate == OptDate).OrderByDescending(cs => cs.optdate).ToList();
+ ICollectionView vw = CollectionViewSource.GetDefaultView(checkList);
+ vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo"));
+ obsCheckRecordStock = new ObservableCollection(checkList);
+
+ ChannelStocks = checkList;
+
+ }
+
+ public bool CanCloseDialog()
+ {
+ return true;
+ }
+
+ public void OnDialogClosed()
+ {
+
+ }
+
+ public void OnDialogOpened(IDialogParameters parameters)
+ {
+ if (parameters.ContainsKey("OptDate"))
+ {
+ OptDate = parameters.GetValue("OptDate");
+ }
+ RequestData();
+ }
+ public DelegateCommand BtnCloseCommand {
+ get => new DelegateCommand(() =>
+ {
+ // 关闭当前窗口
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ });
+ }
+
+ public bool KeepAlive => true;
+ }
+}
diff --git a/DM_Weight/ViewModels/CheckRecordNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckRecordNewWindowViewModel.cs
new file mode 100644
index 0000000..39d60fc
--- /dev/null
+++ b/DM_Weight/ViewModels/CheckRecordNewWindowViewModel.cs
@@ -0,0 +1,211 @@
+using DM_Weight.Models;
+using DM_Weight.Port;
+using DM_Weight.Report;
+using DM_Weight.util;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace DM_Weight.ViewModels
+{
+ public class CheckRecordNewWindowViewModel : 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 DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
+
+ public DateTime? StartDate
+ {
+ get => _startDate;
+ set
+ {
+ if (value != null)
+ {
+ SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
+ }
+ else
+ {
+ SetProperty(ref _startDate, value);
+ }
+ RequestData();
+ }
+ }
+
+ private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
+
+ public DateTime? EndDate
+ {
+ get => _endDate;
+ set
+ {
+ if (value != null)
+ {
+ TimeSpan ershisi = new TimeSpan(23, 59, 59);
+ SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
+ }
+ else
+ {
+ SetProperty(ref _endDate, value);
+ }
+
+ RequestData();
+ }
+ }
+ public event Action RequestClose;
+ private ObservableCollection _obsCheckRecordStock = new ObservableCollection();
+ public ObservableCollection obsCheckRecordStock
+ {
+ get => _obsCheckRecordStock;
+ set=>SetProperty(ref _obsCheckRecordStock, value);
+ }
+ private CheckRecordStock _checkRecordStock=new CheckRecordStock();
+ public CheckRecordStock checkRecordStock
+ {
+ get => _checkRecordStock;
+ set=>SetProperty(ref _checkRecordStock, value);
+ }
+
+
+ ////private SqlSugarScope SqlSugarHelper.Db;
+ private PortUtil _portUtil;
+ IEventAggregator _eventAggregator;
+ IDialogService _dialogService;
+ public CheckRecordNewWindowViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator, IDialogService dialogService)
+ {
+ _dialogService = DialogService;
+ ////this.SqlSugarHelper.Db = sqlSugarScope;
+ _portUtil = portUtil;
+ _eventAggregator = eventAggregator;
+ }
+ public DelegateCommand DownLoadCommond
+ {
+ get => new DelegateCommand(() =>
+ {
+ GridReportUtil.PrintReportStockNew(StartDate, EndDate);
+ });
+ }
+ public DelegateCommand Query
+ {
+ get => new DelegateCommand(() =>
+ {
+ RequestData();
+ });
+ }
+ public void RequestData()
+ {
+ int totalCount = 0;
+ string strSql = @"SELECT optDate AS optdate,U.User_name AS operatorUser,R.User_name AS reviewerUser,Drug_spec AS drugSpec,Manufactory AS manufactory,Quantity FROM check_stock C
+ LEFT JOIN user_list U ON C.operator=U.ID LEFT JOIN user_list R ON C.reviewer=R.ID WHERE 1=1";
+ if(StartDate!=null)
+ {
+ strSql += " AND C.optDate>@OPTSTARTDATE ";
+ }
+ if(EndDate!=null)
+ {
+ strSql += " AND C.optDate<@OPTENDDATE ";
+ }
+ strSql += " GROUP BY C.optdate ORDER BY C.OPTDATE DESC";
+ List checkList = SqlSugarHelper.Db.SqlQueryable(strSql)
+ .AddParameters(new
+ {
+ OPTSTARTDATE = StartDate,
+ OPTENDDATE = EndDate
+ }).ToPageList(PageNum, PageSize, ref totalCount);
+ //SqlSugarHelper.Db.ThenMapper(checkList, item =>
+ //{
+ // //item.drugDetails = SqlSugarHelper.Db.Queryable().SetContext(x => x.optdate, () => item.optdate, item).ToList();
+ // item.manuNoDetails = SqlSugarHelper.Db.Queryable().SetContext(x => x.optdate, () => item.optdate, item).ToList();
+ //});
+ obsCheckRecordStock = new ObservableCollection(checkList);
+
+ }
+
+ public DelegateCommand RowSelected
+ {
+ get => new DelegateCommand(async () =>
+ {
+ if (checkRecordStock != null && checkRecordStock.optdate!=null)
+ {
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("OptDate", checkRecordStock.optdate);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "CheckRecordDetailDialog", dialogParameters, DoDialogResult, "RootDialog");
+
+ }
+ });
+ }
+
+ public bool KeepAlive => true;
+
+ private void DoDialogResult(IDialogResult dialogResult)
+ {
+ checkRecordStock = null;
+ RequestData();
+ }
+
+ public bool IsNavigationTarget(NavigationContext navigationContext)
+ {
+ return true;
+ }
+
+ public void OnNavigatedFrom(NavigationContext navigationContext)
+ {
+
+ }
+
+ public void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ RequestData();
+ }
+ }
+}
diff --git a/DM_Weight/ViewModels/CheckStockNew2WindowViewModel.cs b/DM_Weight/ViewModels/CheckStockNew2WindowViewModel.cs
new file mode 100644
index 0000000..d8731d1
--- /dev/null
+++ b/DM_Weight/ViewModels/CheckStockNew2WindowViewModel.cs
@@ -0,0 +1,604 @@
+using DM_Weight.Models;
+using DM_Weight.msg;
+using DM_Weight.Port;
+using DM_Weight.Report;
+using DM_Weight.select;
+using DM_Weight.util;
+using log4net;
+using log4net.Repository.Hierarchy;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace DM_Weight.ViewModels
+{
+ public class CheckStockNew2WindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
+ {
+ //public static CheckStockNewWindowViewModel vm;
+ private readonly ILog logger = LogManager.GetLogger(typeof(CheckStockWindowViewModel));
+ public string drugId;
+ //public string Stock;
+ private static readonly DateTime Jan1st1970 = new DateTime
+ (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ public static List StaticSelects = new()
+ {
+ new OrderTakeSelect
+ {
+ Code = "DrugName",
+ Name = "药品名称"
+ },
+ new OrderTakeSelect
+ {
+ Code = "PyCode",
+ Name = "拼音码"
+ },
+ new OrderTakeSelect
+ {
+ Code = "DrugBarcode",
+ Name = "药品条码"
+ },
+ new OrderTakeSelect
+ {
+ Code = "DrugId",
+ Name = "药品编码"
+ }
+ };
+
+ private List _selects = StaticSelects;
+
+ public List Selects
+ {
+ get { return _selects; }
+ set
+ {
+ SetProperty(ref _selects, value);
+ }
+ }
+
+ private OrderTakeSelect _selectedItem = StaticSelects[0];
+ ///