同上,刚刚未提交上去

This commit is contained in:
maqiao 2024-11-05 08:49:56 +08:00
parent 21082a6e17
commit 5e9198cf59
11 changed files with 209 additions and 91 deletions

View File

@ -3,7 +3,7 @@
<connectionStrings> <connectionStrings>
<!-- 数据库连接字符串 --> <!-- 数据库连接字符串 -->
<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />--> <!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
<add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangxiang_xianchang;userid=root;password=root" /> <add name="database" connectionString="server=127.0.0.1;port=3306;database=xx_xiangchang2;userid=root;password=root" />
</connectionStrings> </connectionStrings>
<!--<runtime> <!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!-- --><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -99,7 +99,7 @@
<!-- 指纹机号码 --> <!-- 指纹机号码 -->
<add key="machineNumber" value="1"/> <add key="machineNumber" value="1"/>
<!-- 指纹机ip --> <!-- 指纹机ip -->
<add key="fingerIp" value="192.168.1.201"/> <add key="fingerIp" value="192.168.50.201"/>
<!-- 多处方取药 0:不启用 1启用--> <!-- 多处方取药 0:不启用 1启用-->
<add key="MultiOrder" value="1"/> <add key="MultiOrder" value="1"/>

View File

@ -96,6 +96,8 @@ namespace DM_Weight.Models
get=> _base; get=> _base;
set { SetProperty(ref _base, value); } set { SetProperty(ref _base, value); }
} }
[SugarColumn(IsIgnore = true)]
public string drug_name_spec { get; set; }

View File

