每隔1分钟自动获取冰箱温度,添加冰箱设置页面,温度可设置小数,保留一位小数

This commit is contained in:
maqiao 2025-01-14 15:37:05 +08:00
parent 83bbf8c453
commit 29723e1054
7 changed files with 135 additions and 81 deletions

View File

@ -37,7 +37,7 @@
<!-- 按处方还药或者按取药记录还药 1:处方ReturnDrugWindow22药品ReturnDrugWindow--> <!-- 按处方还药或者按取药记录还药 1:处方ReturnDrugWindow22药品ReturnDrugWindow-->
<add key="returnDrugMode" value="2" /> <add key="returnDrugMode" value="2" />
<!-- 自动退出时间单位秒为0时不自动退出 --> <!-- 自动退出时间单位秒为0时不自动退出 -->
<add key="autoExit" value="0"/> <add key="autoExit" value="3"/>
<!-- 无操作退出录像时间单位秒为0时不退出录像 --> <!-- 无操作退出录像时间单位秒为0时不退出录像 -->
<add key="stopRecord" value="0"/> <add key="stopRecord" value="0"/>

View File

@ -23,10 +23,17 @@ namespace DM_Weight.Common
string[] rang = value.ToString().Split('-'); string[] rang = value.ToString().Split('-');
if (rang.Length >= 2) if (rang.Length >= 2)
{ {
bool bSRange = int.TryParse(rang[0], out int sRange); bool bSRange = float.TryParse(rang[0], out float sRange);
bool bERange = int.TryParse(rang[1], out int eRange); bool bERange = float.TryParse(rang[1], out float eRange);
if (bSRange && bERange) if (bSRange && bERange)
{ {
string[] sList= sRange.ToString().Split('.');
string[] eList= eRange.ToString().Split(".");
if ((sList.Length > 1 && sList[1].Length > 1) || (eList.Length > 1 && eList[1].Length>1))
{
tips = "小数点后保留1位";
return new ValidationResult(flag, tips);
}
if ((sRange < 2 || eRange > 8||sRange>8||eRange<2)) if ((sRange < 2 || eRange > 8||sRange>8||eRange<2))
{ {
tips = "温度区间设置2-8度请检查输入"; tips = "温度区间设置2-8度请检查输入";

View File

@ -32,10 +32,10 @@ namespace DM_Weight.Finger
{ {
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
logger.Info($"进入构造器,开始连接指纹机"); logger.Info($"进入构造器,开始连接指纹机");
Task.Run(() => // Task.Run(() =>
{ //{
ConnectionMain(); ConnectionMain();
}); //});
} }
public void ConnectionMain() public void ConnectionMain()

View File

@ -23,6 +23,7 @@ using System.Windows.Threading;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using DM_Weight.msg; using DM_Weight.msg;
using System.Threading; using System.Threading;
using DM_Weight.Common;
namespace DM_Weight.ViewModels namespace DM_Weight.ViewModels
{ {
@ -301,17 +302,17 @@ namespace DM_Weight.ViewModels
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow"); _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
} }
} }
else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow")) //else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow"))
{ //{
//if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"])>0) // if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
//{ // {
// _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow"); // _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
//} // }
//else // else
{ // {
_regionManager.RequestNavigate("ContentRegion", "SettingWindow"); // _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
} // }
} //}
else else
{ {
_regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath); _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
@ -341,6 +342,7 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil; private PortUtil _portUtil;
//private CHKFunction _chkFunction; //private CHKFunction _chkFunction;
IEventAggregator _eventAggregator; IEventAggregator _eventAggregator;
bool IsLeave = false;
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator) public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator)
{ {
_portUtil = portUtil; _portUtil = portUtil;
@ -426,7 +428,7 @@ namespace DM_Weight.ViewModels
byte[] data = null; byte[] data = null;
float retT = await _portUtil.GetFridgeTemperature(1); float retT = await _portUtil.GetFridgeTemperature(1);
Thread.Sleep(80); Thread.Sleep(80);
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃"; WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃";
} }
} }
@ -438,13 +440,14 @@ namespace DM_Weight.ViewModels
byte[] data = null; byte[] data = null;
float retT = await _portUtil.GetFridgeTemperature(1); float retT = await _portUtil.GetFridgeTemperature(1);
Thread.Sleep(80); Thread.Sleep(80);
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃;"; WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃";
if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1) logger.Info(WD);
{ //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
float retTemp = await _portUtil.GetFridgeTemperature(2); //{
Thread.Sleep(80); // float retTemp = await _portUtil.GetFridgeTemperature(2);
WD += $"{retTemp}℃"; // Thread.Sleep(80);
} // WD += $"{retTemp}℃";
//}
} }
} }
/// <summary> /// <summary>
@ -532,7 +535,7 @@ namespace DM_Weight.ViewModels
//.ToTree(pd => pd.Children, pd => pd.ParentId, 0); //.ToTree(pd => pd.Children, pd => pd.ParentId, 0);
PremissionDmList = premissions; PremissionDmList = premissions;
SelectedMenu = premissions[0]; SelectedMenu = premissions[0];
PreSelectedMenu= premissions[0]; PreSelectedMenu = premissions[0];
SelectedChildMenu = premissions[0].Children[0]; SelectedChildMenu = premissions[0].Children[0];
_regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath); _regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
FindDrawerCount(); FindDrawerCount();
@ -648,6 +651,46 @@ namespace DM_Weight.ViewModels
////获取录像机的时间 ////获取录像机的时间
//_chkFunction.HIK_DVR_TIME(); //_chkFunction.HIK_DVR_TIME();
//_chkFunction.HIKStartDVRRecord(); //_chkFunction.HIKStartDVRRecord();
new PromiseUtil<int>().taskAsyncLoop(60000, 0, async (options, next, stop) =>
{
try
{
if (!_portUtil.FridgeOperate)
{
string retStr = string.Empty;
byte[] data = null;
float retT = await _portUtil.GetFridgeTemperature(1);
Thread.Sleep(80);
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃";
logger.Info(WD);
//if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
//{
// float retTemp = await _portUtil.GetFridgeTemperature(2);
// Thread.Sleep(80);
// WD += $"{retTemp}℃";
//}
if (IsLeave)
{
stop();
}
else
{
next();
}
}
else
{
stop();
}
}
catch (Exception ex)
{
logger.Info($"获取冰箱异常:{ex.Message}");
next();
}
});
} }
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建 //每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
@ -659,7 +702,8 @@ namespace DM_Weight.ViewModels
//这个方法用于拦截请求 //这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext) public void OnNavigatedFrom(NavigationContext navigationContext)
{ {
IsLeave = true;
navigationContext.NavigationService.Region.RegionManager.Regions.Remove(PrismManager.SettingViewRegionName);
} }
} }
} }

