diff --git a/MasaBlazorApp3/DataAccess/Dao/IOrderInfoDao.cs b/MasaBlazorApp3/DataAccess/Dao/IOrderInfoDao.cs index b3f704c..9a58114 100644 --- a/MasaBlazorApp3/DataAccess/Dao/IOrderInfoDao.cs +++ b/MasaBlazorApp3/DataAccess/Dao/IOrderInfoDao.cs @@ -28,6 +28,8 @@ namespace MasaBlazorApp3.DataAccess.Dao public Task>> getReturnInfoByOrderNo(string OrderrNo); //获取药盒中的用药信息 public Task> GetAllOrderInfoByBox(int box,string OrderrNo, DateTime OrderDate, int? take, int? skip); + //获取待处理处方中的麻醉师 + public Task> GetAllOrderInfo(string Name, string OrderrNo, DateTime? OrderDate, int? take, int? skip); //获取所有药盒号 public Task GetDrawerNum(string machineId); //核对处方 diff --git a/MasaBlazorApp3/DataAccess/Dao/IReportDataDao.cs.cs b/MasaBlazorApp3/DataAccess/Dao/IReportDataDao.cs.cs index 7f8dd15..0f347e2 100644 --- a/MasaBlazorApp3/DataAccess/Dao/IReportDataDao.cs.cs +++ b/MasaBlazorApp3/DataAccess/Dao/IReportDataDao.cs.cs @@ -14,7 +14,7 @@ namespace MasaBlazorApp3.DataAccess.Dao //专用账册导出数据 Task> GetAccountExportData(DateTime? startDate, DateTime? endDate, string drugName); //手术室患者麻醉药品使用登记本 - Task> GetOrderInfoData(DateTime startDate); + Task> GetOrderInfoData(DateTime? startDate); //请领登记表导出 Task> GetApplyInfoDate(DateTime searchDate); } diff --git a/MasaBlazorApp3/DataAccess/Impl/ChannelListDao.cs b/MasaBlazorApp3/DataAccess/Impl/ChannelListDao.cs index 621124d..314b7b0 100644 --- a/MasaBlazorApp3/DataAccess/Impl/ChannelListDao.cs +++ b/MasaBlazorApp3/DataAccess/Impl/ChannelListDao.cs @@ -1123,12 +1123,7 @@ namespace MasaBlazorApp3.DataAccess.Impl Operator = _globalStateService.Operator.Id, Reviewer = _globalStateService.Reviewer?.Id ?? _globalStateService.Operator.Id, InvoiceId = boxTakeVo.ChannelStock.Id.ToString(), - }); - //int totalQuantity = _connection.PlanDetails.Where(p => p.PlanId == Convert.ToInt32(boxChannelList.DrugId)&&p.DrugId== boxTakeVo.BoxDetail.DrugId).Sum(p => p.BaseQuantity); - int totalQuantity= boxChannelList.TotalQuantity+ boxTakeVo.GetQuantity; - int list = _connection.ChannelList.Where(cl => cl.Id == boxChannelList.Id) - .Set(cl => cl.TotalQuantity, totalQuantity) - .Update(); + }); int delResutl = await _connection.ChannelStock.Where(cs => cs.MachineId == boxTakeVo.BoxDetail.MachineId && cs.DrugId == boxTakeVo.BoxDetail.DrugId && cs.ManuNo == null).DeleteAsync(); if (mid > 0 && r > 0 && boxID > 0 && boxMId > 0) { @@ -1146,6 +1141,10 @@ namespace MasaBlazorApp3.DataAccess.Impl } if (flag) { + int totalQuantity = boxChannelList.TotalQuantity + datas.Sum(it => it.GetQuantity); + int list = _connection.ChannelList.Where(cl => cl.Id == boxChannelList.Id) + .Set(cl => cl.TotalQuantity, totalQuantity) + .Update(); _connection.CommitTransaction(); } else @@ -1849,7 +1848,7 @@ namespace MasaBlazorApp3.DataAccess.Impl var query = _connection.ChannelStock.AsQueryable() .Where(cl=>cl.MachineId==_setting.boxMachineId&&cl.DrawerNo==BoxNum&&cl.Quantity>0); return await query - .Where(cl=>cl.Quantity<=0) + //.Where(cl=>cl.Quantity<=0) .OrderBy((cl) => cl.DrawerNo) .ThenBy((cl) => cl.DrawerNo) .ThenBy((cl) => cl.ColNo) diff --git a/MasaBlazorApp3/DataAccess/Impl/OrderInfoDao.cs b/MasaBlazorApp3/DataAccess/Impl/OrderInfoDao.cs index c101970..04e8c67 100644 --- a/MasaBlazorApp3/DataAccess/Impl/OrderInfoDao.cs +++ b/MasaBlazorApp3/DataAccess/Impl/OrderInfoDao.cs @@ -1,4 +1,5 @@ -using LinqToDB; +using Google.Protobuf; +using LinqToDB; using LinqToDB.SqlQuery; using log4net; using log4net.Util; @@ -10,6 +11,7 @@ using MasaBlazorApp3.Pojo.Vo; using MasaBlazorApp3.Port; using Microsoft.Extensions.Options; using Mysqlx.Crud; +using Radzen; using Radzen.Blazor.Rendering; using System; using System.Collections; @@ -29,13 +31,14 @@ namespace MasaBlazorApp3.DataAccess.Impl private GlobalStateService _globalStateService; private readonly ILog logger = LogManager.GetLogger(typeof(OrderInfoDao)); private readonly PortUtil _portUtil; - - public OrderInfoDao(AppDataConnection connection, IOptions setting, GlobalStateService globalStateService, PortUtil portUtil) + NotificationService _message; + public OrderInfoDao(AppDataConnection connection, IOptions setting, GlobalStateService globalStateService, PortUtil portUtil, NotificationService message) { _connection = connection; _setting = setting.Value; _globalStateService = globalStateService; _portUtil = portUtil; + _message = message; } public async Task> GetAllOrderInfo(string OrderrNo, DateTime OrderDate, int? take, int? skip) @@ -596,7 +599,8 @@ namespace MasaBlazorApp3.DataAccess.Impl group od by od.OrderNo into temp select new { temp.Key }; var query = from oi in _connection.OrderInfo - from od in query2.InnerJoin(od => od.Key == oi.OrderNo) where oi.Pharmacy==_setting.storage + from od in query2.InnerJoin(od => od.Key == oi.OrderNo) + where oi.Pharmacy == _setting.storage select oi; if (!String.IsNullOrEmpty(OrderrNo)) { @@ -615,7 +619,7 @@ namespace MasaBlazorApp3.DataAccess.Impl int pagedData = await query.CountAsync(); List list = await query - .LoadWith(oi => oi.DetailList) + .LoadWith(oi => oi.DetailInfo) .OrderBy((oi) => oi.RecvDate) .ThenBy((oi => oi.OrderNo)) .Skip((int)skip) @@ -625,10 +629,17 @@ namespace MasaBlazorApp3.DataAccess.Impl { for (int i = 0; i < list.Count; i++) { - for (int j = 0; j < list[i].DetailList.Count; j++) + //for (int j = 0; j < list[i].DetailList.Count; j++) + //{ + if (list[i].DetailInfo != null && list[i].DetailInfo.Id > 0) { - list[i].DetailList[j].Drug = await _connection.DrugInfo.AsQueryable().Where(d => d.DrugId == list[i].DetailList[j].DrugId).FirstOrDefaultAsync(); + list[i].DetailInfo.Drug = await _connection.DrugInfo.AsQueryable().Where(d => d.DrugId == list[i].DetailInfo.DrugId).FirstOrDefaultAsync(); + if (list[i].DetailInfo.Drug != null) + { + list[i].DetailInfo.Drug.Manus = await _connection.DrugManuNo.AsQueryable().Where(m => m.DrugId == list[i].DetailInfo.DrugId).ToListAsync(); + } } + //} } } @@ -683,6 +694,70 @@ namespace MasaBlazorApp3.DataAccess.Impl }; } /// + /// 获取待处理处方中的麻醉师 + /// + /// + /// + /// + /// + /// + public async Task> GetAllOrderInfo(string Name, string OrderrNo, DateTime? OrderDate, int? take, int? skip) + { + var query2 = from od in _connection.OrderDetail + from cl in _connection.ChannelStock.Where(c => c.MachineId == _setting.boxMachineId).InnerJoin(c => c.DrugId == od.DrugId) + group od by od.OrderNo into temp + select new { temp.Key }; + var query = from oi in _connection.OrderInfo + from od in query2.InnerJoin(od => od.Key == oi.OrderNo) + where oi.Pharmacy == _setting.storage + select oi; + if (!string.IsNullOrEmpty(Name)) + { + query = query.Where(oi => oi.anaesthetistName == Name); + } + + if (!String.IsNullOrEmpty(OrderrNo)) + { + query = query.Where(oi => oi.OrderNo.Equals(OrderrNo)); + } + if (OrderDate != null && OrderDate != DateTime.MinValue) + { + query = query.Where(oi => oi.ChargeDate.Date.Equals(((DateTime)OrderDate).Date)); + } + query = query.Where(oi => oi.Status == 0); + query = query.Where(oi => oi.HisDispFlag == 0); + query = query.Where(oi => oi.CancelFlag == 0); + + int pagedData = await query.CountAsync(); + + List list = await query + .LoadWith(oi => oi.DetailInfo) + .OrderBy((oi) => oi.RecvDate) + .ThenBy((oi => oi.OrderNo)) + //.Skip((int)skip) + //.Take((int)take) + .ToListAsync(); + if (list != null && list.Count > 0) + { + for (int i = 0; i < list.Count; i++) + { + if (list[i].DetailInfo != null && list[i].DetailInfo.Id > 0) + { + list[i].DetailInfo.Drug = await _connection.DrugInfo.AsQueryable().Where(d => d.DrugId == list[i].DetailInfo.DrugId).FirstOrDefaultAsync(); + if (list[i].DetailInfo.Drug != null) + { + list[i].DetailInfo.Drug.Manus = await _connection.DrugManuNo.AsQueryable().Where(m => m.DrugId == list[i].DetailInfo.DrugId).ToListAsync(); + } + } + } + } + return new PageData() + { + TotalDesserts = pagedData, + Desserts = list + }; + } + /// /// 获取所有药盒号 /// /// @@ -710,201 +785,208 @@ namespace MasaBlazorApp3.DataAccess.Impl int drawerNo = DrawerNo; - if (oi.DetailList != null && oi.DetailList.Count > 0) + if (oi.DetailInfo != null && oi.DetailInfo.Id > 0) { - for (int j = 0; j < oi.DetailList.Count; j++) + //ChannelStock? cs = _connection.ChannelStock.AsQueryable() + // .Where(cs => cs.DrugId == oi.DetailList[j].DrugId + // // && cs.ManuNo == oi.DetailList[j].SetManuNo + // // && cs.EffDate == oi._OrderDetail.SetEffDate + // && cs.MachineId.Equals(_setting.boxMachineId) + // && cs.DrawerNo == drawerNo + // && cs.Quantity >= oi.DetailList[j].Quantity).FirstOrDefault(); + List cs = _connection.ChannelStock.AsQueryable() + .Where(cs => cs.DrugId == oi.DetailInfo.DrugId + && cs.ManuNo == oi.DetailInfo.drugManuNo.ManuNo + && cs.EffDate == ((DateTime)oi.DetailInfo.drugManuNo.EffDate).ToString("yyyy-MM-dd") + && cs.MachineId.Equals(_setting.boxMachineId) + && cs.DrawerNo == drawerNo).OrderBy(cs => cs.EffDate).ToList(); + if (cs.Count <= 0) { - //ChannelStock? cs = _connection.ChannelStock.AsQueryable() - // .Where(cs => cs.DrugId == oi.DetailList[j].DrugId - // // && cs.ManuNo == oi.DetailList[j].SetManuNo - // // && cs.EffDate == oi._OrderDetail.SetEffDate - // && cs.MachineId.Equals(_setting.boxMachineId) - // && cs.DrawerNo == drawerNo - // && cs.Quantity >= oi.DetailList[j].Quantity).FirstOrDefault(); - List cs = _connection.ChannelStock.AsQueryable() - .Where(cs => cs.DrugId == oi.DetailList[j].DrugId - // && cs.ManuNo == oi.DetailList[j].SetManuNo - // && cs.EffDate == oi._OrderDetail.SetEffDate - && cs.MachineId.Equals(_setting.boxMachineId) - && cs.DrawerNo == drawerNo).OrderBy(cs => cs.EffDate).ToList(); - if (cs.Count <= 0) + logger.Info($"处方{oi.OrderNo}中药品{oi.DetailInfo.DrugId}在{drawerNo}号药盒无库存"); + empChannelStock += $"处方{oi.OrderNo}中药品{oi.DetailInfo.DrugId}在{drawerNo}号药盒无库存 "; + continue; + } + int csQuantity = cs.Sum(cs => cs.Quantity); + if (csQuantity < oi.DetailInfo.Quantity) + { + logger.Info($"处方{oi.OrderNo}中药品{oi.DetailInfo.DrugId}在{drawerNo}号库存不足,需要核对数{oi.DetailInfo.Quantity},库存总数{csQuantity}"); + empChannelStock += $"处方{oi.OrderNo}中药品{oi.DetailInfo.DrugId}在{drawerNo}号库存不足,需要核对数{oi.DetailInfo.Quantity},库存总数{csQuantity} "; + continue; + } + //更新处方状态 + if (oi.Status == 0) + { + int iUpdate = _connection.OrderInfo.Where(o => o.OrderNo == oi.OrderNo).Set(o => o.Status, 2).Update(); + _connection.Insert(new OrderFinish() { - logger.Info($"处方{oi.OrderNo}中药品{oi.DetailList[j].DrugId}在{drawerNo}号药盒无库存"); - continue; + OrderNo = oi.OrderNo, + PatientId = oi.PatientId, + Pharmacy = oi.Pharmacy, + State = 1, + //WinNo = DrawerNo + 1 + "号手术间", + Operator = _globalStateService.Operator.NickName, + }); + } + int Break = 0; + for (int k = 0; (k < cs.Count && Break == 0); k++) + { + int oldQuantity = cs[k].Quantity; + int useQuantity = 0; //实际使用数量 + if (cs[k].Quantity >= oi.DetailInfo.Quantity) + { + cs[k].Quantity = cs[k].Quantity - oi.DetailInfo.Quantity; + Break = 1;//药品够取跳出循环 + useQuantity = oi.DetailInfo.Quantity; } - int csQuantity = cs.Sum(cs => cs.Quantity); - if (csQuantity < oi.DetailList[j].Quantity) + else { - logger.Info($"处方{oi.OrderNo}中药品{oi.DetailList[j].DrugId}在{drawerNo}号库存不足,需要核对数{oi.DetailList[j].Quantity},库存总数{csQuantity}"); - continue; + oi.DetailInfo.Quantity = oi.DetailInfo.Quantity - cs[k].Quantity; + useQuantity = cs[k].Quantity; + cs[k].Quantity = 0; } - //更新处方状态 - if (oi.Status == 0) - { - int iUpdate = _connection.OrderInfo.Where(o => o.OrderNo == oi.OrderNo).Set(o => o.Status, 2).Update(); - _connection.Insert(new OrderFinish() - { - OrderNo = oi.OrderNo, - PatientId = oi.PatientId, - Pharmacy = oi.Pharmacy, - State = 1, - //WinNo = DrawerNo + 1 + "号手术间", - Operator = _globalStateService.Operator.NickName, - }); - } - int Break = 0; - for (int k = 0; (k < cs.Count&&Break==0); k++) - { - int oldQuantity = cs[k].Quantity; - int useQuantity = 0; //实际使用数量 - if (cs[k].Quantity >= oi.DetailList[j].Quantity) - { - cs[k].Quantity = cs[k].Quantity - oi.DetailList[j].Quantity; - Break = 1;//药品够取跳出循环 - useQuantity = oi.DetailList[j].Quantity; - } - else - { - oi.DetailList[j].Quantity = oi.DetailList[j].Quantity - cs[k].Quantity; - useQuantity = cs[k].Quantity; - cs[k].Quantity = 0; - } - //cs.NeedNum = cs.NeedNum > 0 ? cs.NeedNum + oi._OrderDetail.Quantity : oi._OrderDetail.Quantity; - logger.Info($"更新药盒{cs[k].DrawerNo}药品{cs[k].DrugId}批次{cs[k].ManuNo}库存为{oldQuantity},处方用药数量为{oi.DetailList[j].Quantity}"); - // 更新数据 库存信息 - _connection.Update(cs[k]); + //cs.NeedNum = cs.NeedNum > 0 ? cs.NeedNum + oi._OrderDetail.Quantity : oi._OrderDetail.Quantity; + logger.Info($"更新药盒{cs[k].DrawerNo}药品{cs[k].DrugId}批次{cs[k].ManuNo}库存为{oldQuantity},处方用药数量为{oi.DetailInfo.Quantity}"); + // 更新数据 库存信息 + _connection.Update(cs[k]); - //更新ChannelList对应的总库存 - ChannelList? channelList = _connection.ChannelList.AsQueryable().Where(cl => cl.MachineId.Equals(cs[k].MachineId) && cl.Id.Equals(cs[k].ListId) && cl.DrawerNo.Equals(cs[k].DrawerNo)).FirstOrDefault(); - if (channelList != null) - { - channelList.TotalQuantity = channelList.TotalQuantity - useQuantity;// oi.DetailList[j].Quantity; - _connection.Update(channelList); - } - // 获取更新完库存后的药品库存 - List nowChannels = _connection.ChannelStock.AsQueryable() - .Where(it => it.MachineId.Equals(cs[k].MachineId) || it.MachineId.Equals(_setting.machineId)) - .Where(it => it.DrugId.Equals(cs[k].DrugId)) - .Where(it => it.ManuNo.Equals(cs[k].ManuNo)) - .Where(it => it.DrawerType == 1) - .ToList(); - _connection.Insert(new MachineRecord() - { - MachineId = _setting.machineId, - DrawerNo = cs[k].DrawerNo, - ColNo = cs[k].ColNo, - DrugId = cs[k].DrugId, - ManuNo = cs[k].ManuNo, - EffDate = !String.IsNullOrEmpty(cs[k].EffDate) ? DateTime.ParseExact(cs[k].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, - Operator = _globalStateService.Operator?.Id, - Reviewer = _globalStateService.Reviewer?.Id, - OperationTime = DateTime.Now, - Quantity = useQuantity,// oi.DetailList[j].Quantity, - Type = 2, - InvoiceId = oi.OrderNo - //, StockQuantity = nowChannels.Sum(it => it.Quantity) - }); + //更新ChannelList对应的总库存 + ChannelList? channelList = _connection.ChannelList.AsQueryable().Where(cl => cl.MachineId.Equals(cs[k].MachineId) && cl.Id.Equals(cs[k].ListId) && cl.DrawerNo.Equals(cs[k].DrawerNo)).FirstOrDefault(); + if (channelList != null) + { + channelList.TotalQuantity = channelList.TotalQuantity - useQuantity;// oi.DetailList[j].Quantity; + _connection.Update(channelList); + } + // 获取更新完库存后的药品库存 + List nowChannels = _connection.ChannelStock.AsQueryable() + .Where(it => it.MachineId.Equals(cs[k].MachineId) || it.MachineId.Equals(_setting.machineId)) + .Where(it => it.DrugId.Equals(cs[k].DrugId)) + .Where(it => it.ManuNo.Equals(cs[k].ManuNo)) + .Where(it => it.DrawerType == 1) + .ToList(); + _connection.Insert(new MachineRecord() + { + MachineId = _setting.machineId, + DrawerNo = cs[k].DrawerNo, + ColNo = cs[k].ColNo, + DrugId = cs[k].DrugId, + ManuNo = cs[k].ManuNo, + EffDate = !String.IsNullOrEmpty(cs[k].EffDate) ? DateTime.ParseExact(cs[k].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null, + Operator = _globalStateService.Operator?.Id, + Reviewer = _globalStateService.Reviewer?.Id, + OperationTime = DateTime.Now, + Quantity = useQuantity,// oi.DetailList[j].Quantity, + Type = 2, + InvoiceId = oi.OrderNo + //, StockQuantity = nowChannels.Sum(it => it.Quantity) + }); - //查询上一条账册中的空瓶数 - AccountBookG2? accountBookEmpty = _connection.AccountBookG2.AsQueryable() - .Where(ab => ab.MachineId.Equals(_setting.machineId)) - .Where(ab => ab.Type == 1 || ab.Type == 2) - .Where(ab => ab.DrugId == oi.DetailList[j].DrugId) - .Where(ab => ab.ManuNo == cs[k].ManuNo).OrderByDescending(ab => ab.Id).FirstOrDefault(); - //保存账册 - int iInsertResult = _connection.Insert(new AccountBookG2() + //查询上一条账册中的空瓶数 + AccountBookG2? accountBookEmpty = _connection.AccountBookG2.AsQueryable() + .Where(ab => ab.MachineId.Equals(_setting.machineId)) + .Where(ab => ab.Type == 1 || ab.Type == 2) + .Where(ab => ab.DrugId == oi.DetailInfo.DrugId) + .Where(ab => ab.ManuNo == cs[k].ManuNo).OrderByDescending(ab => ab.Id).FirstOrDefault(); + //保存账册 + int iInsertResult = _connection.Insert(new AccountBookG2() + { + DrugId = oi.DetailInfo.DrugId, + Type = 2, + Department = oi.DeptName, + OrderNo = oi.OrderNo, + ManuNo = cs[k].ManuNo, + EffDate = cs[k].EffDate, + OutQuantity = useQuantity,// oi.DetailList[j].Quantity, + UserId1 = _globalStateService.Operator?.Id, + UserId2 = _globalStateService.Reviewer?.Id, + MachineId = _setting.machineId, + CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), + CreateTime = DateTime.Now, + InvoiceNo = oi.OrderNo, + ManuStock = nowChannels.Sum(it => it.Quantity), + TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi.DetailInfo.Quantity, + ShoushuJian = drawerNo.ToString() + }); + //修改凌晨生成的日结存与总结存数据 + AccountBookG2? accountBookG2Day = _connection.AccountBookG2.AsQueryable() + .Where(ab => ab.MachineId.Equals(_setting.machineId)) + .Where(ab => ab.Type == 3) + .Where(ab => ab.DrugId == oi.DetailInfo.DrugId) + .Where(ab => ab.ManuNo == cs[k].ManuNo) + .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).FirstOrDefault(); + if (accountBookG2Day != null) + { + accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - useQuantity;// oi.DetailList[j].Quantity; + _connection.Update(accountBookG2Day); + } + else + { + //生成日结存时可能没有该库位的绑定信息,需要写入日结存 + int iDayResult = _connection.Insert(new AccountBookG2() { - DrugId = oi.DetailList[j].DrugId, - Type = 2, - Department = oi.DeptName, - OrderNo = oi.OrderNo, + DrugId = oi.DetailInfo.DrugId, + Type = 3, ManuNo = cs[k].ManuNo, EffDate = cs[k].EffDate, - OutQuantity = useQuantity,// oi.DetailList[j].Quantity, + YQuantity = 0, + ManuStock = useQuantity,// oi.DetailList[j].Quantity, + TotalStock = useQuantity,// oi.DetailList[j].Quantity, UserId1 = _globalStateService.Operator?.Id, UserId2 = _globalStateService.Reviewer?.Id, MachineId = _setting.machineId, CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), - CreateTime = DateTime.Now, - InvoiceNo = oi.OrderNo, - ManuStock = nowChannels.Sum(it => it.Quantity), - TotalStock = (accountBookEmpty != null ? (accountBookEmpty.TotalStock > 0 ? accountBookEmpty.TotalStock : 0) : 0) + oi.DetailList[j].Quantity, - ShoushuJian = drawerNo.ToString() + InvoiceNo = "日结存" }); - //修改凌晨生成的日结存与总结存数据 - AccountBookG2? accountBookG2Day = _connection.AccountBookG2.AsQueryable() - .Where(ab => ab.MachineId.Equals(_setting.machineId)) - .Where(ab => ab.Type == 3) - .Where(ab => ab.DrugId == oi.DetailList[j].DrugId) - .Where(ab => ab.ManuNo == cs[k].ManuNo) - .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).FirstOrDefault(); - if (accountBookG2Day != null) + if (iDayResult <= 0) { - accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - useQuantity;// oi.DetailList[j].Quantity; - _connection.Update(accountBookG2Day); + logger.Info($"未写入日结存数据{oi.DetailInfo.DrugId}-{cs[k].ManuNo}-{cs[k].EffDate}-{useQuantity}"); + empChannelStock += $"未写入日结存数据{oi.DetailInfo.DrugId}-{cs[k].ManuNo}-{cs[k].EffDate}-{useQuantity} "; } - else + } + //修改凌晨生成的日结存与总结存数据 + AccountBookG2? accountBookG2Total = _connection.AccountBookG2.AsQueryable() + .Where(ab => ab.MachineId.Equals(_setting.machineId)) + .Where(ab => ab.Type == 4) + .Where(ab => ab.DrugId == oi.DetailInfo.DrugId) + .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).FirstOrDefault(); + if (accountBookG2Total != null) + { + accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - useQuantity;// oi.DetailList[j].Quantity; + _connection.Update(accountBookG2Total); + } + else + { + //生成总结存时可能没有该库位的绑定信息,需要写入总结存 + int iTotalResult = _connection.Insert(new AccountBookG2() { - //生成日结存时可能没有该库位的绑定信息,需要写入日结存 - int iDayResult = _connection.Insert(new AccountBookG2() - { - DrugId = oi.DetailList[j].DrugId, - Type = 3, - ManuNo = cs[k].ManuNo, - EffDate = cs[k].EffDate, - YQuantity = 0, - ManuStock = useQuantity,// oi.DetailList[j].Quantity, - TotalStock = useQuantity,// oi.DetailList[j].Quantity, - UserId1 = _globalStateService.Operator?.Id, - UserId2 = _globalStateService.Reviewer?.Id, - MachineId = _setting.machineId, - CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), - InvoiceNo = "日结存" - }); - if (iDayResult <= 0) - { - logger.Info($"未写入日结存数据{oi.DetailList[j].DrugId}-{cs[k].ManuNo}-{cs[k].EffDate}-{useQuantity}"); - } - } - //修改凌晨生成的日结存与总结存数据 - AccountBookG2? accountBookG2Total = _connection.AccountBookG2.AsQueryable() - .Where(ab => ab.MachineId.Equals(_setting.machineId)) - .Where(ab => ab.Type == 4) - .Where(ab => ab.DrugId == oi.DetailList[j].DrugId) - .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).FirstOrDefault(); - if (accountBookG2Total != null) + DrugId = oi.DetailInfo.DrugId, + Type = 4, + YQuantity = 0, + ManuStock = useQuantity,//oi.DetailList[j].Quantity, + TotalStock = useQuantity,// oi.DetailList[j].Quantity, + UserId1 = _globalStateService.Operator?.Id, + UserId2 = _globalStateService.Reviewer?.Id, + MachineId = _setting.machineId, + CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), + InvoiceNo = "总结存" + }); + if (iTotalResult <= 0) { - accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - useQuantity;// oi.DetailList[j].Quantity; - _connection.Update(accountBookG2Total); - } - else - { - //生成总结存时可能没有该库位的绑定信息,需要写入总结存 - int iTotalResult = _connection.Insert(new AccountBookG2() - { - DrugId = oi.DetailList[j].DrugId, - Type = 4, - YQuantity = 0, - ManuStock = useQuantity,//oi.DetailList[j].Quantity, - TotalStock = useQuantity,// oi.DetailList[j].Quantity, - UserId1 = _globalStateService.Operator?.Id, - UserId2 = _globalStateService.Reviewer?.Id, - MachineId = _setting.machineId, - CreateDate = DateTime.Now.ToString("yyyy-MM-dd"), - InvoiceNo = "总结存" - }); - if (iTotalResult <= 0) - { - logger.Info($"未写入总结存数据{oi.DetailList[j].DrugId}-{useQuantity}"); - } + logger.Info($"未写入总结存数据{oi.DetailInfo.DrugId}-{useQuantity}"); + empChannelStock += $"未写入总结存数据{oi.DetailInfo.DrugId}-{useQuantity} "; } } } + } } logger.Info($"管理员{_globalStateService.Operator.NickName}结束确认手麻单"); - + if(!string.IsNullOrEmpty(empChannelStock)) + { + _message.Notify( + new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = $"有未核对处方:{empChannelStock}", Duration = 4000 } + ); + } if (bFlag) { _connection.CommitTransaction(); diff --git a/MasaBlazorApp3/DataAccess/Impl/PlanDao.cs b/MasaBlazorApp3/DataAccess/Impl/PlanDao.cs index 126ab2b..0c55b77 100644 --- a/MasaBlazorApp3/DataAccess/Impl/PlanDao.cs +++ b/MasaBlazorApp3/DataAccess/Impl/PlanDao.cs @@ -119,7 +119,7 @@ namespace MasaBlazorApp3.DataAccess.Impl plan.OperatorUser = _globalStateService.Operator.Id; plan.ReviewerUser = _globalStateService.Reviewer?.Id ?? _globalStateService.Operator.Id; plan.UseState = 1; - plan.MachineId = _setting.machineId; + plan.MachineId = _setting.boxMachineId; if(_connection.InsertWithInt32Identity(plan) > 0) { //保存操作记录 diff --git a/MasaBlazorApp3/DataAccess/Impl/ReportDataDao.cs b/MasaBlazorApp3/DataAccess/Impl/ReportDataDao.cs index 78e0f5a..09cff6f 100644 --- a/MasaBlazorApp3/DataAccess/Impl/ReportDataDao.cs +++ b/MasaBlazorApp3/DataAccess/Impl/ReportDataDao.cs @@ -104,7 +104,7 @@ namespace MasaBlazorApp3.DataAccess.Impl }; } //手术室患者麻醉药品使用登记本 - public async Task> GetOrderInfoData(DateTime searchDate) + public async Task> GetOrderInfoData(DateTime? searchDate) { List accountList = new List(); int pagedData = 0; @@ -112,7 +112,7 @@ namespace MasaBlazorApp3.DataAccess.Impl string SQL = $@"SELECT oi.Order_date as portdate, od.drug_id as DrugId,1 as ShouShuJian,'' as ZhuMa,'' as FuMa,oi.patient_id as IDNumber,oi.p_name as PName,oi.disease as Diagnose, CONCAT(di.drug_name,' ',di.drug_spec) as DrugName,od.set_manu_No as ManuNo,od.use_dosage as UsageDosage,'' as CanYeLiang,'' as CanYeChuZhi,'' as UseUserName,'' as CheckUserName from order_info oi inner join order_detail od on oi.order_no=od.order_no inner join drug_info di on od.drug_id=di.drug_id - WHERE DATE_FORMAT(oi.Order_date,'%Y-%m-%d')='{searchDate.ToString("yyyy-MM-dd")}' and oi.dm_status=2 and oi.cancel_flag=0 and oi.his_disp_flag=0 and di.pack_h=1"; + WHERE DATE_FORMAT(oi.Order_date,'%Y-%m-%d')='{searchDate?.ToString("yyyy-MM-dd")}' and oi.dm_status=2 and oi.cancel_flag=0 and oi.his_disp_flag=0 and di.pack_h=1"; @@ -149,7 +149,7 @@ namespace MasaBlazorApp3.DataAccess.Impl var reportList = _connection.FromSql(SQL); - if (reportList != null) + if (reportList != null&& reportList.Count()>0) { foreach (var report in reportList) { diff --git a/MasaBlazorApp3/Pages/BoxAddDrug.razor b/MasaBlazorApp3/Pages/BoxAddDrug.razor index 2a2a2fc..a789e10 100644 --- a/MasaBlazorApp3/Pages/BoxAddDrug.razor +++ b/MasaBlazorApp3/Pages/BoxAddDrug.razor @@ -41,7 +41,7 @@ .my-popup { display: none; - /* position:absolute; */ + position:absolute; overflow: hidden; /* height: 360px; width: 600px; */ @@ -66,7 +66,7 @@ - + diff --git a/MasaBlazorApp3/Pages/BoxBindNew.razor b/MasaBlazorApp3/Pages/BoxBindNew.razor index 63cf6f2..acf9a62 100644 --- a/MasaBlazorApp3/Pages/BoxBindNew.razor +++ b/MasaBlazorApp3/Pages/BoxBindNew.razor @@ -11,8 +11,8 @@ foreach (var item in BoxList) {
- - + +
} } @@ -91,7 +91,7 @@ if (bindList == null || bindList.Count <= 0) { _message.Notify( - new NotificationMessage { Severity = NotificationSeverity.Success, Summary = "提示", Detail = $"请先选择药箱号再点击按钮", Duration = 4000 } + new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = $"请先选择药箱号再点击按钮", Duration = 4000 } ); return; } @@ -157,6 +157,8 @@ _message.Notify( new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "提示", Detail = $"该药盒下的药品仍有库存,请清库存后再操作", Duration = 4000 } ); + BoxList.ForEach(it => it.IsChecked = false); + firstFlag = 0; return; } else diff --git a/MasaBlazorApp3/Pages/BoxStock.razor b/MasaBlazorApp3/Pages/BoxStock.razor index 8ebc45d..e5678c9 100644 --- a/MasaBlazorApp3/Pages/BoxStock.razor +++ b/MasaBlazorApp3/Pages/BoxStock.razor @@ -3,7 +3,7 @@
-
+
@foreach (int i in DrawerNos) { @@ -12,7 +12,7 @@
-