@ -74,8 +74,9 @@ namespace DM_Weight.Port
}); });
return bools; return bools;
} }
public void OpenBoxDoor(int boxNum) public bool OpenBoxDoor(int boxNum)
{ {
bool bFlag=false;
Policy.Handle<Exception>().Retry(3, ((exception, retryCount) => Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
{ {
this.Dispose(); this.Dispose();
@ -86,7 +87,9 @@ namespace DM_Weight.Port
{ {
master.WriteSingleRegister(1, (ushort)boxNum, 14); master.WriteSingleRegister(1, (ushort)boxNum, 14);
Console.WriteLine($"开门指令已发送{(ushort)boxNum}"); Console.WriteLine($"开门指令已发送{(ushort)boxNum}");
bFlag = true;
}); });
return bFlag;
} }
private void Dispose() private void Dispose()
{ {

View File

@ -163,8 +163,11 @@ namespace DM_Weight.ViewModels
} }
private void RequestDrug() private void RequestDrug()
{ {
var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList(); //var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugInfos = list; //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<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
} }
public DelegateCommand BindingDrug public DelegateCommand BindingDrug
{ {

View File

@ -389,10 +389,10 @@ namespace DM_Weight.ViewModels
Button9Color = Brushes.Yellow; Button9Color = Brushes.Yellow;
break; break;
case 10: case 10:
Button9Color = Brushes.Yellow; Button10Color = Brushes.Yellow;
break; break;
case 11: case 11:
Button9Color = Brushes.Yellow; Button11Color = Brushes.Yellow;
break; break;
case 12: case 12:
Button12Color = Brushes.Yellow; Button12Color = Brushes.Yellow;

View File

@ -36,7 +36,7 @@ namespace DM_Weight.ViewModels
set => SetProperty(ref _userList, value); set => SetProperty(ref _userList, value);
} }
public UserList DMUserList; public UserList DMUserList=new UserList();
private string UserName; private string UserName;
public List<RoleDm> Roles { get; set; } public List<RoleDm> Roles { get; set; }

View File

@ -68,86 +68,169 @@ namespace DM_Weight.ViewModels
get { return _selectedChildMenu; } get { return _selectedChildMenu; }
set 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); keys.Add("Type", 2);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
} }
else if (value.PremissionPath.Equals("AddRecordWindow")) else if (SelectedChildMenu.PremissionPath.Equals("AddRecordWindow"))
{ {
//定义传参变量 //定义传参变量
NavigationParameters keys = new NavigationParameters(); NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式 //添加参数,键值对格式
keys.Add("Type", 1); keys.Add("Type", 1);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
} }
else if (value.PremissionPath.Equals("ReturnRecordWindow")) else if (SelectedChildMenu.PremissionPath.Equals("ReturnRecordWindow"))
{ {
//定义传参变量 //定义传参变量
NavigationParameters keys = new NavigationParameters(); NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式 //添加参数,键值对格式
keys.Add("Type", 3); keys.Add("Type", 3);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
} }
else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow")) else if (SelectedChildMenu.PremissionPath.Equals("RetrunEmptyRecordWindow"))
{ {
//定义传参变量 //定义传参变量
NavigationParameters keys = new NavigationParameters(); NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式 //添加参数,键值对格式
keys.Add("Type", 3); keys.Add("Type", 3);
_regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys); _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath, keys);
} }
else if (value.PremissionPath.Equals("CheckRecordWindow")) else if (SelectedChildMenu.PremissionPath.Equals("CheckRecordWindow"))
{ {
//定义传参变量 //定义传参变量
NavigationParameters keys = new NavigationParameters(); NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式 //添加参数,键值对格式
keys.Add("Type", 4); keys.Add("Type", 4);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys); _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
} }
else 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");
{
_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 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 else
{ {
//SelectedMenu.Children = SelectedMenu.Children; //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<PremissionDm> PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } } public List<PremissionDm> PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } }
public UserList UserList { get { return _userList; } set { SetProperty(ref _userList, value); } } public UserList UserList { get { return _userList; } set { SetProperty(ref _userList, value); } }
@ -431,6 +528,7 @@ namespace DM_Weight.ViewModels
PremissionDmList = premissions; PremissionDmList = premissions;
SelectedMenu = premissions[0]; SelectedMenu = premissions[0];
SelectedChildMenu = premissions[0].Children[0]; SelectedChildMenu = premissions[0].Children[0];
_regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
FindDrawerCount(); FindDrawerCount();
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0"); int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");

View File

@ -325,10 +325,10 @@ namespace DM_Weight.ViewModels
Button9Color = Brushes.Yellow; Button9Color = Brushes.Yellow;
break; break;
case 10: case 10:
Button9Color = Brushes.Yellow; Button10Color = Brushes.Yellow;
break; break;
case 11: case 11:
Button9Color = Brushes.Yellow; Button11Color = Brushes.Yellow;
break; break;
case 12: case 12:
Button12Color = Brushes.Yellow; Button12Color = Brushes.Yellow;

View File

@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
@ -115,7 +116,7 @@ namespace DM_Weight.ViewModels
{ {
if (_userLists == null) if (_userLists == null)
{ {
_userLists = SqlSugarHelper.Db.Queryable<UserList>().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<UserList>().Where(us => us.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5")).Select(us => new BindUserList() { UserId = us.UserBarcode, UserName = us.Nickname }).ToList();
_userListSelectedItem = _userLists[0]; _userListSelectedItem = _userLists[0];
} }
} }
@ -146,6 +147,7 @@ namespace DM_Weight.ViewModels
{ {
get => new DelegateCommand<string>((DrawerNo) => get => new DelegateCommand<string>((DrawerNo) =>
{ {
UserListSelectedItem = null;
this.DrawerNo = Convert.ToInt32(DrawerNo); this.DrawerNo = Convert.ToInt32(DrawerNo);
ChannelList cnl = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo.ToString() == DrawerNo).First(); ChannelList cnl = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo.ToString() == DrawerNo).First();
if (cnl != null && cnl.DrawerType != null) if (cnl != null && cnl.DrawerType != null)
@ -158,23 +160,24 @@ namespace DM_Weight.ViewModels
{ {
//药箱归属药师,把药师信息显示出来 //药箱归属药师,把药师信息显示出来
UserStatus = Visibility.Visible; 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 (UserListSelectedItem == null)
{ {
if (UserLists.Where(us => us.UserName == "请选择药师").Count() <= 0) if (UserLists.Where(us => us.UserName == "请选择药师").Count() <= 0)
{ {
BindUserList nullBind = new BindUserList(); BindUserList nullBind = new BindUserList();
nullBind.UserId = 0; //nullBind.UserId = null;
nullBind.UserName = "请选择药师"; nullBind.UserName = "请选择药师";
_userLists.Add(nullBind); _userLists.Add(nullBind);
} }
UserListSelectedItem = UserLists.Where(us => us.UserName == "请选择药师").FirstOrDefault(); UserListSelectedItem = UserLists.Where(us => us.UserName == "请选择药师").FirstOrDefault();
} }
else
{
UserListSelectedItem = UserLists[0];
}
} }
else else
{ {
@ -210,7 +213,12 @@ namespace DM_Weight.ViewModels
Type = 55, Type = 55,
InvoiceId = $"打开{DrawerNo}号药箱", InvoiceId = $"打开{DrawerNo}号药箱",
}).ExecuteCommand(); }).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 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 AlertMsg alertMsg = new AlertMsg
@ -364,7 +372,7 @@ namespace DM_Weight.ViewModels
public class BindUserList public class BindUserList
{ {
public int UserId { get; set; } public string UserId { get; set; }
public string UserName { get; set; } public string UserName { get; set; }
} }
} }

View File

@ -156,7 +156,7 @@
IsEditable="True" IsEditable="True"
ItemsSource="{Binding DrugInfos}" ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}" SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp" DisplayMemberPath="drug_name_spec" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
/> />
<TextBox <TextBox
Grid.Column="1" Grid.Column="1"

View File

@ -56,7 +56,11 @@
<materialDesign:Card Grid.Row="0"> <materialDesign:Card Grid.Row="0">
<ListBox ItemsSource="{Binding SelectedMenu.Children}" SelectedItem="{ Binding SelectedChildMenu }" HorizontalAlignment="left" Cursor="Hand"> <ListBox ItemsSource="{Binding SelectedMenu.Children}" SelectedItem="{ Binding SelectedChildMenu }" HorizontalAlignment="left" Cursor="Hand">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectionChildCommon}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel> <ListBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" IsItemsHost="True"/> <WrapPanel Orientation="Horizontal" IsItemsHost="True"/>