From eb7fc78760cb6b18212853aadec6ce929012065e Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Tue, 20 Aug 2024 13:59:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B8=E5=AF=B9=E5=A4=84?= =?UTF-8?q?=E6=96=B9=E4=B8=8E=E5=BC=80=E6=8A=BD=E5=B1=89=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/Models/ChannelList.cs | 2 +- .../CheckOrderNewWindowViewModel.cs | 22 +++---- .../ViewModels/OpenBoxWindowViewModel.cs | 60 +++++++++---------- .../ViewModels/WSDRecordWindowViewModel.cs | 17 +++++- DM_Weight/Views/CheckOrderNewWindow.xaml | 5 +- DM_Weight/Views/WSDRecordWindow.xaml | 12 ++-- 6 files changed, 67 insertions(+), 51 deletions(-) diff --git a/DM_Weight/Models/ChannelList.cs b/DM_Weight/Models/ChannelList.cs index 43e70d1..fc1cf4a 100644 --- a/DM_Weight/Models/ChannelList.cs +++ b/DM_Weight/Models/ChannelList.cs @@ -73,7 +73,7 @@ namespace DM_Weight.Models /// /// - /// 默认值: 1 + /// 默认值: 1 (公共药箱值为1,归属个人药箱值为0) /// [SugarColumn(ColumnName = "drawer_type")] public int DrawerType { get; set; } diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs index 0a7047a..361ff65 100644 --- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs +++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs @@ -17,6 +17,7 @@ using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; +using System.Windows; namespace DM_Weight.ViewModels { @@ -94,12 +95,13 @@ namespace DM_Weight.ViewModels RequestData(); } } - private bool _isEnable = true; - public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); } + private Visibility _isEnableList = Visibility.Collapsed; + public Visibility IsEnableList { get => _isEnableList; set => SetProperty(ref _isEnableList, value); } private int _status = 0; public int Status { get => _status; set { SetProperty(ref _status, value); } } + private List _ordersList = new List(); public List OrderInfoList { @@ -146,11 +148,12 @@ namespace DM_Weight.ViewModels int totalCount = 0; if (DrawerNo >= 0) { + IsEnableList = Visibility.Visible; //查询当前药箱归属的药师 - string currentDrawerUser = SqlSugarHelper.Db.Queryable().Where(cl => cl.DrawerNo == DrawerNo && cl.MachineId == "DM5").Select(cl => cl.BelongUser).First(); + string currentDrawerUser = SqlSugarHelper.Db.Queryable().Where(cl => cl.DrawerNo == DrawerNo + 1 && cl.MachineId == "DM5").Select(cl => cl.BelongUser).First(); OrderInfoList = SqlSugarHelper.Db.Queryable() - .Includes(oi=>oi._OrderDetail,od=>od.DrugInfo) + .Includes(oi => oi._OrderDetail, od => od.DrugInfo) //.Includes(cl => cl.channelStocks, cs => cs.DrugInfo,di=>di.drugBase) //.InnerJoin((oi, od) => oi.OrderNo == od.OrderNo) //.InnerJoin((oi, od, di) => od.DrugId == di.DrugId.ToString()) @@ -159,7 +162,7 @@ namespace DM_Weight.ViewModels .Where(oi => oi.DmStatus == 0) .Where(oi => oi.HisDispFlag == 0) .Where(oi => oi.CancelFlag == 0) - .WhereIF(currentDrawerUser != null, oi => oi.DoctorCode == currentDrawerUser) + .Where(oi => oi.DoctorCode == currentDrawerUser) .OrderBy(oi => oi.OrderId) .ToPageList(PageNum, PageSize, ref totalCount); @@ -251,7 +254,7 @@ namespace DM_Weight.ViewModels //Expression> updateExp = it => it.ManuNo == oi._OrderDetail.SetManuNo && it.EffDate == oi._OrderDetail.SetEffDate; - 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).First(); + 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).First(); if (cs == null) { empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo},{oi._OrderDetail.SetEffDate}"; @@ -429,9 +432,8 @@ namespace DM_Weight.ViewModels { DrawerNo -= 1; RequestData(); - IsEnable = false; Status = 1; - _portUtil.SpeakAsync($"正在打开{DrawerNo+1}号药箱"); + _portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱"); //记录开药箱日志 SqlSugarHelper.Db.Insertable(new MachineRecord() { @@ -440,7 +442,7 @@ namespace DM_Weight.ViewModels Operator = HomeWindowViewModel.Operator?.Id, OperationTime = DateTime.Now, Type = 55, - InvoiceId = $"打开{DrawerNo+1}号药箱", + InvoiceId = $"打开{DrawerNo + 1}号药箱", }).ExecuteCommand(); ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo); } @@ -501,7 +503,6 @@ namespace DM_Weight.ViewModels { Status = 3; } - IsEnable = true; _portUtil.Operate = false; break; // 打开失败 @@ -513,7 +514,6 @@ namespace DM_Weight.ViewModels }; _eventAggregator.GetEvent().Publish(alertMsg); - IsEnable = true; Status = 0; //记录药箱操作日志 diff --git a/DM_Weight/ViewModels/OpenBoxWindowViewModel.cs b/DM_Weight/ViewModels/OpenBoxWindowViewModel.cs index 9dbab4a..95d0fe3 100644 --- a/DM_Weight/ViewModels/OpenBoxWindowViewModel.cs +++ b/DM_Weight/ViewModels/OpenBoxWindowViewModel.cs @@ -21,12 +21,12 @@ namespace DM_Weight.ViewModels public class OpenBoxWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime { private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel)); - private int _drawerNo = -1; + private int _drawerType = -1; - public int DrawerNo + public int DrawerType { - get => _drawerNo; - set => SetProperty(ref _drawerNo, value); + get => _drawerType; + set => SetProperty(ref _drawerType, value); } private int status = 0; @@ -43,10 +43,10 @@ namespace DM_Weight.ViewModels //公共药箱状态 private int _publicStatus = 0; - public int PublicStatus { get => _publicStatus;set=>SetProperty(ref _publicStatus, value); } + public int PublicStatus { get => _publicStatus; set => SetProperty(ref _publicStatus, value); } //名下药箱状态 private int _selfStatus = 0; - public int SelfStatus { get => _publicStatus;set=>SetProperty(ref _publicStatus,value); } + public int SelfStatus { get => _publicStatus; set => SetProperty(ref _publicStatus, value); } //抽屉号列表 @@ -55,21 +55,21 @@ namespace DM_Weight.ViewModels //public static int iNumber = 1; private PortUtil _portUtil; IEventAggregator _eventAggregator; - public OpenBoxWindowViewModel(PortUtil portUtil,IEventAggregator eventAggregator) + public OpenBoxWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator) { _portUtil = portUtil; _eventAggregator = eventAggregator; } public DelegateCommand OpenBoxDelegate { - get => new DelegateCommand((DrawerNo) => + get => new DelegateCommand((DrawerType) => { - this.DrawerNo = Convert.ToInt32(DrawerNo); - switch (this.DrawerNo) + this.DrawerType = Convert.ToInt32(DrawerType); + switch (this.DrawerType) { case 0: PublicEnable = false; - PublicStatus=1; + PublicStatus = 1; break; case 1: SelfEnable = false; @@ -82,8 +82,8 @@ namespace DM_Weight.ViewModels } private void SearchBox() { - iList = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerNo) - .WhereIF(this.DrawerNo==0,cl=> cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode) + iList = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.DrawerType == this.DrawerType) + .WhereIF(this.DrawerType == 0, cl => cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode) .Select(cl => cl.DrawerNo).ToList(); if (iList.Count > 0) { @@ -91,7 +91,6 @@ namespace DM_Weight.ViewModels //_portUtil.DrawerNo = iList[iNumber]; //iNumber++; //_portUtil.OpenBox(); - logger.Info(""); for (int i = 0; i < iList.Count; i++) { @@ -106,6 +105,7 @@ namespace DM_Weight.ViewModels InvoiceId = $"打开{iList[i]}号药箱", }).ExecuteCommand(); _portUtil.SpeakAsync($"正在打开{iList[i]}号药箱"); + logger.Info($"正在打开{iList[i]}号药箱"); ModbusHelper.GetInstance().OpenBoxDoor(iList[i] - 1); Thread.Sleep(1000); } @@ -114,7 +114,7 @@ namespace DM_Weight.ViewModels SelfStatus = 0; PublicEnable = true; SelfEnable = true; - DrawerNo = -1; + DrawerType = -1; } } void DoMyPrismEvent(DeviceMsg msg) @@ -136,22 +136,22 @@ namespace DM_Weight.ViewModels //if (iNumber < iList.Count) //{ - //_portUtil.DrawerNo = iList[iNumber]; - //iNumber++; - if(PublicStatus==1) - { - PublicStatus = 2; - } - else - { - SelfStatus = 2; - } - //_portUtil.OpenBox(); + //_portUtil.DrawerNo = iList[iNumber]; + //iNumber++; + if (PublicStatus == 1) + { + PublicStatus = 2; + } + else + { + SelfStatus = 2; + } + //_portUtil.OpenBox(); //} //else //{ - //iNumber = 0; - //_portUtil.GetBoxStatus(); + //iNumber = 0; + //_portUtil.GetBoxStatus(); //} break; // 药箱关闭 @@ -177,7 +177,7 @@ namespace DM_Weight.ViewModels } PublicEnable = true; SelfEnable = true; - DrawerNo = -1; + DrawerType = -1; //_portUtil.Operate = false; break; // 打开失败 @@ -191,7 +191,7 @@ namespace DM_Weight.ViewModels PublicEnable = true; SelfEnable = true; - DrawerNo = -1; + DrawerType = -1; PublicStatus = 0; SelfStatus = 0; diff --git a/DM_Weight/ViewModels/WSDRecordWindowViewModel.cs b/DM_Weight/ViewModels/WSDRecordWindowViewModel.cs index ae066d4..47ecc5d 100644 --- a/DM_Weight/ViewModels/WSDRecordWindowViewModel.cs +++ b/DM_Weight/ViewModels/WSDRecordWindowViewModel.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace DM_Weight.ViewModels { - public class WSDRecordWindowViewModel : BindableBase, IRegionMemberLifetime + public class WSDRecordWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime { private int _pageNum = 1; public int PageNum @@ -122,5 +122,20 @@ namespace DM_Weight.ViewModels //.ToList(); TotalCount = totalCount; } + + public void OnNavigatedTo(NavigationContext navigationContext) + { + RequestData(); + } + + public bool IsNavigationTarget(NavigationContext navigationContext) + { + return true; + } + + public void OnNavigatedFrom(NavigationContext navigationContext) + { + + } } } diff --git a/DM_Weight/Views/CheckOrderNewWindow.xaml b/DM_Weight/Views/CheckOrderNewWindow.xaml index 199a5cb..4febf7e 100644 --- a/DM_Weight/Views/CheckOrderNewWindow.xaml +++ b/DM_Weight/Views/CheckOrderNewWindow.xaml @@ -99,7 +99,7 @@