View File

@ -191,28 +191,28 @@ _exitCommand ??= new DelegateCommand(Exit);
else else
{ {
//1仅当班人、审核人可登录 //1仅当班人、审核人可登录
if (LoginUserCheck.Equals("1")) //if (LoginUserCheck.Equals("1"))
{ //{
//检查当前登录人是否是值班人 (审核人与发药人) // //检查当前登录人是否是值班人 (审核人与发药人)
listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>() // listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
.Where(cs => cs.State == "0").First(); // .Where(cs => cs.State == "0").First();
if (listHkcChangeShifts != null) // if (listHkcChangeShifts != null)
{ // {
if(!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName)) // if(!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
{ // {
AlertMsg alertMsg = new AlertMsg // AlertMsg alertMsg = new AlertMsg
{ // {
Message = "仅值班人可登录,当前登录人非值班人", // Message = "仅值班人可登录,当前登录人非值班人",
Type = MsgType.ERROR // Type = MsgType.ERROR
}; // };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); // _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = ""; // Username = "";
Password = ""; // Password = "";
return; // return;
} // }
} // }
} //}
if (userList.PassWord == MD5.GetMD5Hash(Password)) if (userList.PassWord == MD5.GetMD5Hash(Password))
{ {
@ -247,6 +247,7 @@ _exitCommand ??= new DelegateCommand(Exit);
void SetUser(UserList user) void SetUser(UserList user)
{ {
logger.Info("SetUser");
// 单人登录模式 // 单人登录模式
if (SingleLogin) if (SingleLogin)
{ {
@ -254,6 +255,7 @@ _exitCommand ??= new DelegateCommand(Exit);
keys.Add("operator", user); keys.Add("operator", user);
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{ {
logger.Info("跳转Home");
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys); _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
})); }));
} }
@ -364,6 +366,7 @@ _exitCommand ??= new DelegateCommand(Exit);
{ {
FingerMsg = !msg.Result; FingerMsg = !msg.Result;
} }
logger.Info($"LoginBtnEnable:{LoginBtnEnable}");
if (LoginBtnEnable) if (LoginBtnEnable)
{ {
if (msg.Message.Equals("LOGIN")) if (msg.Message.Equals("LOGIN"))
@ -398,28 +401,28 @@ _exitCommand ??= new DelegateCommand(Exit);
else else
{ {
//1仅当班人、审核人可登录 //1仅当班人、审核人可登录
if (LoginUserCheck.Equals("1")) //if (LoginUserCheck.Equals("1"))
{ //{
//检查当前登录人是否是值班人 (审核人与发药人) //检查当前登录人是否是值班人 (审核人与发药人)
listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>() //listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
.Where(cs => cs.State == "0").First(); // .Where(cs => cs.State == "0").First();
if (listHkcChangeShifts != null) //if (listHkcChangeShifts != null)
{ //{
if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName)) // if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
{ // {
AlertMsg alertMsg = new AlertMsg // AlertMsg alertMsg = new AlertMsg
{ // {
Message = "仅值班人可登录,当前登录人非值班人", // Message = "仅值班人可登录,当前登录人非值班人",
Type = MsgType.ERROR // Type = MsgType.ERROR
}; // };
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg); // _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = ""; // Username = "";
Password = ""; // Password = "";
return; // return;
} // }
} //}
} //}
SetUser(userList); SetUser(userList);
} }
} }

