From bf4db0096aa5722037a4ce313a42d3b5e1955584 Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Wed, 30 Apr 2025 16:42:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B4=A6=E5=86=8C=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/App.config | 2 +- DM_Weight/App.xaml.cs | 3 + DM_Weight/DM_Weight.csproj | 3 + DM_Weight/Models/AccountBookG2.cs | 6 + DM_Weight/Report/GridReportUtil.cs | 36 + DM_Weight/ReportTemp/account_book_new.grf | 656 ++++++++++++++++++ .../ViewModels/AccountWindowViewModel.cs | 144 ++++ .../CheckOrderNewWindowViewModel.cs | 163 +++-- .../ViewModels/RoleManagerWindowViewModel.cs | 7 + DM_Weight/Views/AccountWindow.xaml | 65 ++ DM_Weight/Views/AccountWindow.xaml.cs | 51 ++ 11 files changed, 1061 insertions(+), 75 deletions(-) create mode 100644 DM_Weight/ReportTemp/account_book_new.grf create mode 100644 DM_Weight/ViewModels/AccountWindowViewModel.cs create mode 100644 DM_Weight/Views/AccountWindow.xaml create mode 100644 DM_Weight/Views/AccountWindow.xaml.cs diff --git a/DM_Weight/App.config b/DM_Weight/App.config index 3969b3e..b6086a3 100644 --- a/DM_Weight/App.config +++ b/DM_Weight/App.config @@ -42,7 +42,7 @@ - + diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs index 8368c92..bb385ce 100644 --- a/DM_Weight/App.xaml.cs +++ b/DM_Weight/App.xaml.cs @@ -294,6 +294,9 @@ namespace DM_Weight containerRegistry.RegisterDialog(); containerRegistry.RegisterForNavigation(); + //账册 + containerRegistry.RegisterForNavigation(); + //药品转移药箱 containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation(); diff --git a/DM_Weight/DM_Weight.csproj b/DM_Weight/DM_Weight.csproj index 52e924c..e965709 100644 --- a/DM_Weight/DM_Weight.csproj +++ b/DM_Weight/DM_Weight.csproj @@ -98,6 +98,9 @@ Always + + Always + Always diff --git a/DM_Weight/Models/AccountBookG2.cs b/DM_Weight/Models/AccountBookG2.cs index 74ede11..dba0104 100644 --- a/DM_Weight/Models/AccountBookG2.cs +++ b/DM_Weight/Models/AccountBookG2.cs @@ -148,5 +148,11 @@ namespace DM_Weight.Models /// [SugarColumn(IsIgnore =true)] public string ReviewerName { get;set; } + + /// + /// 手术间 + /// + [SugarColumn(ColumnName = "shoushuJian")] + public string ShoushuJian { get;set; } } } diff --git a/DM_Weight/Report/GridReportUtil.cs b/DM_Weight/Report/GridReportUtil.cs index 41a152a..830d734 100644 --- a/DM_Weight/Report/GridReportUtil.cs +++ b/DM_Weight/Report/GridReportUtil.cs @@ -365,5 +365,41 @@ namespace DM_Weight.Report Report.PrintPreview(true); } + + public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate, string drug_id) + { + // 定义Grid++Report报表主对象 + GridppReport Report = new GridppReport(); + // 加载模板文件 + Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "account_book_new.grf"); + Report.DetailGrid.Recordset.ConnectionString = gridConnectionString; + DateTime? p_startDate = startDate?? Convert.ToDateTime("2010-1-1"); + DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1); + string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1"); + string SQL = $@" select ab.drug_id, ab.type, + di.drug_name AS DrugName,di.Drug_spec AS DrugSpec,di.big_unit AS BigUnit,di.small_unit AS SmallUnit, + DATE_FORMAT(ab.create_date,'%Y/%m/%d') AS YearMD,ab.manu_no AS ManuNo,DATE_FORMAT(ab.eff_date,'%Y%m%d') AS effDate,IF(ab.type=1,ab.add_quantity,'') AS InQuantity,ab.shoushuJian AS shoushuJian, + re.Patient_name AS PName,re.sex AS Sex,re.age AS Age,re.use_dose AS UseDose,re.residual_dose AS ResidualDose,re.create_time AS DiposalTime + ,re.operator_name, ab.manu_stock AS Stock,ab.total_stock AS empty,ab.total_stock,UL.User_name AS SendUser, + UL2.User_name AS InCheckUser, + re.supervisor_name AS CheckUser,ab.manu_stock,ab.total_stock,ab.user_id1,ab.user_id2,ab.out_Quantity + ,DB.BASEQUANTITY AS BaseQuantity,oi.Patient_id AS ZYH,oi.dept_name AS KS,re.anaesthetist_name AS YS, + IF(ab.`type`=1,'',UL.User_name) AS emptyUser + from account_book_g2 ab inner join drug_info di on ab.drug_id=di.Drug_ID + LEFT JOIN DRUG_BASE DB ON di.DRUG_ID=DB.DRUGID AND DB.MACHINE_ID='DM3' + LEFT JOIN order_info_sm oi on ab.invoice_no=oi.order_no + LEFT JOIN user_list UL ON ab.user_id1=UL.ID + LEFT JOIN user_list UL2 ON ab.user_id2=UL.ID + LEFT JOIN surgical_residual re on ab.invoice_no=re.order_no WHERE ab.machine_id='DM3' and ab.type in(1,2) and + ab.create_time>'{p_startDate}' AND ab.create_time<'{p_endDate}' "; + if (!string.IsNullOrEmpty(drug_id)) + { + SQL += " AND ab.drug_id='" + drug_id + "' "; + } + SQL += " ORDER BY ab.drug_id,ab.Manu_No,ab.create_time asc,ab.id "; + + Report.DetailGrid.Recordset.QuerySQL = SQL; + Report.PrintPreview(true); + } } } diff --git a/DM_Weight/ReportTemp/account_book_new.grf b/DM_Weight/ReportTemp/account_book_new.grf new file mode 100644 index 0000000..c54e875 --- /dev/null +++ b/DM_Weight/ReportTemp/account_book_new.grf @@ -0,0 +1,656 @@ +{ + "Version":"6.8.1.1", + "Font":{ + "Name":"宋体", + "Size":105000, + "Weight":400, + "Charset":134 + }, + "Printer":{ + "Oriention":"Landscape", + "TopMargin":0.3175, + "RightMargin":1, + "BottomMargin":0.3969 + }, + "DetailGrid":{ + "CenterView":true, + "Recordset":{ + "QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n CONCAT(dmr.`quantity`,IF(dmr.`type`=32,\"(空瓶)\",\"\")) AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` in (31, 32)\r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate", + "Field":[ + { + "Name":"药品名称", + "DBFieldName":"DrugName" + }, + { + "Name":"日期", + "DBFieldName":"YearMD" + }, + { + "Name":"批号", + "DBFieldName":"ManuNo" + }, + { + "Name":"效期", + "Type":"DateTime", + "Format":"yyyy/MM/dd", + "DBFieldName":"effDate" + }, + { + "Name":"领入", + "DBFieldName":"InQuantity" + }, + { + "Name":"规格", + "DBFieldName":"DrugSpec" + }, + { + "Name":"大单位", + "DBFieldName":"BigUnit" + }, + { + "Name":"小单位", + "DBFieldName":"SmallUnit" + }, + { + "Name":"基数", + "DBFieldName":"BaseQuantity" + }, + { + "Name":"手术间", + "DBFieldName":"shoushuJian" + }, + { + "Name":"患者姓名", + "DBFieldName":"PName" + }, + { + "Name":"性别", + "DBFieldName":"Sex" + }, + { + "Name":"年龄", + "DBFieldName":"Age" + }, + { + "Name":"住院号", + "DBFieldName":"ZYH" + }, + { + "Name":"科室", + "DBFieldName":"KS" + }, + { + "Name":"使用剂量", + "DBFieldName":"UseDose" + }, + { + "Name":"剩余剂量", + "DBFieldName":"ResidualDose" + }, + { + "Name":"余液处理时间", + "DBFieldName":"DiposalTime" + }, + { + "Name":"医师", + "DBFieldName":"YS" + }, + { + "Name":"复核人", + "DBFieldName":"CheckUser" + }, + { + "Name":"实物", + "DBFieldName":"Stock" + }, + { + "Name":"空瓶", + "DBFieldName":"empty" + }, + { + "Name":"发药人", + "DBFieldName":"SendUser" + }, + { + "Name":"领药人", + "DBFieldName":"InUser" + }, + { + "Name":"领药复核人", + "DBFieldName":"InCheckUser" + }, + { + "Name":"空瓶回收人", + "DBFieldName":"emptyUser" + } + ] + }, + "Column":[ + { + "Name":"日期", + "Width":2.77813 + }, + { + "Name":"批次", + "Width":2.19604 + }, + { + "Name":"有效期", + "Width":2.77813 + }, + { + "Name":"领入", + "Width":0.820208 + }, + { + "Name":"手术间", + "Width":0.79375 + }, + { + "Name":"患者姓名", + "Width":1.61396 + }, + { + "Name":"性别", + "Width":1.00542 + }, + { + "Name":"年龄", + "Width":0.79375 + }, + { + "Name":"住院号", + "Width":1.5875 + }, + { + "Name":"科室", + "Width":2.2225 + }, + { + "Name":"使用剂量", + "Width":1.82563 + }, + { + "Name":"剩余剂量", + "Width":1.5875 + }, + { + "Name":"余液处理时间", + "Width":2.59292 + }, + { + "Name":"医师", + "Width":1.5875 + }, + { + "Name":"复核人", + "Width":1.79917 + }, + { + "Name":"空瓶回收人", + "Width":1.61396 + }, + { + "Name":"实物", + "Width":1.40229 + }, + { + "Name":"空瓶", + "Width":1.19063 + }, + { + "Name":"发药人", + "Width":1.79917 + }, + { + "Name":"Column2", + "Width":1.79917 + } + ], + "ColumnContent":{ + "Height":2.01083, + "ColumnContentCell":[ + { + "Column":"日期", + "TextAlign":"MiddleCenter", + "DataField":"日期" + }, + { + "Column":"批次", + "TextAlign":"MiddleCenter", + "DataField":"批号" + }, + { + "Column":"有效期", + "TextAlign":"MiddleCenter", + "DataField":"效期" + }, + { + "Column":"领入", + "TextAlign":"MiddleCenter", + "DataField":"领入" + }, + { + "Column":"手术间", + "TextAlign":"MiddleCenter", + "DataField":"手术间" + }, + { + "Column":"患者姓名", + "TextAlign":"MiddleCenter", + "DataField":"患者姓名" + }, + { + "Column":"性别", + "TextAlign":"MiddleCenter", + "DataField":"性别" + }, + { + "Column":"年龄", + "DataField":"年龄" + }, + { + "Column":"住院号", + "DataField":"住院号" + }, + { + "Column":"科室", + "DataField":"科室" + }, + { + "Column":"使用剂量", + "DataField":"使用剂量" + }, + { + "Column":"剩余剂量", + "DataField":"剩余剂量" + }, + { + "Column":"余液处理时间", + "DataField":"余液处理时间" + }, + { + "Column":"医师", + "DataField":"医师" + }, + { + "Column":"复核人", + "DataField":"复核人" + }, + { + "Column":"空瓶回收人", + "DataField":"空瓶回收人" + }, + { + "Column":"实物", + "DataField":"实物" + }, + { + "Column":"空瓶", + "DataField":"空瓶" + }, + { + "Column":"发药人", + "DataField":"发药人" + }, + { + "Column":"Column2", + "DataField":"领药复核人" + } + ] + }, + "ColumnTitle":{ + "Height":2.59292, + "RepeatStyle":"OnPage", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"日期", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"日期" + }, + { + "GroupTitle":false, + "Column":"批次", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"批号" + }, + { + "GroupTitle":false, + "Column":"有效期", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"有效期" + }, + { + "GroupTitle":false, + "Column":"领入", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"领\r\n入" + }, + { + "GroupTitle":true, + "Name":"Column1", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"手术间", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"手\r\n术\r\n间" + }, + { + "GroupTitle":false, + "Column":"患者姓名", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"患者\r\n姓名" + }, + { + "GroupTitle":false, + "Column":"性别", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"性\r\n别" + }, + { + "GroupTitle":false, + "Column":"年龄", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"年\r\n龄" + }, + { + "GroupTitle":false, + "Column":"住院号", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"住院号" + }, + { + "GroupTitle":false, + "Column":"科室", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"科室" + }, + { + "GroupTitle":false, + "Column":"使用剂量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"使用\r\n剂量" + }, + { + "GroupTitle":false, + "Column":"剩余剂量", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"剩余\r\n剂量" + }, + { + "GroupTitle":false, + "Column":"余液处理时间", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"余液\r\n处理\r\n时间" + }, + { + "GroupTitle":false, + "Column":"医师", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"医师" + }, + { + "GroupTitle":false, + "Column":"复核人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"复核人" + }, + { + "GroupTitle":false, + "Column":"空瓶回收人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"空瓶\r\n回收人" + } + ], + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"使用" + }, + { + "GroupTitle":true, + "Name":"Column3", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"实物", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"实物" + }, + { + "GroupTitle":false, + "Column":"空瓶", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"空瓶" + } + ], + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"结存数" + }, + { + "GroupTitle":true, + "Name":"Column4", + "ColumnTitleCell":[ + { + "GroupTitle":false, + "Column":"发药人", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"发药人" + } + ], + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"领药人" + }, + { + "GroupTitle":false, + "Column":"Column2", + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"复核人" + } + ] + } + }, + "PageHeader":{ + "Height":0 + }, + "Parameter":[ + { + "Name":"startDate", + "DataType":"DateTime", + "Format":"yyyy-MM-dd hh:mm:ss", + "Value":"2023/1/1" + }, + { + "Name":"endDate", + "DataType":"DateTime", + "Format":"yyyy-MM-dd hh:mm:ss", + "Value":"2023/4/28 23:59:59" + }, + { + "Name":"machine_id", + "Value":"DM1" + } + ], + "ReportHeader":[ + { + "Name":"ReportHeader1", + "Height":1.5875, + "Control":[ + { + "Type":"MemoBox", + "Name":"MemoBox2", + "Dock":"Fill", + "Font":{ + "Name":"宋体", + "Size":217500, + "Bold":true, + "Charset":134 + }, + "TextAlign":"MiddleCenter", + "Text":"湘谭县人民医院麻醉药品、麻精神药品专用账本(手术室)" + } + ], + "RepeatOnPage":true + }, + { + "Name":"ReportHeader2", + "Height":1.00542, + "Control":[ + { + "Type":"MemoBox", + "Name":"MemoBox3", + "Dock":"Fill", + "Border":{ + "Styles":"[DrawLeft|DrawTop|DrawRight]" + }, + "Font":{ + "Name":"宋体", + "Size":120000, + "Bold":true, + "Charset":134 + }, + "Text":"药品名称:[#药品名称#] 规格:[#规格#] 单位:[#大单位#] 基数:[#基数#]" + } + ], + "RepeatOnPage":true + } + ] +} \ No newline at end of file diff --git a/DM_Weight/ViewModels/AccountWindowViewModel.cs b/DM_Weight/ViewModels/AccountWindowViewModel.cs new file mode 100644 index 0000000..14482a9 --- /dev/null +++ b/DM_Weight/ViewModels/AccountWindowViewModel.cs @@ -0,0 +1,144 @@ +using DM_Weight.Models; +using DM_Weight.msg; +using DM_Weight.Report; +using DM_Weight.util; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using Prism.Regions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.ViewModels +{ + public class AccountWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime + { + public static AccountWindowViewModel vm; + 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); + } + } + } + + 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); + } + } + } + IEventAggregator _eventAggregator; + public AccountWindowViewModel(IEventAggregator eventAggregator) + { + _eventAggregator = eventAggregator; + vm = this; + } + /// + /// 导出账册 + /// + public DelegateCommand DownloadAccountBook + { + get => new DelegateCommand(() => + { + if(DrugInfo==null||string.IsNullOrEmpty(DrugInfo.DrugId)) + { + AlertMsg alertMsg = new AlertMsg + { + Message = $"请选择药品!", + Type = MsgType.ERROR, + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return; + } + GridReportUtil.PrintReportAccountBook(StartDate, EndDate, DrugInfo.DrugId); + + }); + } + + public bool KeepAlive => false; + + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnNavigatedFrom(NavigationContext navigationContext) + { + } + + public void OnNavigatedTo(NavigationContext navigationContext) + { + //药品信息 + GetAllDrugInfos(); + } + /// + /// 药品 + /// + 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); + } + } + private void GetAllDrugInfos() + { + var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList(); + DrugInfos = list; + DrugInfo = list[0]; + } + 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 DrugName 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)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList(); + } + } +} diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs index 331bb8e..bb4f600 100644 --- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs @@ -316,8 +316,8 @@ namespace DM_Weight.ViewModels .Where(oi => oi.DmStatus == 1) .Where(oi => oi.HisDispFlag == 0) .Where(oi => oi.CancelFlag == 0) - .Where(oi => oi.DrawerCode==DrawerNo+1) - .Where(oi=>oi._OrderDetail.SetManuNo!=null && oi._OrderDetail.SetManuNo != "null") + .Where(oi => oi.DrawerCode == DrawerNo + 1) + .Where(oi => oi._OrderDetail.SetManuNo != null) .Where(oi => oi._OrderDetail.Quantity > 0) .OrderBy(oi => oi.OrderId) .ToPageList(PageNum, PageSize, ref totalCount); @@ -326,7 +326,7 @@ namespace DM_Weight.ViewModels { OrderInfoList.ForEach(oi => oi.ItemIsChecked = true); //OrderInfoList.ForEach(oi => oi.OrderDetailList.ForEach(od => od.DrugInfo = od.DrugInfo ?? new DrugInfo())); - OrderInfoList.ForEach(oi => oi._OrderDetail.DrugInfo= oi._OrderDetail.DrugInfo ?? new DrugInfo()); + OrderInfoList.ForEach(oi => oi._OrderDetail.DrugInfo = oi._OrderDetail.DrugInfo ?? new DrugInfo()); //TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).GroupBy(oi => oi.OrderDetailList.DrugInfo.DrugName).Select(oi => new TotalDrug { DrugName = oi.Key, TotalCount = oi.Sum(item => item.OrderDetailList.Quantity) }).ToList(); TotalDrugList = OrderInfoList.Where(oi => oi.ItemIsChecked).Select(OrderDetailList => OrderDetailList._OrderDetail).GroupBy(item => item.DrugInfo.DrugName).Select(group => new TotalDrug { DrugName = group.Key, TotalCount = group.Sum(item => item.Quantity) }).ToList(); @@ -485,7 +485,7 @@ namespace DM_Weight.ViewModels PatientId = oi.PatientId, Pharmacy = oi.Pharmacy, State = 2, - WinNo= DrawerNo+1+"号手术间", + WinNo = DrawerNo + 1 + "号手术间", Operator = HomeWindowViewModel.Operator?.Nickname, }).ExecuteCommand(); } @@ -495,79 +495,92 @@ namespace DM_Weight.ViewModels //for (int j = 0; j < oi._OrderDetail.Count; j++) //{ // oi._OrderDetail = oi.OrderDetailList[j]; - int drawerNo = DrawerNo + 1; - ChannelStock cs = SqlSugarHelper.Db.Queryable() - .Where(cs => cs.DrugId == oi._OrderDetail.DrugId - && cs.ManuNo == oi._OrderDetail.SetManuNo - // && cs.EffDate == oi._OrderDetail.SetEffDate - && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM5") - && cs.DrawerNo == drawerNo - && cs.Quantity >= oi._OrderDetail.Quantity).First(); - if (cs == null) + int drawerNo = DrawerNo + 1; + ChannelStock cs = SqlSugarHelper.Db.Queryable() + .Where(cs => cs.DrugId == oi._OrderDetail.DrugId + && cs.ManuNo == oi._OrderDetail.SetManuNo + // && cs.EffDate == oi._OrderDetail.SetEffDate + && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM5") + && cs.DrawerNo == drawerNo + && cs.Quantity >= oi._OrderDetail.Quantity).First(); + if (cs == null) + { + empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo};"; + continue; + } + cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity; + cs.NeedNum = cs.NeedNum + oi._OrderDetail.Quantity; + // 更新数据 库存信息 + SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity, it.NeedNum }).ExecuteCommand(); + + // 获取更新完库存后的药品库存 + List nowChannels = SqlSugarHelper.Db.Queryable() + .Where(it => it.MachineId.Equals(cs.MachineId) || it.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"])) + .Where(it => it.DrugId.Equals(cs.DrugId)) + .Where(it => it.ManuNo.Equals(cs.ManuNo)) + .Where(it => it.DrawerType == 1) + .ToList(); + if (cs != null) + { + + SqlSugarHelper.Db.Insertable(new MachineRecord() { - empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo};"; - continue; - } - cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity; - cs.NeedNum = cs.NeedNum + oi._OrderDetail.Quantity; - // 更新数据 库存信息 - SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity, it.NeedNum }).ExecuteCommand(); + MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), + DrawerNo = cs.DrawerNo, + ColNo = cs.ColNo, + DrugId = cs.DrugId, + ManuNo = cs.ManuNo, + EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, + Operator = HomeWindowViewModel.Operator?.Id, + Reviewer = HomeWindowViewModel.Reviewer?.Id, + OperationTime = DateTime.Now, + Quantity = oi._OrderDetail.Quantity, + Type = 2, + InvoiceId = oi.OrderNo + //, StockQuantity = nowChannels.Sum(it => it.Quantity) + }).ExecuteCommand(); - if (cs != null) + #region 记录 注射剂使用与交接记录报表 + //查询发药时间 + //MachineRecord SendMachineRecord = SqlSugarHelper.Db.Queryable().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 2) + //.OrderByDescending(mr => mr.OperationTime) + //.First(); + //string retUser = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cl.DrawerNo == cs.DrawerNo) + //.Select(cl => cl.BelongUser).First(); + + RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp => rp.SendDate).First(); + if (rejectionReport != null) { + //发药信息 + //RejectionReport rejectionReport = new RejectionReport(); + //rejectionReport.SendDate = SendMachineRecord.OperationTime; + //rejectionReport.SendUser = SendMachineRecord.Operator.ToString(); + //rejectionReport.ReceiveUser = retUser; + rejectionReport.RealNum = cs.BaseQuantity; - SqlSugarHelper.Db.Insertable(new MachineRecord() - { - MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), - DrawerNo = cs.DrawerNo, - ColNo = cs.ColNo, - DrugId = cs.DrugId, - ManuNo = cs.ManuNo, - EffDate = !String.IsNullOrEmpty(cs.EffDate) ? DateTime.ParseExact(cs.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, - Operator = HomeWindowViewModel.Operator?.Id, - Reviewer = HomeWindowViewModel.Reviewer?.Id, - OperationTime = DateTime.Now, - Quantity = oi._OrderDetail.Quantity, - Type = 2, - InvoiceId = oi.OrderNo - //, StockQuantity = nowChannels.Sum(it => it.Quantity) - }).ExecuteCommand(); + //还药信息 + rejectionReport.InfactNum = cs.BaseQuantity - oi._OrderDetail.Quantity; + rejectionReport.EmptyNum = oi._OrderDetail.Quantity; + rejectionReport.ReturnTime = DateTime.Now.ToString(); + rejectionReport.ReturnUser = rejectionReport.SendUser; + rejectionReport.ReturnReceiveUser = rejectionReport.ReceiveUser;// SendMachineRecord.Operator.ToString(); + rejectionReport.DrugId = oi._OrderDetail.DrugId; + rejectionReport.DrugName = oi._OrderDetail.DrugInfo.DrugName; + rejectionReport.DrugSpec = oi._OrderDetail.DrugInfo.DrugSpec; - #region 记录 注射剂使用与交接记录报表 - //查询发药时间 - //MachineRecord SendMachineRecord = SqlSugarHelper.Db.Queryable().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 2) - //.OrderByDescending(mr => mr.OperationTime) - //.First(); - //string retUser = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cl.DrawerNo == cs.DrawerNo) - //.Select(cl => cl.BelongUser).First(); - - RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp => rp.SendDate).First(); - if (rejectionReport != null) - { - //发药信息 - //RejectionReport rejectionReport = new RejectionReport(); - //rejectionReport.SendDate = SendMachineRecord.OperationTime; - //rejectionReport.SendUser = SendMachineRecord.Operator.ToString(); - //rejectionReport.ReceiveUser = retUser; - rejectionReport.RealNum = cs.BaseQuantity; - - //还药信息 - rejectionReport.InfactNum = cs.BaseQuantity - oi._OrderDetail.Quantity; - rejectionReport.EmptyNum = oi._OrderDetail.Quantity; - rejectionReport.ReturnTime = DateTime.Now.ToString(); - rejectionReport.ReturnUser = rejectionReport.SendUser; - rejectionReport.ReturnReceiveUser = rejectionReport.ReceiveUser;// SendMachineRecord.Operator.ToString(); - rejectionReport.DrugId = oi._OrderDetail.DrugId; - rejectionReport.DrugName = oi._OrderDetail.DrugInfo.DrugName; - rejectionReport.DrugSpec = oi._OrderDetail.DrugInfo.DrugSpec; - - rejectionReport.OperationTime = DateTime.Now; - - int iRejectionReport = SqlSugarHelper.Db.Updateable(rejectionReport).ExecuteCommand(); - } - #endregion + rejectionReport.OperationTime = DateTime.Now; + int iRejectionReport = SqlSugarHelper.Db.Updateable(rejectionReport).ExecuteCommand(); } + #endregion + + //} + //查询上一条账册中的空瓶数 + AccountBookG2 accountBookEmpty = SqlSugarHelper.Db.Queryable() + .Where(ab => ab.MachineId.Equals(ConfigurationManager.AppSettings["dm_machineId"].ToString())) + .Where(ab => ab.Type == 1 || ab.Type == 2) + .Where(ab => ab.DrugId == oi._OrderDetail.DrugId) + .Where(ab => ab.ManuNo == cs.ManuNo).OrderByDescending(ab => ab.Id).First(); //保存账册 int iInsertResult = SqlSugarHelper.Db.Insertable(new AccountBookG2() { @@ -583,8 +596,10 @@ namespace DM_Weight.ViewModels MachineId = ConfigurationManager.AppSettings["dm_machineId"].ToString(), CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), CreateTime = DateTime.Now, - InvoiceNo = oi.OrderNo - + InvoiceNo = oi.OrderNo, + ManuStock = nowChannels.Sum(it => it.Quantity), + TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi._OrderDetail.Quantity, + ShoushuJian= drawerNo.ToString() }).ExecuteCommand(); //修改凌晨生成的日结存与总结存数据 AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable() @@ -654,7 +669,7 @@ namespace DM_Weight.ViewModels } } - //} + } } if (!string.IsNullOrEmpty(empChannelStock)) { @@ -745,7 +760,7 @@ namespace DM_Weight.ViewModels //ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo); try { - _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo) }); + _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo) }); _socketHelper.dateTime = DateTime.Now; } catch (Exception ex) diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs index a0f4b0b..a29889f 100644 --- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs +++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs @@ -532,6 +532,12 @@ namespace DM_Weight.ViewModels PremissionName = "药箱药品调整", PremissionPath = "ExchangeWindow", }; + PremissionDm sysset6 = new PremissionDm + { + Id = 59, + PremissionName = "账册", + PremissionPath = "AccountWindow", + }; syssetChild.Add(sysset1); syssetChild.Add(sysset2); syssetChild.Add(syssetLogin); @@ -541,6 +547,7 @@ namespace DM_Weight.ViewModels syssetChild.Add(sysset3); syssetChild.Add(sysset4); syssetChild.Add(sysset5); + syssetChild.Add(sysset6); sysset.Children = syssetChild; defaultAll.Add(sysset); #endregion diff --git a/DM_Weight/Views/AccountWindow.xaml b/DM_Weight/Views/AccountWindow.xaml new file mode 100644 index 0000000..7af6c3f --- /dev/null +++ b/DM_Weight/Views/AccountWindow.xaml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DM_Weight/Views/AccountWindow.xaml.cs b/DM_Weight/Views/AccountWindow.xaml.cs new file mode 100644 index 0000000..08f3686 --- /dev/null +++ b/DM_Weight/Views/AccountWindow.xaml.cs @@ -0,0 +1,51 @@ +using DM_Weight.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace DM_Weight.Views +{ + /// + /// AccountWindow.xaml 的交互逻辑 + /// + public partial class AccountWindow : UserControl + { + AccountWindowViewModel vms; + public AccountWindow() + { + InitializeComponent(); + } + /// + /// 药品名称下拉框 + /// + /// + /// + private void ComboBox_KeyUp(object sender, KeyEventArgs e) + { + ComboBox comboBox = sender as ComboBox; + vms.UpdateComboBoxItems(comboBox.Text); + if (this.vms.DrugInfos.Count > 0) + { + comboBox.IsDropDownOpen = true; + } + TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox); + textBox.SelectionStart = textBox.Text.Length; + } + + private void UserControl_Loaded(object sender, RoutedEventArgs e) + { + vms = AccountWindowViewModel.vm; + } + } +}