diff --git a/DM_Weight/Converter/StockStatusConverter.cs b/DM_Weight/Converter/StockStatusConverter.cs
index b7233ac..961d33e 100644
--- a/DM_Weight/Converter/StockStatusConverter.cs
+++ b/DM_Weight/Converter/StockStatusConverter.cs
@@ -30,10 +30,14 @@ namespace DM_Weight.Converter
{
return "未取药";
}
- else
+ if(status == 1)
{
return "已取药待入库";
}
+ if(status==2)
+ {
+ return "正在入库";
+ }
}
return "";
}
diff --git a/DM_Weight/Models/ChannelStock.cs b/DM_Weight/Models/ChannelStock.cs
index 9fd9103..be15bcc 100644
--- a/DM_Weight/Models/ChannelStock.cs
+++ b/DM_Weight/Models/ChannelStock.cs
@@ -85,12 +85,17 @@ namespace DM_Weight.Models
///
[SugarColumn(ColumnName = "board_type")]
public int BoardType { get; set; }
+ private int? _state = 0;
///
///
/// 默认值: 1(用于标识毒麻柜是否给交接柜补药:0未补,1已补)
///
[SugarColumn(ColumnName = "state")]
- public int? State { get; set; }
+ public int? State
+ {
+ get => _state;
+ set { SetProperty(ref _state, value); }
+ }
[SugarColumn(IsIgnore = true)]
public bool IsSelected { get; set; }
@@ -208,5 +213,11 @@ namespace DM_Weight.Models
[SugarColumn(IsIgnore =true)]
public string OrderNos { get; set; }
+ //交接柜加药数量
+ [SugarColumn(ColumnName = "col_no1")]
+ public int AddToJJNum { get; set; }
+ //需要加药数量
+ [SugarColumn(ColumnName = "col_no2")]
+ public int NeedNum { get; set; }
}
}
\ No newline at end of file
diff --git a/DM_Weight/Port/ModbusHelper.cs b/DM_Weight/Port/ModbusHelper.cs
index 30672c8..e0cbdac 100644
--- a/DM_Weight/Port/ModbusHelper.cs
+++ b/DM_Weight/Port/ModbusHelper.cs
@@ -11,46 +11,45 @@ using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
+using System.Speech.Synthesis;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
namespace DM_Weight.Port
{
public class ModbusHelper
{
+ private static ModbusHelper instance;
private ModbusIpMaster master;
private Socket socket;
private TcpClient client;
- private static ModbusHelper instance;
- private static readonly object objLock = new object();
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
+ public static bool BoxOperate { get; set; }
public ModbusHelper()
{
- if (ConfigurationManager.AppSettings["test"] == null || !(ConfigurationManager.AppSettings["test"].ToString().Equals("Y")))
- {
- socket = MakeKeepALiveSocket();
- client = new TcpClient();
- client.Client = socket;
- master = ModbusIpMaster.CreateIp(client);
- }
+ socket = MakeKeepALiveSocket();
+ client = new TcpClient();
+ client.Client = socket;
+ master = ModbusIpMaster.CreateIp(client);
}
public static ModbusHelper GetInstance()
{
if (instance == null)
{
- lock (objLock)
- {
- if (instance == null)
- instance = new ModbusHelper();
- }
+ //lock (objLock)
+ //{
+ // if (instance == null)
+ instance = new ModbusHelper();
+ //}
}
return instance;
}
private void SetModusIpMaster()
{
- Debug.WriteLine("SetModusIpMaster");
+ logger.Info("SetModusIpMaster");
socket = MakeKeepALiveSocket();
client = new TcpClient();
client.Client = socket;
@@ -59,25 +58,28 @@ namespace DM_Weight.Port
public bool[] GetAllBoxState()
{
- if (ConfigurationManager.AppSettings["test"] != null && ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
- {
- return new bool[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false };
- }
bool[] bools = Policy.Handle()
.Retry(3, (exception, retryCount) =>
{
this.Dispose();
//Debug.WriteLine($"获取所有箱子门状态出错,第{retryCount}次重试", exception);
logger.Info($"获取所有箱子门状态出错,第{retryCount}次重试, 异常信息{exception}");
+
+ Thread.Sleep(50);
+ BoxOperate = false;
this.SetModusIpMaster();
// return TimeSpan.FromSeconds (1);
}).Execute(() =>
{
bool[] flags = new bool[18];
+ if (master == null)
+ {
+ this.SetModusIpMaster();
+ }
var result = master.ReadInputRegisters(1, 0x0033, 2);
var r1 = Convert.ToString(((int)result[0] >> 14) | ((int)result[1] << 2), 2).PadLeft(18, '0');
var r2 = r1.ToCharArray();
- Debug.WriteLine("r2=>" + string.Join(", ", r2));
+ logger.Info("r2=>" + string.Join(", ", r2));
for (int i = 0; i < 18; i++)
{
flags[i] = r2[17 - i] == '1' ? true : false;
@@ -89,16 +91,15 @@ namespace DM_Weight.Port
}
public bool OpenBoxDoor(int boxNum)
{
- if (ConfigurationManager.AppSettings["test"] != null && ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
- {
- return true;
- }
+ BoxOperate = true;
bool bFlag = false;
+ Thread.Sleep(50);
Policy.Handle().Retry(3, ((exception, retryCount) =>
{
this.Dispose();
//Debug.WriteLine($"打开箱子出错,第{retryCount}次重试", exception);
logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
+ Thread.Sleep(50);
this.SetModusIpMaster();
//return TimeSpan.FromSeconds (1);
})).Execute(() =>
@@ -145,5 +146,10 @@ namespace DM_Weight.Port
});
return _socket;
}
+ private static SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
+ public static void SpeakAsync(string textinfo)
+ {
+ speechSynthesizer.SpeakAsync(textinfo);
+ }
}
}
diff --git a/DM_Weight/ViewModels/AdditionWindowViewModel.cs b/DM_Weight/ViewModels/AdditionWindowViewModel.cs
index c774752..36d027e 100644
--- a/DM_Weight/ViewModels/AdditionWindowViewModel.cs
+++ b/DM_Weight/ViewModels/AdditionWindowViewModel.cs
@@ -71,18 +71,19 @@ namespace DM_Weight.ViewModels
ChannelStocks = SqlSugarHelper.Db.Queryable()
.Includes(cs => cs.ChannelLst)
.Includes(cs => cs.DrugInfo)
- .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity)
- .OrderBy(cs => cs.Chnguid)
+ .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cs.AddToJJNum > 0)
+
.OrderBy(cs => cs.DrawerNo)
+ .OrderBy(cs => cs.DrugId)
.ToList();
- ChannelStocks= ChannelStocks.GroupBy(it=>new {it.DrawerNo,it.DrugId})
- .Select(it=>
- {
- var ret = it.First();
- ret.Quantity = it.Sum(itx => itx.Quantity);
- return ret;
- }).ToList();
- ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
+ //ChannelStocks= ChannelStocks.GroupBy(it=>new {it.DrawerNo,it.DrugId})
+ // .Select(it=>
+ // {
+ // var ret = it.First();
+ // ret.Quantity = it.Sum(itx => itx.Quantity);
+ // return ret;
+ // }).ToList();
+ //ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
}
//开药箱放入药品
public DelegateCommand OpenBoxCommand
@@ -92,12 +93,25 @@ namespace DM_Weight.ViewModels
selectedStock = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
if (selectedStock != null && selectedStock.Count > 0)
{
+ selectedStock.ForEach(cs => cs.ChannelLst.State = 2);
+
int drawerNo = 0;
for (int i = 0; i < selectedStock.Count; i++)
{
if (!(drawerNo == selectedStock[i].DrawerNo))
{
drawerNo = selectedStock[i].DrawerNo;
+
+ // 保存数据 入库记录
+ SqlSugarHelper.Db.Insertable(new MachineRecord()
+ {
+ MachineId = "DM5",
+ DrawerNo = drawerNo,
+ Operator = HomeWindowViewModel.Operator?.Id,
+ OperationTime = DateTime.Now,
+ Type = 55,
+ InvoiceId = "药箱补药",
+ }).ExecuteCommand();
_portUtil.SpeakAsync($"正在打开{selectedStock[i].DrawerNo}号药箱");
}
ModbusHelper.GetInstance().OpenBoxDoor(selectedStock[i].DrawerNo - 1);
@@ -127,21 +141,32 @@ namespace DM_Weight.ViewModels
//更新 交接柜 库存信息
if (selectedStock != null && selectedStock.Count > 0)
{
- for (int j = 0; j < selectedStock.Count; j++)
+ //for (int j = 0; j < selectedStock.Count; j++)
+ //{
+
+ // // 更新数据 交接柜 库存信息
+ // ChannelStock jiaojie_it = selectedStock[j];
+ // jiaojie_it.Quantity = jiaojie_it.AddToJJNum;
+ // jiaojie_it.NeedNum = 0;
+ // jiaojie_it.AddToJJNum = 0;
+ //SqlSugarHelper.Db.Updateable(new ChannelStock()
+ //{
+ // Quantity = jiaojie_it.AddToJJNum,
+ // ManuNo = jiaojie_it.ManuNo,
+ // //EffDate = it.EffDate,
+ // //Id = jiaojie_it.Id,
+ // DrugId=jiaojie_it.DrugId,
+ // DrawerNo=jiaojie_it.DrawerNo,
+ // MachineId=jiaojie_it.MachineId,
+ //}).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).WhereColumns(jiaojie_it=>new { jiaojie_it.DrugId, jiaojie_it.DrawerNo, jiaojie_it.MachineId }).ExecuteCommand();
+ //}
+ selectedStock.ForEach(cs =>
{
- // 更新数据 交接柜 库存信息
- ChannelStock jiaojie_it = selectedStock[j];
- SqlSugarHelper.Db.Updateable(new ChannelStock()
- {
- Quantity = jiaojie_it.BaseQuantity,
- //ManuNo = it.ManuNo,
- //EffDate = it.EffDate,
- //Id = jiaojie_it.Id,
- DrugId=jiaojie_it.DrugId,
- DrawerNo=jiaojie_it.DrawerNo,
- MachineId=jiaojie_it.MachineId,
- }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).WhereColumns(jiaojie_it=>new { jiaojie_it.DrugId, jiaojie_it.DrawerNo, jiaojie_it.MachineId }).ExecuteCommand();
- }
+ cs.Quantity = cs.AddToJJNum;
+ cs.NeedNum= 0;
+ cs.AddToJJNum = 0;
+ });
+ SqlSugarHelper.Db.Updateable(selectedStock).ExecuteCommand();
List jiaojie = selectedStock.GroupBy(cs => cs.DrawerNo).Select(cs => cs.FirstOrDefault()).ToList();
if (jiaojie != null && jiaojie.Count > 0)
@@ -152,7 +177,7 @@ namespace DM_Weight.ViewModels
ChannelList jiaojieList = new ChannelList();
jiaojieList.State = 0;
jiaojieList.Id = jiaojie_it.ChannelLst.Id;
- //更新交接柜状态为 已取药未入库
+ //更新交接柜状态为0
var result = SqlSugarHelper.Db.Updateable(jiaojieList)
.UpdateColumns(it => new { it.State, it.Id }).ExecuteCommand();
}
diff --git a/DM_Weight/ViewModels/BindBoxPackageWindowViewModel.cs b/DM_Weight/ViewModels/BindBoxPackageWindowViewModel.cs
index bbbc823..26a8310 100644
--- a/DM_Weight/ViewModels/BindBoxPackageWindowViewModel.cs
+++ b/DM_Weight/ViewModels/BindBoxPackageWindowViewModel.cs
@@ -124,9 +124,15 @@ namespace DM_Weight.ViewModels
.Includes(cs => cs.DrugInfo)
.Where(cs => cs.MachineId.Equals("DM5"))
.Where(cs => cs.DrawerNo == DrawerNo).ToList();
+
if (list != null && list.Count > 0)
{
- Channels = list;
+ Channels=list.GroupBy(cs =>cs.DrugId).Select(cs =>
+ {
+ var ret = cs.First();
+ ret.Quantity = cs.Sum(itx => itx.Quantity);
+ return ret;
+ }).ToList();
}
else
{
@@ -212,7 +218,9 @@ namespace DM_Weight.ViewModels
DrugId = DrugInfo.DrugId.ToString(),
BaseQuantity = baseQuantity,
Id = Guid.NewGuid().ToString(),
- MachineId = "DM5"
+ MachineId = "DM5",
+ AddToJJNum=0,
+ NeedNum=baseQuantity
}).ExecuteCommand();
// 保存数据 入库记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
index 4cc834e..3585633 100644
--- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
@@ -27,7 +27,7 @@ namespace DM_Weight.ViewModels
public class CheckOrderNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
- System.Timers.Timer CheckBoxStatusTimer;
+ // System.Timers.Timer CheckBoxStatusTimer;
private int _pageNum = 1;
public int PageNum
@@ -50,7 +50,7 @@ namespace DM_Weight.ViewModels
}
}
- private int _pageSize = 10;
+ private int _pageSize = 8;
public int PageSize
{
get => _pageSize;
@@ -334,7 +334,7 @@ namespace DM_Weight.ViewModels
PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
if (Convert.ToDateTime(currentList.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
{
- switch (DrawerNo)
+ switch (DrawerNo+1)
{
case 1:
_button1Color = Brushes.Yellow;
@@ -560,8 +560,9 @@ namespace DM_Weight.ViewModels
continue;
}
cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity;
+ cs.NeedNum =cs.NeedNum + oi._OrderDetail.Quantity;
// 更新数据 库存信息
- SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
+ SqlSugarHelper.Db.Updateable(cs).UpdateColumns(it => new { it.Quantity,it.NeedNum }).ExecuteCommand();
if (cs != null)
{
@@ -710,11 +711,11 @@ namespace DM_Weight.ViewModels
{
AlertMsg alertMsg = new AlertMsg
{
- Message = $"所选单子中对应药品批次效期无效{empChannelStock}",
+ Message = $"所选单子中对应药品批次无效{empChannelStock}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent().Publish(alertMsg);
- logger.Info($"所选单子对应药品批次效期无效{empChannelStock}");
+ logger.Info($"所选单子对应药品批次无效{empChannelStock}");
throw new Exception("事务回滚");
}
return true;
@@ -762,8 +763,13 @@ namespace DM_Weight.ViewModels
public bool KeepAlive => false;
- public async void OpenBoxAction(string strDrawerNo)
+ public void OpenBoxAction(string strDrawerNo)
{
+ if (ModbusHelper.BoxOperate)
+ {
+ Task.Factory.StartNew(() => { ModbusHelper.SpeakAsync("请关闭药箱后再打开"); });
+ return;
+ }
DrawerNo = Convert.ToInt32(strDrawerNo);
MachineRecord machineRecord = new MachineRecord();
machineRecord.MachineId = "DM5";
@@ -774,28 +780,38 @@ namespace DM_Weight.ViewModels
machineRecord.InvoiceId = $"打开{DrawerNo + 1}号药箱";
- if (DrawerNo > 0)
+ if (DrawerNo >= 0)
{
RequestData();
Status = 1;
- _portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
+ ModbusHelper.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
//logger.Info($"正在打开{DrawerNo + 1}号药箱");
//记录开药箱日志
SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
//设置对应药箱按钮可用状态
- SetIsEnableStatus(DrawerNo, false);
+ //SetIsEnableStatus(DrawerNo, false);
//_eventAggregator.GetEvent().Publish();
- if (CheckBoxStatusTimer is null)
+ Task.Factory.StartNew(async () =>
{
- CheckBoxStatusTimer = new System.Timers.Timer();
- }
- if (!CheckBoxStatusTimer.Enabled)
- {
- CheckBoxStatusTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetAllBoxState);
- CheckBoxStatusTimer.Interval = 3000;
- CheckBoxStatusTimer.Start();
- }
+ bool loop = true;
+ while (loop)
+ {
+ await Task.Delay(9000);
+ bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
+ bool state = Array.TrueForAll(boolsl, b => b == false);
+ if (state)
+ {
+ loop = false;
+ ModbusHelper.BoxOperate = false;
+ }
+ else
+ {
+ ModbusHelper.BoxOperate = true;
+ ModbusHelper.SpeakAsync("药箱已打开,请及时关闭");
+ }
+ }
+ });
//设置对应药箱按钮可用状态
//SetIsEnableStatus(DrawerNo, false);
}
@@ -874,27 +890,6 @@ namespace DM_Weight.ViewModels
public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
- private void GetAllBoxState(object sender, ElapsedEventArgs e)
- {
- //查询药箱是否关闭,如果已经关闭则按钮可用,可继续开该编号的药箱
- if (DrawerNo >= 0)
- {
- bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
- bool allFalse = Array.TrueForAll(boolArrs, b => b == false);
- if (allFalse)
- {
- if (CheckBoxStatusTimer.Enabled)
- {
- CheckBoxStatusTimer.Stop();
- }
- }
- for (int i = 0; i < boolArrs.Length; i++)
- {
- //设置对应药箱按钮可用状态
- SetIsEnableStatus(i, !boolArrs[i]);
- }
- }
- }
//void DoMyPrismEvent(DeviceMsg msg)
//{
diff --git a/DM_Weight/ViewModels/CheckSelfOrderWindowViewModel.cs b/DM_Weight/ViewModels/CheckSelfOrderWindowViewModel.cs
index e73f2c8..97ececf 100644
--- a/DM_Weight/ViewModels/CheckSelfOrderWindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckSelfOrderWindowViewModel.cs
@@ -1184,6 +1184,11 @@ namespace DM_Weight.ViewModels
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
+ if(ModbusHelper.BoxOperate)
+ {
+ Task.Factory.StartNew(() => { ModbusHelper.SpeakAsync("请关闭药箱后再打开"); });
+ return;
+ }
//查询当前药师的第一个药箱号并打开该药箱
int drawerNo = SqlSugarHelper.Db.Queryable().Where(cl => cl.MachineId == "DM5" && cl.BelongUser == HomeWindowViewModel.Operator.UserBarcode).Select(cl => cl.DrawerNo).First();
if (drawerNo > 0)
@@ -1206,7 +1211,7 @@ namespace DM_Weight.ViewModels
_portUtil.SpeakAsync($"正在打开{drawerNo}号药箱");
logger.Info($"正在打开{drawerNo}号药箱");
ModbusHelper.GetInstance().OpenBoxDoor(drawerNo - 1);
- SetBtnEnable(drawerNo, false);
+ //SetBtnEnable(drawerNo, false);
//if (CheckBoxStatusTimer is null)
//{
// CheckBoxStatusTimer = new System.Timers.Timer();
@@ -1225,7 +1230,26 @@ namespace DM_Weight.ViewModels
channelList.EffDate = DateTime.Now.ToString();
SqlSugarHelper.Db.Updateable(channelList).UpdateColumns(it => new { it.EffDate }).ExecuteCommand();
}
-
+ Task.Factory.StartNew(async () =>
+ {
+ bool loop = true;
+ while (loop)
+ {
+ await Task.Delay(9000);
+ bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
+ bool state = Array.TrueForAll(boolsl, b => b == false);
+ if (state)
+ {
+ loop = false;
+ ModbusHelper.BoxOperate = false;
+ }
+ else
+ {
+ ModbusHelper.BoxOperate = true;
+ ModbusHelper.SpeakAsync("药箱已打开,请及时关闭");
+ }
+ }
+ });
}
}
//private void GetAllBoxState(object sender, ElapsedEventArgs e)
diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs
index 67ce963..032aea5 100644
--- a/DM_Weight/ViewModels/HomeWindowViewModel.cs
+++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs
@@ -40,11 +40,11 @@ namespace DM_Weight.ViewModels
///
/// 冰箱温度
///
- private string _wd = "恒温冷藏抽屉当前温度2.8(非真实数据)";
- public string WD { get => _wd; set => SetProperty(ref _wd, value); }
- System.Timers.Timer WDTimer;
+ //private string _wd = "恒温冷藏抽屉当前温度2.8(非真实数据)";
+ //public string WD { get => _wd; set => SetProperty(ref _wd, value); }
+ //System.Timers.Timer WDTimer;
- System.Timers.Timer WSDTimer;
+ //System.Timers.Timer WSDTimer;
///
/// 是否有冰箱抽屉
@@ -287,10 +287,8 @@ namespace DM_Weight.ViewModels
//}
if (SelectedMenu != null && SelectedMenu.PremissionName == "退出")
{
- bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
- bool allTrue = Array.TrueForAll(boolArrs, b => b);
//false是关着,true是开着
- if (!allTrue)
+ if (!ModbusHelper.BoxOperate)
{
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
@@ -300,12 +298,8 @@ namespace DM_Weight.ViewModels
else
{
//还有药箱开着不能退出
- AlertMsg alertMsg = new AlertMsg
- {
- Message = "请关闭药箱后再退出系统",
- Type = MsgType.ERROR
- };
- _eventAggregator.GetEvent().Publish(alertMsg);
+ _portUtil.SpeakAsync("请关闭药箱后再退出");
+ SelectedMenu = _premissionDmList[0];
}
}
else
@@ -611,17 +605,40 @@ namespace DM_Weight.ViewModels
// timer.Start();
//}
#region 温度查询定时
- int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
- if (interval > 0)
- {
- WSDTimer = new System.Timers.Timer();
+ //int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
+ //if (interval > 0)
+ //{
+ // WSDTimer = new System.Timers.Timer();
- WSDTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetWSD);
- WSDTimer.Interval = interval;
- WSDTimer.Start();
- //WDTimer.AutoReset = true;
- //WDTimer.Enabled = true;
- }
+ // WSDTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetWSD);
+ // WSDTimer.Interval = interval;
+ // WSDTimer.Start();
+ // //WDTimer.AutoReset = true;
+ // //WDTimer.Enabled = true;
+ //}
+ Task.Factory.StartNew(async () =>
+ {
+ while (true)
+ {
+ TemperatureHumidityInfo temp = _portUtil.GetWSD();
+ if (temp != null)
+ {
+ SqlSugarHelper.Db.Insertable(new TemperatureHumidityInfo()
+ {
+ GroupNo = temp.GroupNo,
+ Temp = temp.Temp,
+ Humi = temp.Humi,
+ AddTime = DateTime.Now
+ }).ExecuteCommand();
+ logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
+ await Task.Delay(1200000);//20分钟查一次
+ }
+ else
+ {
+ logger.Info("温湿度信息返回空");
+ }
+ }
+ });
#endregion
//if (stopRecord > 0)
//{
diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
index 6bbfbb2..a4b68fe 100644
--- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
+++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
@@ -483,13 +483,13 @@ namespace DM_Weight.ViewModels
};
PremissionDm machineRecord= new PremissionDm
{
- Id = 54,
+ Id = 55,
PremissionName = "操作记录",
PremissionPath = "MachineRecordWindow",
};
PremissionDm wSDRecord= new PremissionDm
{
- Id = 54,
+ Id = 56,
PremissionName = "温湿度记录",
PremissionPath = "WSDRecordWindow",
};
@@ -514,13 +514,18 @@ namespace DM_Weight.ViewModels
// PremissionPath = "SettingWindow",
// };
//}
-
+ sysset3 = new PremissionDm
+ {
+ Id = 57,
+ PremissionName = "登录设置",
+ PremissionPath = "SettingWindow",
+ };
syssetChild.Add(sysset1);
syssetChild.Add(sysset2);
- syssetChild.Add(sysset3);
syssetChild.Add(settingBox);
syssetChild.Add(machineRecord);
syssetChild.Add(wSDRecord);
+ syssetChild.Add(sysset3);
sysset.Children = syssetChild;
defaultAll.Add(sysset);
#endregion
diff --git a/DM_Weight/ViewModels/SettingBoxWindowViewModel.cs b/DM_Weight/ViewModels/SettingBoxWindowViewModel.cs
index 02648e3..a14c17b 100644
--- a/DM_Weight/ViewModels/SettingBoxWindowViewModel.cs
+++ b/DM_Weight/ViewModels/SettingBoxWindowViewModel.cs
@@ -198,6 +198,12 @@ namespace DM_Weight.ViewModels
{
if (DrawerNo > 0)
{
+
+ if (ModbusHelper.BoxOperate)
+ {
+ Task.Factory.StartNew(() => { ModbusHelper.SpeakAsync("请关闭药箱后再打开"); });
+ return;
+ }
IsEnable = false;
Status = 1;
//_portUtil.SpeakAsync("正在打开药箱");
@@ -219,6 +225,26 @@ namespace DM_Weight.ViewModels
IsEnable = true;
Status = 0;
}
+ Task.Factory.StartNew(async () =>
+ {
+ bool loop = true;
+ while (loop)
+ {
+ await Task.Delay(9000);
+ bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
+ bool state = Array.TrueForAll(boolsl, b => b == false);
+ if (state)
+ {
+ loop = false;
+ ModbusHelper.BoxOperate = false;
+ }
+ else
+ {
+ ModbusHelper.BoxOperate = true;
+ ModbusHelper.SpeakAsync("药箱已打开,请及时关闭");
+ }
+ }
+ });
}
});
}
diff --git a/DM_Weight/Views/AdditionWindow.xaml b/DM_Weight/Views/AdditionWindow.xaml
index 954fcaa..851015a 100644
--- a/DM_Weight/Views/AdditionWindow.xaml
+++ b/DM_Weight/Views/AdditionWindow.xaml
@@ -160,8 +160,8 @@
-
-
+
+
diff --git a/DM_Weight/Views/CheckOrderNewWindow.xaml b/DM_Weight/Views/CheckOrderNewWindow.xaml
index 538eb19..3be8011 100644
--- a/DM_Weight/Views/CheckOrderNewWindow.xaml
+++ b/DM_Weight/Views/CheckOrderNewWindow.xaml
@@ -29,6 +29,7 @@
+
@@ -141,12 +142,11 @@
-
+ materialDesign:ListViewAssist.ListViewItemPadding="0 15 0 0">
-
+
+
-
-
+ Header="合计"/>
diff --git a/DM_Weight/Views/CheckSelfOrderWindow.xaml b/DM_Weight/Views/CheckSelfOrderWindow.xaml
index 121a99d..0c5dc47 100644
--- a/DM_Weight/Views/CheckSelfOrderWindow.xaml
+++ b/DM_Weight/Views/CheckSelfOrderWindow.xaml
@@ -151,12 +151,11 @@
-
+ materialDesign:ListViewAssist.ListViewItemPadding="0 15 0 0">