From 5e9198cf59ec4ef84cbb9ad1b8adcdffce553cc1 Mon Sep 17 00:00:00 2001
From: maqiao <625215135@qq.com>
Date: Tue, 5 Nov 2024 08:49:56 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E4=B8=8A=EF=BC=8C=E5=88=9A=E5=88=9A?=
=?UTF-8?q?=E6=9C=AA=E6=8F=90=E4=BA=A4=E4=B8=8A=E5=8E=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DM_Weight/App.config | 4 +-
DM_Weight/Models/DrugInfo.cs | 2 +
DM_Weight/Port/ModbusHelper.cs | 5 +-
.../BindBoxPackageWindowViewModel.cs | 7 +-
.../CheckOrderNewWindowViewModel.cs | 4 +-
.../ViewModels/EditUserDialogViewModel.cs | 2 +-
DM_Weight/ViewModels/HomeWindowViewModel.cs | 232 +++++++++++++-----
.../ViewModels/OpenBoxNewWindowViewModel.cs | 4 +-
.../ViewModels/SettingBoxWindowViewModel.cs | 32 ++-
DM_Weight/Views/BindBoxPackageWindow.xaml | 2 +-
DM_Weight/Views/HomeWindow.xaml | 6 +-
11 files changed, 209 insertions(+), 91 deletions(-)
diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 2d4cf09..27b072d 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -3,7 +3,7 @@
-
+
-
+
diff --git a/DM_Weight/Models/DrugInfo.cs b/DM_Weight/Models/DrugInfo.cs
index 948246c..ec67235 100644
--- a/DM_Weight/Models/DrugInfo.cs
+++ b/DM_Weight/Models/DrugInfo.cs
@@ -96,6 +96,8 @@ namespace DM_Weight.Models
get=> _base;
set { SetProperty(ref _base, value); }
}
+ [SugarColumn(IsIgnore = true)]
+ public string drug_name_spec { get; set; }
diff --git a/DM_Weight/Port/ModbusHelper.cs b/DM_Weight/Port/ModbusHelper.cs
index e69ed21..98d5294 100644
--- a/DM_Weight/Port/ModbusHelper.cs
+++ b/DM_Weight/Port/ModbusHelper.cs
@@ -74,8 +74,9 @@ namespace DM_Weight.Port
});
return bools;
}
- public void OpenBoxDoor(int boxNum)
+ public bool OpenBoxDoor(int boxNum)
{
+ bool bFlag=false;
Policy.Handle().Retry(3, ((exception, retryCount) =>
{
this.Dispose();
@@ -86,7 +87,9 @@ namespace DM_Weight.Port
{
master.WriteSingleRegister(1, (ushort)boxNum, 14);
Console.WriteLine($"开门指令已发送{(ushort)boxNum}");
+ bFlag = true;
});
+ return bFlag;
}
private void Dispose()
{
diff --git a/DM_Weight/ViewModels/BindBoxPackageWindowViewModel.cs b/DM_Weight/ViewModels/BindBoxPackageWindowViewModel.cs
index 9f48a15..b70bc0c 100644
--- a/DM_Weight/ViewModels/BindBoxPackageWindowViewModel.cs
+++ b/DM_Weight/ViewModels/BindBoxPackageWindowViewModel.cs
@@ -163,8 +163,11 @@ namespace DM_Weight.ViewModels
}
private void RequestDrug()
{
- var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
- DrugInfos = list;
+ //var list = SqlSugarHelper.Db.Queryable().Includes(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
+ //DrugInfos = 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,' / ',manufactory) as drug_name_spec FROM `drug_info` d";
+ DrugInfos = SqlSugarHelper.Db.SqlQueryable(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
+
}
public DelegateCommand BindingDrug
{
diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
index 86b0604..4f92c02 100644
--- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
@@ -389,10 +389,10 @@ namespace DM_Weight.ViewModels
Button9Color = Brushes.Yellow;
break;
case 10:
- Button9Color = Brushes.Yellow;
+ Button10Color = Brushes.Yellow;
break;
case 11:
- Button9Color = Brushes.Yellow;
+ Button11Color = Brushes.Yellow;
break;
case 12:
Button12Color = Brushes.Yellow;
diff --git a/DM_Weight/ViewModels/EditUserDialogViewModel.cs b/DM_Weight/ViewModels/EditUserDialogViewModel.cs
index d1d12b4..c90ecf9 100644
--- a/DM_Weight/ViewModels/EditUserDialogViewModel.cs
+++ b/DM_Weight/ViewModels/EditUserDialogViewModel.cs
@@ -36,7 +36,7 @@ namespace DM_Weight.ViewModels
set => SetProperty(ref _userList, value);
}
- public UserList DMUserList;
+ public UserList DMUserList=new UserList();
private string UserName;
public List Roles { get; set; }
diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs
index 842b1bc..0b7ad4f 100644
--- a/DM_Weight/ViewModels/HomeWindowViewModel.cs
+++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs
@@ -68,86 +68,169 @@ namespace DM_Weight.ViewModels
get { return _selectedChildMenu; }
set
{
- if (!_portUtil.Operate)
+ //if (!_portUtil.Operate)
+ //{
+ // if (value != null)
+ // {
+ // if (value.PremissionPath.Equals("TakeRecordWindow"))
+ // {
+ // //定义传参变量
+ // NavigationParameters keys = new NavigationParameters();
+
+ // //添加参数,键值对格式
+ // keys.Add("Type", 2);
+ // _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
+ // }
+ // else if (value.PremissionPath.Equals("AddRecordWindow"))
+ // {
+ // //定义传参变量
+ // NavigationParameters keys = new NavigationParameters();
+
+ // //添加参数,键值对格式
+ // keys.Add("Type", 1);
+ // _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
+ // }
+ // else if (value.PremissionPath.Equals("ReturnRecordWindow"))
+ // {
+ // //定义传参变量
+ // NavigationParameters keys = new NavigationParameters();
+
+ // //添加参数,键值对格式
+ // keys.Add("Type", 3);
+ // _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
+ // }
+ // else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow"))
+ // {
+ // //定义传参变量
+ // NavigationParameters keys = new NavigationParameters();
+
+ // //添加参数,键值对格式
+ // keys.Add("Type", 3);
+ // _regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys);
+ // }
+ // else if (value.PremissionPath.Equals("CheckRecordWindow"))
+ // {
+ // //定义传参变量
+ // NavigationParameters keys = new NavigationParameters();
+
+ // //添加参数,键值对格式
+ // keys.Add("Type", 4);
+ // _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
+ // }
+ // else
+ // {
+ // if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2"))
+ // {
+ // if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
+ // {
+ // _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
+ // }
+ // else
+ // {
+ // _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
+ // }
+ // }
+ // else if (value.PremissionPath.Equals("SettingMainWindow") || value.PremissionPath.Equals("SettingWindow"))
+ // {
+ // if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
+ // {
+ // _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
+ // }
+ // else
+ // {
+ // _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
+ // }
+ // }
+ // else
+ // {
+ // _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
+ // }
+ // }
+ // }
+ SetProperty(ref _selectedChildMenu, value);
+ //}
+ }
+ }
+ private void SelectChildNavigate(PremissionDm SelectedChildMenu)
+ {
+ if (!_portUtil.Operate)
+ {
+ if (SelectedChildMenu != null)
{
- if (value != null)
+ if (SelectedChildMenu.PremissionPath.Equals("TakeRecordWindow"))
{
- if (value.PremissionPath.Equals("TakeRecordWindow"))
- {
- //定义传参变量
- NavigationParameters keys = new NavigationParameters();
+ //定义传参变量
+ NavigationParameters keys = new NavigationParameters();
- //添加参数,键值对格式
- keys.Add("Type", 2);
- _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
- }
- else if (value.PremissionPath.Equals("AddRecordWindow"))
- {
- //定义传参变量
- NavigationParameters keys = new NavigationParameters();
+ //添加参数,键值对格式
+ keys.Add("Type", 2);
+ _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
+ }
+ else if (SelectedChildMenu.PremissionPath.Equals("AddRecordWindow"))
+ {
+ //定义传参变量
+ NavigationParameters keys = new NavigationParameters();
- //添加参数,键值对格式
- keys.Add("Type", 1);
- _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
- }
- else if (value.PremissionPath.Equals("ReturnRecordWindow"))
- {
- //定义传参变量
- NavigationParameters keys = new NavigationParameters();
+ //添加参数,键值对格式
+ keys.Add("Type", 1);
+ _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
+ }
+ else if (SelectedChildMenu.PremissionPath.Equals("ReturnRecordWindow"))
+ {
+ //定义传参变量
+ NavigationParameters keys = new NavigationParameters();
- //添加参数,键值对格式
- keys.Add("Type", 3);
- _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
- }
- else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow"))
- {
- //定义传参变量
- NavigationParameters keys = new NavigationParameters();
+ //添加参数,键值对格式
+ keys.Add("Type", 3);
+ _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
+ }
+ else if (SelectedChildMenu.PremissionPath.Equals("RetrunEmptyRecordWindow"))
+ {
+ //定义传参变量
+ NavigationParameters keys = new NavigationParameters();
- //添加参数,键值对格式
- keys.Add("Type", 3);
- _regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys);
- }
- else if (value.PremissionPath.Equals("CheckRecordWindow"))
- {
- //定义传参变量
- NavigationParameters keys = new NavigationParameters();
+ //添加参数,键值对格式
+ keys.Add("Type", 3);
+ _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath, keys);
+ }
+ else if (SelectedChildMenu.PremissionPath.Equals("CheckRecordWindow"))
+ {
+ //定义传参变量
+ NavigationParameters keys = new NavigationParameters();
- //添加参数,键值对格式
- keys.Add("Type", 4);
- _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
- }
- else
+ //添加参数,键值对格式
+ keys.Add("Type", 4);
+ _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
+ }
+ else
+ {
+ if (SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow") || SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow2"))
{
- if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2"))
+ if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
{
- if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
- {
- _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
- }
- else
- {
- _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
- }
- }
- else if (value.PremissionPath.Equals("SettingMainWindow") || value.PremissionPath.Equals("SettingWindow"))
- {
- if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
- {
- _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
- }
- else
- {
- _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
- }
+ _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
}
else
{
- _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
+ _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
}
}
+ else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow"))
+ {
+ if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
+ {
+ _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
+ }
+ else
+ {
+ _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
+ }
+ }
+ else
+ {
+ _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
+ }
}
- SetProperty(ref _selectedChildMenu, value);
}
}
}
@@ -195,10 +278,24 @@ namespace DM_Weight.ViewModels
else
{
//SelectedMenu.Children = SelectedMenu.Children;
- SelectedChildMenu = SelectedMenu.Children[0];
+ // SelectedChildMenu = SelectedMenu.Children[0];
+ if (!_portUtil.Operate)
+ {
+ _regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
+ }
}
}
-
+ #region 子菜单点击
+ private DelegateCommand _selectionChildCommon;
+ public DelegateCommand SelectionChildCommon
+ {
+ get => _selectionChildCommon ?? (_selectionChildCommon = new DelegateCommand(SelectionChildMethod));
+ }
+ private void SelectionChildMethod()
+ {
+ SelectChildNavigate(SelectedChildMenu);
+ }
+ #endregion
public List PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } }
public UserList UserList { get { return _userList; } set { SetProperty(ref _userList, value); } }
@@ -431,6 +528,7 @@ namespace DM_Weight.ViewModels
PremissionDmList = premissions;
SelectedMenu = premissions[0];
SelectedChildMenu = premissions[0].Children[0];
+ _regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
FindDrawerCount();
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
diff --git a/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs b/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs
index 5151e31..a1b049c 100644
--- a/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs
@@ -325,10 +325,10 @@ namespace DM_Weight.ViewModels
Button9Color = Brushes.Yellow;
break;
case 10:
- Button9Color = Brushes.Yellow;
+ Button10Color = Brushes.Yellow;
break;
case 11:
- Button9Color = Brushes.Yellow;
+ Button11Color = Brushes.Yellow;
break;
case 12:
Button12Color = Brushes.Yellow;
diff --git a/DM_Weight/ViewModels/SettingBoxWindowViewModel.cs b/DM_Weight/ViewModels/SettingBoxWindowViewModel.cs
index 69d50ef..0c2f2a2 100644
--- a/DM_Weight/ViewModels/SettingBoxWindowViewModel.cs
+++ b/DM_Weight/ViewModels/SettingBoxWindowViewModel.cs
@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
@@ -115,7 +116,7 @@ namespace DM_Weight.ViewModels
{
if (_userLists == null)
{
- _userLists = SqlSugarHelper.Db.Queryable().Where(us => us.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5")).Select(us => new BindUserList() { UserId = Convert.ToInt32(us.UserBarcode), UserName = us.Nickname }).ToList();
+ _userLists = SqlSugarHelper.Db.Queryable().Where(us => us.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5")).Select(us => new BindUserList() { UserId = us.UserBarcode, UserName = us.Nickname }).ToList();
_userListSelectedItem = _userLists[0];
}
}
@@ -146,6 +147,7 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand((DrawerNo) =>
{
+ UserListSelectedItem = null;
this.DrawerNo = Convert.ToInt32(DrawerNo);
ChannelList cnl = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo.ToString() == DrawerNo).First();
if (cnl != null && cnl.DrawerType != null)
@@ -158,23 +160,24 @@ namespace DM_Weight.ViewModels
{
//药箱归属药师,把药师信息显示出来
UserStatus = Visibility.Visible;
- UserListSelectedItem = _userLists.Where(sul => sul.UserId.ToString() == cnl.BelongUser).FirstOrDefault();
+ if (!string.IsNullOrEmpty(cnl.BelongUser))
+ {
+
+ UserListSelectedItem = _userLists.Where(sul => sul.UserId!=null&&sul.UserId.ToString() == cnl.BelongUser).FirstOrDefault();
+ }
if (UserListSelectedItem == null)
{
if (UserLists.Where(us => us.UserName == "请选择药师").Count() <= 0)
{
BindUserList nullBind = new BindUserList();
- nullBind.UserId = 0;
+ //nullBind.UserId = null;
nullBind.UserName = "请选择药师";
_userLists.Add(nullBind);
}
UserListSelectedItem = UserLists.Where(us => us.UserName == "请选择药师").FirstOrDefault();
}
- else
- {
- UserListSelectedItem = UserLists[0];
- }
+
}
else
{
@@ -210,7 +213,12 @@ namespace DM_Weight.ViewModels
Type = 55,
InvoiceId = $"打开{DrawerNo}号药箱",
}).ExecuteCommand();
- ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo - 1);
+ bool bFlag = ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo - 1);
+ if (bFlag)
+ {
+ IsEnable = true;
+ Status = 0;
+ }
}
});
}
@@ -229,15 +237,15 @@ namespace DM_Weight.ViewModels
{
//药箱 归属药师
- iUpdate=SqlSugarHelper.Db.Updateable(new ChannelList() { BelongUser = UserListSelectedItem.UserId.ToString(), DrawerType = BoxTypeSelectedItem.TypeValue, Id = channelList.Id }).UpdateColumns(cl => new { cl.BelongUser, cl.DrawerType }).ExecuteCommand();
+ iUpdate = SqlSugarHelper.Db.Updateable(new ChannelList() { BelongUser = UserListSelectedItem.UserId.ToString(), DrawerType = BoxTypeSelectedItem.TypeValue, Id = channelList.Id }).UpdateColumns(cl => new { cl.BelongUser, cl.DrawerType }).ExecuteCommand();
}
else
{
//药箱属于公共药箱
- iUpdate=SqlSugarHelper.Db.Updateable(new ChannelList() { DrawerType = BoxTypeSelectedItem.TypeValue, Id = channelList.Id }).UpdateColumns(cl => new { cl.DrawerType }).ExecuteCommand();
+ iUpdate = SqlSugarHelper.Db.Updateable(new ChannelList() { DrawerType = BoxTypeSelectedItem.TypeValue, Id = channelList.Id }).UpdateColumns(cl => new { cl.DrawerType }).ExecuteCommand();
}
- if(iUpdate>0)
+ if (iUpdate > 0)
{
//提示请选择药箱
AlertMsg alertMsg = new AlertMsg
@@ -364,7 +372,7 @@ namespace DM_Weight.ViewModels
public class BindUserList
{
- public int UserId { get; set; }
+ public string UserId { get; set; }
public string UserName { get; set; }
}
}
diff --git a/DM_Weight/Views/BindBoxPackageWindow.xaml b/DM_Weight/Views/BindBoxPackageWindow.xaml
index 5e6c9b4..6352ba7 100644
--- a/DM_Weight/Views/BindBoxPackageWindow.xaml
+++ b/DM_Weight/Views/BindBoxPackageWindow.xaml
@@ -156,7 +156,7 @@
IsEditable="True"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
- DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
+ DisplayMemberPath="drug_name_spec" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
/>
-
+
+
+
+
+