@page "/checkOrder/Check" @using MasaBlazorApp3.Pojo.Config @using MasaBlazorApp3.Report @using Microsoft.Extensions.Options @using Radzen.Blazor.Rendering @using log4net; @* *@
@* *@ @* *@
@* *@
@if ((listBoxSelectedcsList != null && string.IsNullOrEmpty(listBoxSelectedcsList.ListId) && listBoxSelectedcsList.Quantity > listBoxSelectedcsList.UseQuantity) || (listBoxSelectedcsList.Quantity > listBoxSelectedcsList.BaseQuantity)) { //ListId为空则是没有在套餐里的药,库存量大于使用量时需要把药还到抽屉里 //列出需要还到抽屉里的药品的抽屉库位 @* *@ @if (listBoxSelectedcsList?.DrawerChanneStockList != null) { } @* *@ } @* *@
@*
*@ @code { private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrder)); @inject IOrderInfoDao orderInfoDao; @inject DialogService dialogService; @inject Microsoft.Extensions.Options.IOptions setting; @inject NotificationService _message; @inject IReportDataDao reportDataDao; @inject IOptions setting; //bool allowRowSelectOnRowClick = true; IEnumerable csList; IList selectedcsList; ChannelStock listBoxSelectedcsList = new(); ChannelStock returnList = new(); IEnumerable orderList; IList selectedOrderList; RadzenListBox listBox; RadzenDataGrid gridOrder; //麻醉师集合 List NamesList = new List(); Anaesthetist NameInfo; BoxModel BoxColor; //全部药盒集合 List AllBoxList = new List(); //药盒集合 List BoxList = new List(); //药盒颜色集合 List BoxColorList = new List() { new BoxModel{BoxNo=1,BoxName=1 }, new BoxModel{BoxNo=2 ,BoxName=1}, new BoxModel{BoxNo=3 ,BoxName=1} }; BoxModel BoxNum; bool isLoading; int count; int[] DrawerNos = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 }; int status = 0; string OrderNo; string PatientName; DateTime? OrderDate = DateTime.Now; DateTime PortOrderDate = DateTime.Now; Popup popup; RadzenButton button; private async Task OnColorChanged(object value) { if ((((BoxModel)value).BoxNo) == 3) { BoxList = AllBoxList.Where(bl => bl.BoxName > 30).ToList(); BoxNum = BoxList.FirstOrDefault(); await InvokeAsync(StateHasChanged); } else { BoxList = AllBoxList.Where(bl => bl.BoxNo == ((BoxModel)value).BoxNo && bl.BoxName <= 30).ToList(); BoxNum = BoxList.FirstOrDefault(); } await LoadData(null); } //药箱选中修改 private async Task OnBoxChanged(object value) { // BoxList = BoxList.Where(bl => bl.BoxNo == ((BoxModel)value).BoxNo && bl.BoxName == ((BoxModel)value).BoxName).ToList(); BoxNum = (BoxModel)value; await LoadData(null); } bool? boolHeader = true; //全选/反选 void ChangeHeaderCheckBox(bool? args) { if (args != null) { boolHeader = args; listBoxSelectedcsList?.OrderList.ToList().ForEach(it => it.ItemIsChecked = (bool)args); } } void OnCheckSeleced(object dete) { //listBoxSelectedcsList?.OrderList.ToList().Where(it => it.OrderNo == (OrderInfo as (dete).))(oi => oi.ItemIsChecked = true)); } //日期修改 async Task OnCurrentDateChanged(DateTime args) { OrderDate = new DateTime(args.Year, args.Month, args.Day); await LoadData(null); } void OnCurrentPortDateChanged(DateTime args) { PortOrderDate = new DateTime(args.Year, args.Month, args.Day); } void OnDrugCellClick(DataGridCellMouseEventArgs args) { } void OnCellClick(DataGridCellMouseEventArgs args) { if (args.Data.DetailInfo.SetManuNo != null) { args.Data.DetailInfo.drugManuNo = args.Data.DetailInfo.Drug.Manus.Where(m => m.ManuNo == args.Data.DetailInfo.SetManuNo).FirstOrDefault(); } if (args.Data.DetailInfo.drugManuNo == null) { args.Data.DetailInfo.drugManuNo = args.Data.DetailInfo.Drug.Manus.FirstOrDefault(); } args.Data.ItemIsChecked = !args.Data.ItemIsChecked; // gridOrder.EditRow(args.Data); } //查询 async Task Search() { await LoadData(null); } //确认 async Task Confirm() { csList = csList.ToList(); List checkChannelStock = new(); string errMessage = string.Empty; foreach (var item in csList) { if (item.SelectedOrderList.Aggregate(0, (a, b) => a + b.DetailInfo.Quantity)>item.Quantity) { _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = $"用药数不可大于库存数,请仔细核对!", Duration = 4000 } ); return; } int i = 0; if (item.OrderList != null && item.SelectedOrderList.Count > 0) { item.UseQuantity = item.SelectedOrderList.Sum(oi => oi.DetailInfo.Quantity); item.OrderQuantity = item.SelectedOrderList.Count; // checkChannelStock.Add(item); i = 1; } if (item.DrawerChanneStockList != null && item.DrawerChanneStockList.Any(d => d.ReturnQuantity > 0)) { //还药数量:使用量==库存?还0 :库存>基数? (库存数-使用数)>基数? 还 库存数-使用数:0; item.ReturnQuantity = (item.UseQuantity == item.Quantity) ? 0 : (item.Quantity <= item.BaseQuantity) ? 0 : ((item.Quantity - item.UseQuantity) > item.BaseQuantity) ? (item.Quantity - item.UseQuantity - item.BaseQuantity) : 0; //还药库位 if (item.ReturnQuantity > 0) { //药品未在套餐中绑定需要把药还到对应抽屉 List allDrugStock = await orderInfoDao.GetStockByDRrug(item.DrugId, item.ManuNo, 1);// await _connection.ChannelStock.Where(cs => cs.MachineId == _setting.machineId && cs.DrawerType == 1 && cs.DrugId == csList[i].DrugId && cs.ManuNo == csList[i].ManuNo).OrderBy(cs => cs.Quantity).ToListAsync(); if (allDrugStock != null && allDrugStock.Count > 0) { item.DrawerChanneStockList = new(); int iReturnQuantity = item.Quantity - item.UseQuantity - item.BaseQuantity; for (int j = 0; j < allDrugStock.Count; j++) { if (allDrugStock[j].BoardType.ToString().Contains("2") && allDrugStock[j].Quantity >= 25) continue; if (allDrugStock[j].BoardType.ToString().Contains("2") && allDrugStock[j].Quantity + item.Quantity - item.UseQuantity > 25) { if (iReturnQuantity <= allDrugStock.Sum(it => it.Quantity)) { for (int q = 0; iReturnQuantity > 0; q++) { allDrugStock[j].ReturnQuantity = 25 - allDrugStock[q].Quantity; item.DrawerChanneStockList.Add(allDrugStock[q]); iReturnQuantity = iReturnQuantity - allDrugStock[q].ReturnQuantity; if (iReturnQuantity <= 0) break; } } else { //库位不足,有药品无库位可放 allDrugStock[j].ReturnQuantity = iReturnQuantity; item.DrawerChanneStockList.Add(allDrugStock[j]); logger.Info($"还药品【{item.Drug.DrugName}】库位不足,有药品无库位可放"); errMessage += $"库位不足,药品【{item.Drug.DrugName}】无库位可放"; _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = errMessage, Duration = 4000 } ); break; ; } } else { allDrugStock[j].ReturnQuantity = iReturnQuantity; item.DrawerChanneStockList.Add(allDrugStock[j]); break; } } } } // checkChannelStock.Add(item); i = 1; } //还空瓶数 item.EmptyQuantity = item.SelectedOrderList.Sum(oi => oi.DetailInfo.Quantity); if (item.EmptyQuantity > 0) { //还空瓶库位 //查询还空瓶库位 //checkChannelStock[i].EmptyStock; List allDrugStock = await orderInfoDao.GetStockByDRrug(item.DrugId, item.ManuNo, 2);// await _connection.ChannelStock.Where(cs => cs.MachineId == _setting.machineId && cs.DrawerType == 1 && cs.DrugId == csList[i].DrugId && cs.ManuNo == csList[i].ManuNo).OrderBy(cs => cs.Quantity).ToListAsync(); if (allDrugStock.Count > 0) { item.EmptyStock = allDrugStock.FirstOrDefault(); item.EmptyStock.ReturnQuantity = item.EmptyQuantity; i = 1; } // checkChannelStock.Add(item); } if (i == 1) { checkChannelStock.Add(item); } } if (errMessage.Length > 0) { return; } if (checkChannelStock == null || checkChannelStock.Count <= 0) { _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = $"无可操作的数据", Duration = 4000 } ); return; } // //弹出确认提示框 var b = await dialogService.OpenAsync( $"核对确认", new Dictionary() { { "csList", checkChannelStock } }, new DialogOptions() { Width = "90vw", Resizable = true, Draggable = true, ShowClose = false }); // if (b) // { // bool bResult = await orderInfoDao.CheckOrderInfoByChannelStock(csList.ToList(), BoxNum); // if (bResult) // { // _message.Notify( // new NotificationMessage { Severity = NotificationSeverity.Success, Summary = "提示", Detail = $"处方已核对完成", Duration = 4000 } // ); // await LoadData(null); // } // else // { // _message.Notify( // new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = $"处方已核对失败", Duration = 4000 } // ); // } // } if (b) { LoadData(null); } } //导处方 async Task AddOrderMethod() { var b = await dialogService.OpenAsync( $"导入处方信息", new Dictionary() { { "boxModel", BoxNum } }, new DialogOptions() { Width = "80vw", Resizable = true, Draggable = true, ShowClose = false }); if (b != null) { try { List importOrderInfo = b; if (importOrderInfo.Count > 0) { string errorMessage = string.Empty; for (int i = 0; i < importOrderInfo.Count; i++) { if (!(bool)listBoxSelectedcsList?.OrderList.Contains(importOrderInfo[i])) { if (csList.Where(c => c.DrugId == importOrderInfo[i].DetailInfo.DrugId && c.ManuNo == importOrderInfo[i].DetailInfo.SetManuNo).FirstOrDefault() == null) { errorMessage += $"处方{importOrderInfo[i].OrderNo}导入失败,药品{importOrderInfo[i].DetailInfo.Drug.DrugName}不存在或批次{importOrderInfo[i].DetailInfo.SetManuNo}不存在"; } else { csList.Where(c => c.DrugId == importOrderInfo[i].DetailInfo.DrugId && c.ManuNo == importOrderInfo[i].DetailInfo.SetManuNo).FirstOrDefault()?.SelectedOrderList.Add(importOrderInfo[i]); //csList.Where(c => c.DrugId == importOrderInfo[i].DetailInfo.DrugId && c.ManuNo == importOrderInfo[i].DetailInfo.SetManuNo).FirstOrDefault()?.OrderList.Add(importOrderInfo[i]); } } csList = csList; } if (!string.IsNullOrEmpty(errorMessage)) { _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = errorMessage, Duration = 4000 } ); return; } else { StateHasChanged(); // 刷新UI } } } catch (Exception) { } } } PageData result; protected override async Task OnInitializedAsync() { BoxColor = BoxColorList.FirstOrDefault(); AllBoxList = await orderInfoDao.GetOperationNum(0); BoxList = AllBoxList.Where(bl => bl.BoxNo == BoxColor.BoxNo && bl.BoxName <= 30).ToList(); BoxNum = AllBoxList.FirstOrDefault(); await base.OnInitializedAsync(); } async Task LoadData(LoadDataArgs args) { string? roomName = BoxNum == null ? "" : setting.Value.roomName + BoxNum.BoxName.ToString().PadLeft(2, '0'); result = await orderInfoDao.GetAllOrderInfoDrugByBox(BoxNum, roomName, OrderDate); isLoading = true; csList = result.Desserts; if (csList != null && csList.Count() > 0) { listBoxSelectedcsList = csList.ElementAt(0); } count = result.TotalDesserts; isLoading = false; StateHasChanged(); // 刷新UI } //麻醉药品使用登记本导出 async Task StockExport() { if (PortOrderDate == DateTime.MinValue) { _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = $"请选择处方时间再导出", Duration = 4000 } ); return; } // PageData pageParentData = await reportDataDao.GetOrderInfoParentData(PortOrderDate); // PageData pageData = await reportDataDao.GetOrderInfoData(PortOrderDate); List pageParentData = await reportDataDao.GetOrderInfoParentData(PortOrderDate); List pageData = await reportDataDao.GetOrderInfoData(PortOrderDate); Dictionary parameters = new Dictionary(); parameters.Add("parent", pageParentData); parameters.Add("child", pageData); GridReportUtil.PrintReport("use_book.grf", parameters); } // protected override async Task OnInitializedAsync() // { // await base.OnInitializedAsync(); // // orderInfos = dbContext.Employees; // var result = await orderInfoDao.GetAllOrderInfo(OrderNo, OrderDate, args.Top, args.Skip); // // Update the Data property // orderInfos = result.Desserts; // // Update the count // count = result.TotalDesserts; // isLoading = false; // } }