View File

@ -555,18 +555,18 @@ namespace DM_Weight.ViewModels
PremissionPath = "RoleManagerWindow", PremissionPath = "RoleManagerWindow",
}; };
PremissionDm sysset3; PremissionDm sysset3;
//if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0) if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
//{ {
// //有冰箱,需要冰箱设置(两个冰箱) //有冰箱,需要冰箱设置(两个冰箱)
// sysset3 = new PremissionDm sysset3 = new PremissionDm
// { {
// Id = 53, Id = 53,
// PremissionName = "设置", PremissionName = "设置",
// PremissionPath = "SettingMainWindow", PremissionPath = "SettingMainWindow",
// }; };
//} }
//else else
{ {
sysset3 = new PremissionDm sysset3 = new PremissionDm
{ {

View File

@ -123,7 +123,7 @@
<Grid Grid.Column="2"> <Grid Grid.Column="2">
<StackPanel Margin="6" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Margin="6" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="储物箱" Command="{Binding OpenRecoverCommand}" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}" /> <Button Content="储物箱" Command="{Binding OpenRecoverCommand}" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}" />
<!--<TextBlock Margin="0,10,10,0" Text="{Binding WD}" Foreground="White" FontWeight="Bold" FontSize="14"/>--> <TextBlock Margin="0,10,10,0" Text="{Binding WD}" Foreground="White" FontWeight="Bold" FontSize="14"/>
<Button Content="查看冰箱温度" Visibility="{Binding HasFridge}" Command="{Binding CheckWDCommand}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}"/> <Button Content="查看冰箱温度" Visibility="{Binding HasFridge}" Command="{Binding CheckWDCommand}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>