diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 6b861da..dfe1c02 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -3,7 +3,7 @@
-
+
-
+
@@ -20,7 +20,7 @@
-
+
@@ -40,7 +40,7 @@
-
+
@@ -58,7 +58,7 @@
-
+
@@ -73,11 +73,14 @@
-
+
-
+
-
+
+
+
+
\ No newline at end of file
diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs
index 3e7521c..d04ea64 100644
--- a/DM_Weight/App.xaml.cs
+++ b/DM_Weight/App.xaml.cs
@@ -177,6 +177,7 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation();
// 还空瓶页面
containerRegistry.RegisterForNavigation();
+ containerRegistry.RegisterForNavigation();
// 归还空瓶模态框
containerRegistry.RegisterDialog();
containerRegistry.RegisterForNavigation();
@@ -223,6 +224,10 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation();
+ containerRegistry.RegisterForNavigation();
+
+ containerRegistry.RegisterForNavigation();
+
}
private void PrismApplication_Startup(object sender, StartupEventArgs e)
{
diff --git a/DM_Weight/Common/TemperatureRangeRule.cs b/DM_Weight/Common/TemperatureRangeRule.cs
index 1ebe4bd..04d3b5f 100644
--- a/DM_Weight/Common/TemperatureRangeRule.cs
+++ b/DM_Weight/Common/TemperatureRangeRule.cs
@@ -23,11 +23,18 @@ namespace DM_Weight.Common
string[] rang = value.ToString().Split('-');
if (rang.Length >= 2)
{
- bool bSRange = int.TryParse(rang[0], out int sRange);
- bool bERange = int.TryParse(rang[1], out int eRange);
+ bool bSRange = float.TryParse(rang[0], out float sRange);
+ bool bERange = float.TryParse(rang[1], out float eRange);
if (bSRange && bERange)
{
- if (sRange < 2 || eRange > 8)
+ 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))
{
tips = "温度区间设置2-8度,请检查输入";
return new ValidationResult(flag, tips);
diff --git a/DM_Weight/Converter/OpenBoxConverter.cs b/DM_Weight/Converter/OpenBoxConverter.cs
new file mode 100644
index 0000000..0e69327
--- /dev/null
+++ b/DM_Weight/Converter/OpenBoxConverter.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace DM_Weight.Converter
+{
+ internal class OpenBoxConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool status = bool.Parse(value.ToString());
+ if(status)
+ {
+ return Visibility.Visible;
+ }
+ else
+ {
+ return Visibility.Collapsed;
+ }
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/DM_Weight/Converter/StatusConverter.cs b/DM_Weight/Converter/StatusConverter.cs
index 8a1a5d8..a7484e2 100644
--- a/DM_Weight/Converter/StatusConverter.cs
+++ b/DM_Weight/Converter/StatusConverter.cs
@@ -73,6 +73,42 @@ namespace DM_Weight.Converter
return Visibility.Collapsed;
}
}
+ //清空按钮的显示与隐藏
+ if(parameter.ToString().Equals("clearVisuability"))
+ {
+ if (status == 1)
+ {
+ return Visibility.Visible;
+ }
+ else
+ {
+ return Visibility.Collapsed;
+ }
+ }
+ //清空按钮的操作状态
+ if(parameter.ToString().Equals("clearBtnLoading"))
+ {
+ if (status == 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //标定按钮的操作状态
+ if(parameter.ToString().Equals("biaoDingBtnLoading"))
+ {
+ if (status >3)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
return Visibility.Collapsed;
}
diff --git a/DM_Weight/DM_Weight.csproj b/DM_Weight/DM_Weight.csproj
index 7981b1a..7a58d6d 100644
--- a/DM_Weight/DM_Weight.csproj
+++ b/DM_Weight/DM_Weight.csproj
@@ -70,6 +70,7 @@
+
diff --git a/DM_Weight/Models/MachineRecord.cs b/DM_Weight/Models/MachineRecord.cs
index 9942ddc..2cefc78 100644
--- a/DM_Weight/Models/MachineRecord.cs
+++ b/DM_Weight/Models/MachineRecord.cs
@@ -1,4 +1,5 @@
-using SqlSugar;
+using Prism.Mvvm;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,7 +10,7 @@ using System.Threading.Tasks;
namespace DM_Weight.Models
{
[SugarTable("dm_machine_record")]
- public class MachineRecord
+ public class MachineRecord:BindableBase
{
///
/// 主键
@@ -114,6 +115,27 @@ namespace DM_Weight.Models
///
[SugarColumn(ColumnName = "return_quantity2", IsOnlyIgnoreInsert = true)]
public int ReturnQuantity2 { get; set; }
+ ///
+ /// 当前还空瓶量
+ /// 默认值: 0
+ ///
+ private int _currentReturn;
+ [SugarColumn(IsIgnore = true)]
+ public int CurrentReturn
+ {
+ get=>_currentReturn;
+ set
+ {
+ if (value > CanReturnQuantity)
+ {
+ throw new ArgumentException("");
+ }
+ SetProperty(ref _currentReturn, value);
+ }
+ }
+
+
+
///
/// 取药记录id
///
@@ -143,5 +165,10 @@ namespace DM_Weight.Models
///
[SugarColumn(ColumnName = "manunoQuantity")]
public int? ManunoQuantity { get; set; }
+
+
+ private DrugManuNo? _drugManuNo;
+ [SugarColumn(IsIgnore = true)]
+ public DrugManuNo? drugManuNo { get => _drugManuNo; set => SetProperty(ref _drugManuNo, value); }
}
}
diff --git a/DM_Weight/Models/OrderDetail.cs b/DM_Weight/Models/OrderDetail.cs
index 109654c..d3acf0e 100644
--- a/DM_Weight/Models/OrderDetail.cs
+++ b/DM_Weight/Models/OrderDetail.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Prism.Mvvm;
using SqlSugar;
namespace DM_Weight.Models
{
@@ -8,12 +9,12 @@ namespace DM_Weight.Models
///
///
[SugarTable("order_detail")]
- public class OrderDetail
+ public class OrderDetail: BindableBase
{
///
///
///
- [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
+ [SugarColumn(ColumnName = "id", IsIdentity = true, IsPrimaryKey = true)]
public int Id { get; set; }
///
///
@@ -29,6 +30,11 @@ namespace DM_Weight.Models
///
///
///
+ [SugarColumn(ColumnName = "order_id")]
+ public string OrderId { get; set; }
+ ///
+ ///
+ ///
[SugarColumn(ColumnName = "order_no")]
public string OrderNo { get; set; }
///
@@ -50,6 +56,12 @@ namespace DM_Weight.Models
[Navigate(NavigateType.ManyToOne, nameof(DrugId))]
public DrugInfo DrugInfo { get; set; }
+
+ [Navigate(NavigateType.ManyToMany, nameof(DrugId))]
+ public List DrugInfos { get; set; }
+
+ [Navigate(NavigateType.ManyToMany, nameof(DrugId))]
+ public List MachineRecords { get; set; }
///
///
///
@@ -127,5 +139,33 @@ namespace DM_Weight.Models
///
[SugarColumn(ColumnName = "use_dosage")]
public string UseDosage { get; set; }
+
+ ///
+ /// 已还药数
+ ///
+ private int _returnQuantity = 0;
+ [SugarColumn(ColumnName = "return_quantity")]
+ public int ReturnQuantity
+ {
+ get;
+ set;
+ }
+ //当前还药数
+ private int currentReturnQuantity;
+ [SugarColumn(IsIgnore =true)]
+ public int CurrentReturnQuantity
+ {
+ get => currentReturnQuantity;
+ set
+ {
+ //if (value > Quantity - ReturnQuantity)
+ // throw new ArgumentException("数量有误");
+ SetProperty(ref currentReturnQuantity, value);
+ }
+ }
+
+ private OrderInfo? _orderInfo;
+ [Navigate(NavigateType.OneToOne,nameof(OrderNo))]
+ public OrderInfo orderInfo { get => _orderInfo; set => SetProperty(ref _orderInfo, value); }
}
}
\ No newline at end of file
diff --git a/DM_Weight/Models/OrderFinish.cs b/DM_Weight/Models/OrderFinish.cs
index c166ac7..7839697 100644
--- a/DM_Weight/Models/OrderFinish.cs
+++ b/DM_Weight/Models/OrderFinish.cs
@@ -27,6 +27,19 @@ namespace DM_Weight.Models
[SugarColumn(ColumnName = "operator")]
public string Operator { get; set; }
-
+
+ [SugarColumn(ColumnName = "drug_id")]
+ public string DrugId { get; set; }
+
+ [SugarColumn(ColumnName = "quantity")]
+ public int Quantity { get; set; }
+
+ //[SugarColumn(ColumnName = "manu_no")]
+ //public string ManuNo { get; set; }
+
+ //[SugarColumn(ColumnName = "eff_date")]
+ //public string EffDate { get; set; }
+
+
}
}
diff --git a/DM_Weight/Models/OrderInfo.cs b/DM_Weight/Models/OrderInfo.cs
index 2be2040..0524ec8 100644
--- a/DM_Weight/Models/OrderInfo.cs
+++ b/DM_Weight/Models/OrderInfo.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Prism.Mvvm;
using SqlSugar;
namespace DM_Weight.Models
{
@@ -8,7 +9,7 @@ namespace DM_Weight.Models
///
///
[SugarTable("order_info")]
- public class OrderInfo
+ public class OrderInfo:BindableBase
{
@@ -16,7 +17,7 @@ namespace DM_Weight.Models
/// 是否选中
///
[SugarColumn(IsIgnore = true)]
- public bool ItemIsChecked { get; set; }
+ public bool ItemIsChecked { get; set; } = false;
///
///
@@ -197,6 +198,10 @@ namespace DM_Weight.Models
//[SugarColumn(ColumnName = "identity")]
//public string Identity { get; set; }
+ private OrderDetail? _orderDetail;
+ [Navigate(NavigateType.OneToOne, nameof(OrderDetail.OrderNo))]
+ public OrderDetail orderDetail { get=> _orderDetail; set=>SetProperty(ref _orderDetail, value); }
+
}
}
\ No newline at end of file
diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs
index 03de52a..a1095a8 100644
--- a/DM_Weight/Port/PortUtil.cs
+++ b/DM_Weight/Port/PortUtil.cs
@@ -25,6 +25,7 @@ using DM_Weight.Views;
using System.Reflection;
using System.Text.RegularExpressions;
using DM_Weight.Common;
+using System.Threading;
namespace DM_Weight.Port
{
@@ -57,6 +58,10 @@ namespace DM_Weight.Port
public int DrawerNo { get; set; }
// 当前操作的库位号列表
public int[] ColNos { get; set; } = new int[] { };
+ // 当前操作查数的库位号列表
+ public List ColNoLst { get; set; } = new List();
+ // 当前操作开药盒的库位号
+ public int OpenBoxColNo { get; set; } = 0;
// 当前操作的窗口
public string WindowName { get; set; }
@@ -72,7 +77,7 @@ namespace DM_Weight.Port
public int BoardType { get; set; } = (Int32)BoardTypeEnum.separation;
public int DrawerType { get; set; } = (Int32)DrawerTypeEnum.drawerTypeOne;
- private int[] BeforeQuantity { get; set; } = new int[] { };
+ private int[] BeforeQuantity { get; set; } = new int[9];
private int[] AfterQuantity { get; set; } = new int[] { };
// 整体流程状态
@@ -108,18 +113,18 @@ namespace DM_Weight.Port
// 失能
CloseStorage();
}
- if (BoardType == (Int32)BoardTypeEnum.weigh)
- {
- // 失能
- await BoxLockLightOff2();
- }
- if (BoardType == (Int32)BoardTypeEnum.weighSmartBox || BoardType == (Int32)BoardTypeEnum.weighBox)
- {
- // 失能
- await BoxLockLightOff();
- // 失能
- await BoxLockLightOff2();
- }
+ //if (BoardType == (Int32)BoardTypeEnum.weigh)
+ //{
+ // // 失能
+ // await BoxLockLightOff2();
+ //}
+ //if (BoardType == (Int32)BoardTypeEnum.weighSmartBox || BoardType == (Int32)BoardTypeEnum.weighBox)
+ //{
+ // // 失能
+ // await BoxLockLightOff();
+ // // 失能
+ // await BoxLockLightOff2();
+ //}
}
Operate = false;
dateTime = DateTime.Now;
@@ -219,9 +224,16 @@ namespace DM_Weight.Port
}
if (BoardType == (Int32)BoardTypeEnum.weigh || BoardType == (Int32)BoardTypeEnum.weighSmartBox || BoardType == (Int32)BoardTypeEnum.weighBox)
{
- int[] quantity = await CheckQuantityByAddr2();
- BeforeQuantity = quantity.Select(it => Convert.ToInt32(it)).ToArray();
- logger.Info($"BeforeQuantity{string.Join(",", BeforeQuantity)}");
+ if (WindowName != "DrawerTakeDrugWindow" && WindowName != "DrawerAddDrugWindow")
+ {
+ int[] quantity = await CheckQuantityByAddr2();
+ BeforeQuantity = quantity.Select(it => Convert.ToInt32(it)).ToArray();
+ logger.Info($"BeforeQuantity{string.Join(",", BeforeQuantity)}");
+ }
+ else
+ {
+ logger.Info($"{WindowName}开锁前先不查数");
+ }
}
byte[] buffer = await OpenDrawer();
@@ -259,15 +271,38 @@ namespace DM_Weight.Port
}
}
// 药盒
- if (BoardType == (Int32)BoardTypeEnum.box)
+ //if (BoardType == (Int32)BoardTypeEnum.box)
+ //{
+ // //抽屉加药和抽屉取药不开药盒锁(单独开)
+ // if (WindowName != "DrawerTakeDrugWindow" || WindowName != "DrawerAddDrugWindow")
+ // {
+ // logger.Info("开锁后药盒自动打开");
+ // //// 药盒指示灯使能
+ // //await BoxLockLightOn();
+ // await OpenBox();
+ // }
+ // else
+ // {
+ // logger.Info("开锁后先不开药盒");
+ // //抽屉加药和抽屉取药根据点的开药盒按钮的库位查数
+ // ColNos = null;
+ // }
+ //}
+ if (BoardType == (Int32)BoardTypeEnum.box || BoardType == (Int32)BoardTypeEnum.weighSmartBox || BoardType == (Int32)BoardTypeEnum.weighBox)
{
- // 药盒指示灯使能
- await BoxLockLightOn();
- }
- if (BoardType == (Int32)BoardTypeEnum.weigh || BoardType == (Int32)BoardTypeEnum.weighSmartBox || BoardType == (Int32)BoardTypeEnum.weighBox)
- {
- // 药盒指示灯使能
- await BoxLockLightOn2();
+ //抽屉加药和抽屉取药不开药盒锁(单独开)
+ if (WindowName != "DrawerTakeDrugWindow" && WindowName != "DrawerAddDrugWindow")
+ {
+ logger.Info($"开锁后药盒自动打开{WindowName}");
+ // 药盒指示灯使能
+ await OpenBox();
+ }
+ else
+ {
+ logger.Info($"{WindowName}开锁后先不开药盒");
+ //抽屉加药和抽屉取药根据点的开药盒按钮的库位查数
+ ColNos = null;
+ }
}
// 返回消息 抽屉已经打开
_eventAggregator.GetEvent().Publish(new util.DeviceMsg()
@@ -378,42 +413,60 @@ namespace DM_Weight.Port
{
// 继续查询抽屉药品数量
// 查询抽屉药品数量
- int[] quantity = await CheckQuantityByAddr2();
- AfterQuantity = quantity.Select(it => Convert.ToInt32(it)).ToArray();
- logger.Info($"AfterQuantity{string.Join(",", AfterQuantity)}");
- int[] Quantitys = new int[BeforeQuantity.Length];
- for (int i = 0; i < BeforeQuantity.Length; i++)
+ if (ColNos != null && ColNos.Length > 0 || OpenBoxColNo > 0)
{
- // 取药
- if (Array.IndexOf(TakeNames, WindowName) > -1)
+ //开药盒锁
+ if (OpenBoxColNo > 0&&(WindowName== "DrawerTakeDrugWindow" || WindowName== "DrawerAddDrugWindow"))
{
- Quantitys[i] = BeforeQuantity[i] - AfterQuantity[i];
+ //开药盒锁前先查数
+ int beforeQuantity = await CheckQuantityForSingle(OpenBoxColNo);
+ BeforeQuantity[OpenBoxColNo - 1] = beforeQuantity;
+ logger.Info($"BeforeQuantity:{OpenBoxColNo}-{beforeQuantity}数量{string.Join(",", BeforeQuantity)}");
+ OpenBoxByColNo(OpenBoxColNo);
+ OpenBoxColNo = 0;
+ await Task.Delay(TimeSpan.FromMilliseconds(20));
}
- // 加药
- if (Array.IndexOf(AddNames, WindowName) > -1)
+ int[] quantity = await CheckQuantityByAddr2();
+ AfterQuantity = quantity.Select(it => Convert.ToInt32(it)).ToArray();
+ logger.Info($"AfterQuantity{string.Join(",", AfterQuantity)}");
+ int[] Quantitys = new int[BeforeQuantity.Length];
+ for (int i = 0; i < BeforeQuantity.Length; i++)
{
- Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
- }
- // 盘点
- if (Array.IndexOf(CheckNames, WindowName) > -1)
- {
- Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
- }
- // 空瓶
- if (Array.IndexOf(CheckNames, WindowName) > -1)
- {
- Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
- }
+ // 取药
+ if (Array.IndexOf(TakeNames, WindowName) > -1)
+ {
+ Quantitys[i] = BeforeQuantity[i] - AfterQuantity[i];
+ }
+ // 加药
+ if (Array.IndexOf(AddNames, WindowName) > -1)
+ {
+ Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
+ }
+ // 盘点
+ if (Array.IndexOf(CheckNames, WindowName) > -1)
+ {
+ Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
+ }
+ // 空瓶
+ if (Array.IndexOf(CheckNames, WindowName) > -1)
+ {
+ Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
+ }
+ }
+ // 告诉前台数据变化
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.UPDATEQUANTITY,
+ WindowName = WindowName,
+ Quantitys = Quantitys
+ });
+ logger.Info($"数量变化【{string.Join(",", Quantitys)}】");
}
- // 告诉前台数据变化
- _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ else
{
- EventType = util.EventType.UPDATEQUANTITY,
- WindowName = WindowName,
- Quantitys = Quantitys
- });
- logger.Info($"数量变化【{string.Join(",", Quantitys)}】");
+ logger.Info("无库位,不查数");
+ }
}
// 继续监听抽屉状态
@@ -430,16 +483,16 @@ namespace DM_Weight.Port
}
// 药盒
- if (BoardType == (Int32)BoardTypeEnum.box)
- {
- // 药盒指示灯失能
- await BoxLockLightOff();
- }
- if (BoardType == (Int32)BoardTypeEnum.weigh || BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- // 药盒指示灯使能
- await BoxLockLightOff2();
- }
+ //if (BoardType == (Int32)BoardTypeEnum.box)
+ //{
+ // // 药盒指示灯失能
+ // await BoxLockLightOff();
+ //}
+ //if (BoardType == (Int32)BoardTypeEnum.weigh || BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // // 药盒指示灯使能
+ // await BoxLockLightOff2();
+ //}
string _WindowName = WindowName;
logger.Info($"抽屉【{DrawerNo}】已关闭");
// 重新初始化数据
@@ -706,7 +759,7 @@ namespace DM_Weight.Port
}
if (_length != length)
{
- throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
+ throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
}
serialPort.Read(buffer, 0, length);
// }
@@ -735,27 +788,45 @@ namespace DM_Weight.Port
// 打开抽屉
public async Task OpenDrawer()
{
- drawerSerial.DiscardInBuffer();
- byte[] buffer = new byte[] { 0xaa, 0x41, (byte)DrawerNo, 0xee };
- if (_drawerProtocol == 485)
+ try
{
- if (DrawerNo > 8)
- {
- buffer = new byte[] { 0xaa, 0x21, (byte)(DrawerNo - 8), 0xee };
- }
- else
- {
- buffer = new byte[] { 0xaa, 0x11, (byte)DrawerNo, 0xee };
- }
+ drawerSerial.DiscardInBuffer();
+ byte[] buffer = new byte[] { 0xaa, 0x41, (byte)DrawerNo, 0xee };
+ if (_drawerProtocol == 485)
+ {
+ if (DrawerNo > 8)
+ {
+ buffer = new byte[] { 0xaa, 0x21, (byte)(DrawerNo - 8), 0xee };
+ }
+ else
+ {
+ buffer = new byte[] { 0xaa, 0x11, (byte)DrawerNo, 0xee };
+ }
+
+ }
+ logger.Info($"打开抽屉,串口数据:{Convert.ToHexString(buffer)}");
+ drawerSerial.Write(buffer, 0, 4);
+
+ return await GetBufferByPort(drawerSerial, 11);
+ }
+ catch (Exception ex)
+ {
+ logger.Info($"抽屉【{DrawerNo}】打开失败");
+ // 返回消息 抽屉打开失败
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.OPENERROR,
+ WindowName = WindowName,
+ Message = $"抽屉【{DrawerNo}】打开失败"
+ });
+ // 重新初始化数据
+ ResetData();
+ return null;
}
- logger.Info($"打开抽屉,串口数据:{Convert.ToHexString(buffer)}");
- drawerSerial.Write(buffer, 0, 4);
-
- return await GetBufferByPort(drawerSerial, 11);
}
- private bool DrawerState(int[] r)
+ public bool DrawerState(int[] r)
{
int index = DrawerNo > 8 ? DrawerNo - 7 : DrawerNo + 1;
return r[index] == 0;
@@ -947,6 +1018,65 @@ namespace DM_Weight.Port
#endregion
#region 药盒操作
+ //无按钮开药盒
+ ///
+ /// 开指定库位的药盒
+ ///
+ ///
+ ///
+ public async Task OpenBoxByColNo(int colNo)
+ {
+ if (colNo > 0)
+ {
+ canBusSerial.DiscardInBuffer();
+ int ColNo = colNo;
+ int[] iNum = new int[] { 4, 2, 1 };
+ var colNo2 = ColNo % 3 > 0 ? (ColNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)ColNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, 5, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
+ //byte[] buffer = new byte[] { 0xaa, 0x11, 0x05,0x01, 0x00,0x00,0x00,0xee};
+ logger.Info($"开药盒{ColNo}【{Convert.ToHexString(buffer)}】");
+ canBusSerial.Write(buffer, 0, 8);
+ byte[] retBuffer = await GetBufferByPort(canBusSerial, 8);
+ logger.Info($"开药盒返回{ColNo}【{Convert.ToHexString(retBuffer)}】");
+ int[] r = retBuffer.Select(it => Convert.ToInt32(it)).ToArray();
+ if (r[4] > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ return false;
+ }
+ ///
+ /// 打开药盒
+ ///
+ ///
+ ///
+ public async Task OpenBox()
+ {
+ for (int i = 0; i < ColNos.Length; i++)
+ {
+ canBusSerial.DiscardInBuffer();
+ int ColNo = ColNos[i];
+ int[] iNum = new int[] { 4, 2, 1 };
+ var colNo2 = ColNo % 3 > 0 ? (ColNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)ColNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, 5, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
+ //byte[] buffer = new byte[] { 0xaa, 0x11, 0x05,0x01, 0x00,0x00,0x00,0xee};
+ logger.Info($"{Convert.ToHexString(buffer)}");
+ canBusSerial.Write(buffer, 0, 8);
+ await Task.Delay(800);
+ }
+
+ }
// 指定药盒指示灯开启使能开锁
public async Task BoxLockLightOn()
{
@@ -962,12 +1092,15 @@ namespace DM_Weight.Port
// 指定药盒指示灯开启失能开锁
public async Task BoxLockLightOff()
{
- for (int i = 0; i < ColNos.Length; i++)
+ if (ColNos != null)
{
- var channel = Convert.ToInt32((DrawerNo * 10 + ColNos[i]).ToString(), 16);
- byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x04, 0x00, 0x00, 0x00, 0x00, 0xee };
- canBusSerial.Write(buffer, 0, 8);
- await Task.Delay(TimeSpan.FromMilliseconds(20));
+ for (int i = 0; i < ColNos.Length; i++)
+ {
+ var channel = Convert.ToInt32((DrawerNo * 10 + ColNos[i]).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x04, 0x00, 0x00, 0x00, 0x00, 0xee };
+ canBusSerial.Write(buffer, 0, 8);
+ await Task.Delay(TimeSpan.FromMilliseconds(20));
+ }
}
}
// 指定药盒状态查询
@@ -995,6 +1128,10 @@ namespace DM_Weight.Port
byte[] buffer = new byte[] { 0xaa, (byte)(0xf0 + DrawerNo), 0x05, 0x00, 0x00, 0x00, 0x00, 0xee };
canBusSerial.Write(buffer, 0, 8);
}
+
+
+
+
#endregion
private string trim(string text)
@@ -1129,6 +1266,128 @@ namespace DM_Weight.Port
+ #endregion
+ #region 药盒标签显示屏
+ //清屏
+ public void ClearContentMethod(int drawerNo, int colNo)
+ {
+ decimal deColNo = colNo;
+ //var channel = drawerNo * 10 + Math.Ceiling(deColNo / 3);
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = Convert.ToInt32((iNum[colNo2] + 10).ToString(), 16);
+ //var index = Convert.ToInt32(((colNo % 3 == 0 ? 3 : colNo % 3)+10).ToString(),16);
+ int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x09, (byte)bColNo, 0, 0, 0, 0xee };
+ canBusSerial.Write(buffer, 0, 8);
+ logger.Info($"清屏指令:{Convert.ToHexString(buffer)}");
+ }
+ //刷新内容
+ public async void ShowContentMethod(int drawerNo, int colNo)
+ {
+ int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xee };
+ logger.Info($"刷新内容指令:{Convert.ToHexString(buffer)}");
+ canBusSerial.Write(buffer, 0, 8);
+ }
+ // 基础数据写入方法
+ public async void WriteChannelInfoMethod(int type, string content, int drawerNo, int colNo)
+ {
+ try
+ {
+ canBusSerial.DiscardInBuffer();
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ if (content.Length > 10)
+ {
+ content = content.Substring(0, 10);
+ }
+ byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content));
+ int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2] + 160;
+ //var index = (colNo % 3 == 0 ? 3 : colNo % 3)+160;
+ if (contentBuf.Length % 2 != 0)
+ {
+ Array.Resize(ref contentBuf, contentBuf.Length + 1);
+ }
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, (byte)bColNo, (byte)type, 0, 0, 0, 0xee };
+
+
+ canBusSerial.Write(buffer, 0, 8);
+ logger.Info($"开始写标签指令:{Convert.ToHexString(buffer)}");
+ Thread.Sleep(20);
+ buffer[4] = 1;
+ for (int i = 0; i < contentBuf.Length; i += 2)
+ {
+ buffer[5] = contentBuf[i];
+ buffer[6] = contentBuf[i + 1];
+ canBusSerial.Write(buffer, 0, 8);
+ logger.Info($"写标签指令:{Convert.ToHexString(buffer)}");
+ Thread.Sleep(50);
+ }
+ buffer[4] = 2;
+ buffer[5] = 0;
+ buffer[6] = 0;
+ canBusSerial.Write(buffer, 0, 8);
+ logger.Info($"结束写标签指令:{Convert.ToHexString(buffer)}");
+ Thread.Sleep(20);
+
+ }
+ catch (Exception ex)
+ {
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.OPENERROR,
+ WindowName = WindowName,
+ Message = $"2.4寸汉显屏异常{ex.Message}"
+ });
+ logger.Info($"2.4寸汉显屏异常:ex:{ex.Message}");
+ }
+ }
+
+ public async Task WriteQuantityMethod(int quantity, int drawerNo, int colNo)
+ {
+ try
+ {
+ logger.Info($"写数量:{drawerNo}-{colNo}:{quantity}");
+ canBusSerial.DiscardInBuffer();
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ string strQuantity = quantity.ToString("X");
+ if (strQuantity.Length % 2 != 0)
+ {
+ strQuantity = "0" + strQuantity;
+ }
+ int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2] + 160;
+ byte[] buffer = new byte[] { 0xaa, (byte)channel, (byte)bColNo, 0xf2, 01, 0, 0, 0xee };
+ if (strQuantity.Length >= 4)
+ {
+ buffer[5] = Convert.ToByte(strQuantity.Substring(0, 2), 16);
+ buffer[6] = Convert.ToByte(strQuantity.Substring(2, 2), 16);
+ }
+ else
+ {
+
+ buffer[6] = Convert.ToByte(strQuantity.Substring(0, 2), 16);
+ }
+ canBusSerial.Write(buffer, 0, 8);
+ logger.Info($"写标签指令:{Convert.ToHexString(buffer)}");
+ }
+ catch (Exception ex)
+ {
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.OPENERROR,
+ WindowName = WindowName,
+ Message = $"写标签数量异常{ex.Message}"
+ });
+ logger.Info($"写标签数量异常:ex:{ex.Message}");
+ }
+ }
+
#endregion
#region 回收箱操作
@@ -1249,7 +1508,121 @@ namespace DM_Weight.Port
return res;
}
+ // 以板子为单位获取抽屉内所有库位的药品数量
+ public async Task CheckQuantityByAddrForMulti()
+ {
+
+ int[] res = new int[9];
+ for (int i = 0; i < ColNoLst.Count; i++)
+ {
+ await Task.Delay(300);
+ canBusSerial.DiscardInBuffer();
+ int colNo = ColNoLst[i];
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)colNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+
+ byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x27, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
+
+ logger.Info($"称重发送库位数量查询{ColNoLst[i]}【{Convert.ToHexString(buffer)}】");
+ canBusSerial.Write(buffer, 0, 8);
+ byte[] result = await GetBufferByPort(canBusSerial, 8);
+ logger.Info($"称重发送库位数量查询返回结果【{Convert.ToHexString(result)}】");
+ byte[] hl = result.Skip(4).Take(2).ToArray();
+ var r = Convert.ToHexString(result).Substring(8, 1);
+ int quantity = 0;
+ if (r == "8")
+ {
+ hl[0] -= 0x80;
+ quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+ logger.Info($"获取值为负数{quantity}");
+ quantity=0 - quantity;
+ }
+ else
+ {
+ quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+ logger.Info($"获取值为正数{quantity}");
+ }
+
+ res[ColNoLst[i] - 1] = quantity;
+ }
+
+ return res;
+
+ }
+ //获取单个称重药合的药品数量 --查数
+ public async Task CheckQuantityForSingle(int colNo)
+ {
+ //await Task.Delay(300);
+ //canBusSerial.DiscardInBuffer();
+ //var index = colNo % 3 == 0 ? 3 : colNo % 3;
+ //var lock1 = colNo <= 3 ? 3 : colNo >= 7 ? 1 : 2;
+ //var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
+
+
+ canBusSerial.DiscardInBuffer();
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)colNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+
+ byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x27, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
+
+ logger.Info($"称重发送库位数量查询{colNo}【{Convert.ToHexString(buffer)}】");
+ canBusSerial.Write(buffer, 0, 8);
+ byte[] result = await GetBufferByPort(canBusSerial, 8);
+ byte[] hl = result.Skip(4).Take(2).ToArray();
+ var r = Convert.ToHexString(result).Substring(8, 1);
+ logger.Info($"称重发送库位数量查询返回结果【{Convert.ToHexString(result)}】");
+
+ if (r == "8")
+ {
+ hl[0] -= 0x80;
+ int quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+ logger.Info($"获取值为负数{quantity}");
+ return 0-quantity;
+ }
+ else
+ {
+ int quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+ logger.Info($"获取值为正数{quantity}");
+ return quantity;
+ }
+
+ }
+ //获取单个称重药合的药品数量---标定
+ public async Task CheckQuantityForBiaoDing(int colNo)
+ {
+ //await Task.Delay(300);
+ //canBusSerial.DiscardInBuffer();
+ //var index = colNo % 3 == 0 ? 3 : colNo % 3;
+ //var lock1 = colNo <= 3 ? 3 : colNo >= 7 ? 1 : 2;
+ //var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
+
+
+ canBusSerial.DiscardInBuffer();
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)colNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+
+ byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x27, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
+
+ logger.Info($"称重发送库位数量查询{colNo}【{Convert.ToHexString(buffer)}】");
+ canBusSerial.Write(buffer, 0, 8);
+ byte[] result = await GetBufferByPort(canBusSerial, 8);
+ logger.Info($"称重发送库位数量查询返回结果【{Convert.ToHexString(result)}】");
+ byte[] hl = result.Skip(4).Take(2).ToArray();
+ int quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+
+ return quantity;
+
+ }
// 以板子为单位获取抽屉内所有库位的药品数量
public async Task CheckQuantityByAddr2()
{
@@ -1260,19 +1633,37 @@ namespace DM_Weight.Port
{
await Task.Delay(300);
canBusSerial.DiscardInBuffer();
- //var index = (int)Math.Ceiling(Convert.ToDecimal(ColNos[i]) / 3); // > 3 ? 2 : 1;
- //var lock1 = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
- var index = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
- var lock1 = ColNos[i] <= 3 ? 3 : ColNos[i] >= 7 ? 1 : 2;
- var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
- byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x27, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
+ int colNo = ColNos[i];
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)colNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
- logger.Info($"称重发送库位数量查询1【{Convert.ToHexString(buffer)}】");
+ byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x27, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
+
+ logger.Info($"称重发送库位数量查询{ColNos[i]}【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
byte[] result = await GetBufferByPort(canBusSerial, 8);
- logger.Info($"称重发送库位数量查询1返回结果【{Convert.ToHexString(result)}】");
+ logger.Info($"称重发送库位数量查询返回结果【{Convert.ToHexString(result)}】");
byte[] hl = result.Skip(4).Take(2).ToArray();
- int quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+ //int quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+ var r = Convert.ToHexString(result).Substring(8, 1);
+ int quantity = 0;
+ if (r == "8")
+ {
+ hl[0] -= 0x80;
+ quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+ logger.Info($"获取值为负数{quantity}");
+ quantity = 0 - quantity;
+ }
+ else
+ {
+ quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
+ logger.Info($"获取值为正数{quantity}");
+ }
+
+
res[ColNos[i] - 1] = quantity;
}
@@ -1285,13 +1676,13 @@ namespace DM_Weight.Port
{
for (int i = 0; i < ColNos.Length; i++)
{
- //var index = ColNos[i] > 3 ? 2 : 1;
- //var lock1 = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
- //var index = (int)Math.Ceiling(Convert.ToDecimal(ColNos[i]) / 3);
- var index = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
- var lock1 = ColNos[i] <= 3 ? 4 : ColNos[i] >= 7 ? 1 : 2;
- var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
- byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x03, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
+ int colNo = ColNos[i];
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)colNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x03, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送药盒使能【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(TimeSpan.FromMilliseconds(500));
@@ -1303,13 +1694,13 @@ namespace DM_Weight.Port
canBusSerial.DiscardInBuffer();
for (int i = 0; i < ColNos.Length; i++)
{
- //var index = ColNos[i] > 3 ? 2 : 1;
- //var lock1 = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
- //var index = (int)Math.Ceiling(Convert.ToDecimal(ColNos[i]) / 3);
- var index = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
- var lock1 = ColNos[i] <= 3 ? 4 : ColNos[i] >= 7 ? 1 : 2;
- var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
- byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x04, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
+ int colNo = ColNos[i];
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = colNo % 3 > 0 ? (colNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)colNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x04, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送药盒失能【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(TimeSpan.FromMilliseconds(50));
@@ -1321,13 +1712,12 @@ namespace DM_Weight.Port
try
{
canBusSerial.DiscardInBuffer();
- //var index = ColNo > 3 ? 2 : 1;
- //var lock1 = ColNo % 3 == 0 ? 3 : ColNo % 3;
- //var index = (int)Math.Ceiling(Convert.ToDecimal(ColNo) / 3);
- var index = ColNo % 3 == 0 ? 3 : ColNo % 3;
- var lock1 = ColNo <= 3 ? 3 : ColNo >= 7 ? 1 : 2;
- var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
- byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x25, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = ColNo % 3 > 0 ? (ColNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)ColNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x25, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送清空计数【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
@@ -1350,13 +1740,12 @@ namespace DM_Weight.Port
try
{
canBusSerial.DiscardInBuffer();
- //var index = ColNo > 3 ? 2 : 1;
- //var lock1 = ColNo % 3 == 0 ? 3 : ColNo % 3;
- //var index = (int)Math.Ceiling(Convert.ToDecimal(ColNo) / 3);
- var index = ColNo % 3 == 0 ? 3 : ColNo % 3;
- var lock1 = ColNo <= 3 ? 3 : ColNo >= 7 ? 1 : 2;
- var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
- byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x26, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
+ int[] iNum = new int[] { 3, 2, 1 };
+ var colNo2 = ColNo % 3 > 0 ? (ColNo % 3) - 1 : 2;
+ var bColNo = iNum[colNo2];
+ decimal decolNO = (decimal)ColNo;
+ var channel = Convert.ToInt32((DrawerNo * 10 + Math.Ceiling(decolNO / 3)).ToString(), 16);
+ byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x26, (byte)bColNo, 0x00, 0x00, 0x00, 0xee };
buffer[4] = (byte)(Quantity & 0xff);
//buffer[4] = (byte)(Quantity >> 8);
@@ -1607,6 +1996,44 @@ namespace DM_Weight.Port
}
return temperature;
}
+ //读制冷片温度
+ public async Task GetFridgeTemperature2()
+ {
+ float temperature = 0.0f;
+ try
+ {
+ fridgeSerial.DiscardInBuffer();
+ byte bAddress;
+ byte[] buffer = new byte[] { 0x01, 0x03, 0x10, 0x0C, 0x00, 0x01, 0x40, 0xC9 };
+ //byte[] buffer = new byte[] { 0x01, 0x03, 0x10, 0x02, 0x00, 0x01 };
+ ////获取数组CRC校验码
+ //byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
+ ////Array.Reverse(byteDate);
+ //int dataLength = buffer.Length;
+ //Array.Resize(ref buffer, dataLength + byteDate.Length);
+ //for (int i = 0; i < byteDate.Length; i++)
+ //{
+ // buffer[dataLength + i] = byteDate[i];
+ //}
+ logger.Info($"获制冷片温度【{Convert.ToHexString(buffer)}】");
+ fridgeSerial.Write(buffer, 0, 8);
+ byte[] retByte = await GetBufferByPort(fridgeSerial, 7);
+ logger.Info($"获取制冷片温度返回【{Convert.ToHexString(retByte)}】");
+ if (retByte != null && retByte.Length >= 7)
+ {
+ var hight = retByte[3];
+ var low = retByte[4];
+ int iHight = Convert.ToInt32(hight << 8);
+ int iLow = Convert.ToInt32(retByte[4]);
+ temperature = Convert.ToSingle(iHight + iLow) / 10;
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.Info($"获取制冷片温度发生异常:ex:{ex.Message}");
+ }
+ return temperature;
+ }
///
/// 设置冰箱温度
///
diff --git a/DM_Weight/ViewModels/AddDrugControlViewModel.cs b/DM_Weight/ViewModels/AddDrugControlViewModel.cs
index 943efca..b442304 100644
--- a/DM_Weight/ViewModels/AddDrugControlViewModel.cs
+++ b/DM_Weight/ViewModels/AddDrugControlViewModel.cs
@@ -18,6 +18,7 @@ using System.Drawing.Printing;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows.Documents;
@@ -356,7 +357,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
+ _portUtil.WriteQuantityMethod( it.Quantity + it.AddQuantity,it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
});
}
RequestData();
diff --git a/DM_Weight/ViewModels/BiaoDingDialogViewModel.cs b/DM_Weight/ViewModels/BiaoDingDialogViewModel.cs
new file mode 100644
index 0000000..90e1924
--- /dev/null
+++ b/DM_Weight/ViewModels/BiaoDingDialogViewModel.cs
@@ -0,0 +1,282 @@
+using DM_Weight.Common;
+using DM_Weight.Models;
+using DM_Weight.msg;
+using DM_Weight.Port;
+using DM_Weight.util;
+using log4net;
+using log4net.Repository.Hierarchy;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.NetworkInformation;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace DM_Weight.ViewModels
+{
+ public class BiaoDingDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
+ {
+ private readonly ILog logger = LogManager.GetLogger(typeof(BiaoDingWindowViewModel));
+ public string Title => "标定";
+
+ public bool KeepAlive => false;
+ private string titleStr;
+ public string TitleStr
+ {
+ get => titleStr;
+ set { SetProperty(ref titleStr, value); }
+ }
+ private ChannelStock channelStock;
+ private string WindowName = "BiaoDingDialog";
+ private string strMessage;
+ public string StrMessage
+ {
+ get => strMessage;
+ set => SetProperty(ref strMessage, value);
+ }
+ private int _status = 1;
+ public int Status { get => _status; set => SetProperty(ref _status, value); }
+
+ //标定数量
+ private int _bdQuantity = 0;
+ public int BDQuantity
+ {
+ get => _bdQuantity;
+ set => SetProperty(ref _bdQuantity, value);
+ }
+
+ public event Action RequestClose;
+
+ public bool CanCloseDialog()
+ {
+ return true;
+ }
+
+ public void OnDialogClosed()
+ {
+ // 取消消息订阅
+ //_eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
+ }
+
+ public void OnDialogOpened(IDialogParameters parameters)
+ {
+ //_eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
+ channelStock = parameters.GetValue("channelStock");
+ if (channelStock != null)
+ {
+ TitleStr = $"正在标定{channelStock.ColNo}号库位";
+ if (channelStock.Quantity > 0)
+ {
+ StrMessage = "库位库存不为零,请取出药品后点击【清空】按钮,清空完成后输入标定数量并放入对应数量药品并根据下一步提示操作";
+ }
+ else
+ {
+ StrMessage = "输入标定数量并放入对应数量药品后点击【标定】按钮";
+ //无库存发送计数清零指令
+ _portUtil.ClearCount(channelStock.DrawerNo, channelStock.ColNo);
+ Status = 3;
+ }
+ }
+
+ }
+ private PortUtil _portUtil;
+ IEventAggregator _eventAggregator;
+ public BiaoDingDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
+ {
+ _portUtil = portUtil;
+ _eventAggregator = eventAggregator;
+ }
+ //void DoMyPrismEvent(DeviceMsg msg)
+ //{
+
+ // if (msg.WindowName.Equals(WindowName))
+ // {
+ // IGrouping grouping = enumerator.Current;
+ // int DrawerNo = grouping.Key;
+ // List channelStocks = grouping.ToList();
+
+ // switch (msg.EventType)
+ // {
+ // // 抽屉打开
+ // case EventType.DRAWEROPEN:
+
+
+ // if (Status == 1)
+ // {
+ // if (channelStocks[0].process == 1)
+ // {
+ // channelStocks.ForEach(it => it.process = 2);
+ // }
+ // }
+ // //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
+ // CheckIsFridgeOpen();
+ // break;
+ // // 抽屉关闭
+ // case EventType.DRAWERCLOSE:
+ // if (Status == 1)
+ // {
+ // if (channelStocks[0].process == 2)
+ // {
+ // channelStocks.ForEach(it => it.process = 3);
+ // }
+ // IGrouping groupingBefore = enumerator.Current;
+ // int DrawerNoBefore = groupingBefore.Key;
+ // if (enumerator.MoveNext())
+ // {
+ // IGrouping groupingAfter = enumerator.Current;
+ // int DrawerNoAfter = groupingAfter.Key;
+ // if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
+ // {
+ // Thread.Sleep(50);
+ // }
+ // OpenOneByOne();
+ // }
+ // // 已经全部取出
+ // else
+ // {
+ // Status = 3;
+ // }
+ // }
+ // //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
+ // CheckIsFridgeClose();
+ // break;
+ // // 数量变化
+ // case EventType.UPDATEQUANTITY:
+ // if (Status == 1)
+ // {
+ // logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
+ // }
+ // break;
+ // // 打开失败
+ // case EventType.OPENERROR:
+ // AlertMsg alertMsg = new AlertMsg
+ // {
+ // Message = msg.Message,
+ // Type = MsgType.ERROR
+ // };
+ // _eventAggregator.GetEvent().Publish(alertMsg);
+ // Status = 0;
+ // break;
+ // }
+ // }
+
+ //}
+ //标定
+ public DelegateCommand BiaoDingCommand
+ {
+ get => new DelegateCommand(async () =>
+ {
+ if (BDQuantity <= 0)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "请输入标定数量",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ return;
+ }
+ try
+ {
+ if (Status == 3)
+ {
+ //提示输入标定数量,发26指令
+ _portUtil.SetNumCount(channelStock.DrawerNo, channelStock.ColNo, BDQuantity);
+ Status = 4;
+ await Task.Delay(200);
+ //发27指令查询数量是否写标定时写入的数量一致,一致则标定成功,不一致则标定失败
+ int stock = await _portUtil.CheckQuantityForBiaoDing(channelStock.ColNo);
+ if (!(stock == BDQuantity))
+ {
+ int i = 1;
+ while (i<=50&&i>0)
+ {
+ await Task.Delay(200);
+ stock = await _portUtil.CheckQuantityForBiaoDing(channelStock.ColNo);
+ if (stock == BDQuantity)
+ {
+
+ logger.Info($"标定完成{stock},{BDQuantity},{i}"); //标定成功
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "标定成功",
+ Type = MsgType.SUCCESS,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ i = 0;
+ }
+ else
+ {
+ i++;
+ logger.Info($"标定数量不一致{stock},{BDQuantity}");
+
+ }
+
+ }
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ if (i == 51)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "标定失败",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+
+ }
+ }
+ else
+ {
+
+ //标定成功
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "标定成功",
+ Type = MsgType.SUCCESS,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ logger.Info($"标定完成{stock},{BDQuantity}");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ logger.Error($"标定异常{e.Message}");
+ }
+ });
+ }
+ //清零
+ public DelegateCommand ClearCommand
+ {
+ get => new DelegateCommand(async () =>
+ {
+ //发计数请零指令
+ _portUtil.ClearCount(channelStock.DrawerNo, channelStock.ColNo);
+ Status = 3;
+ });
+ }
+ //取消
+ public DelegateCommand CancelCommand
+ {
+ get => new DelegateCommand(() =>
+ {
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ });
+ }
+
+ //关闭
+ public DelegateCommand BtnCloseCommand
+ {
+ get => new DelegateCommand(() =>
+ {
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ });
+ }
+ }
+}
diff --git a/DM_Weight/ViewModels/BiaoDingWindowViewModel.cs b/DM_Weight/ViewModels/BiaoDingWindowViewModel.cs
index 26b9397..c2c5747 100644
--- a/DM_Weight/ViewModels/BiaoDingWindowViewModel.cs
+++ b/DM_Weight/ViewModels/BiaoDingWindowViewModel.cs
@@ -39,7 +39,7 @@ namespace DM_Weight.ViewModels
}
}
//状态,抽屉下的库位有库存为0的则可标定,否则不可标定
- private int _status;
+ private int _status=0;
public int Status { get => _status; set => SetProperty(ref _status, value); }
//凭证号
private string _pzh;
@@ -65,6 +65,13 @@ namespace DM_Weight.ViewModels
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ private bool _openBoxVisibility = false;
+ public bool OpenBoxVisibility
+ {
+ get => _openBoxVisibility;
+ set => SetProperty(ref _openBoxVisibility, value);
+ }
+
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
@@ -74,68 +81,12 @@ namespace DM_Weight.ViewModels
_portUtil = portUtil;
_eventAggregator = eventAggregator;
}
- //public DelegateCommand SelectionChangedCommand => new DelegateCommand(selectionAction);
-
- //private async void selectionAction()
- //{
- // if (CStock != null)
- // {
- // // 此处延时1毫秒,等待页面渲染
- // await Task.Delay(TimeSpan.FromMilliseconds(1));
- // DialogParameters dialogParameters = new DialogParameters();
- // dialogParameters.Add("addManuno", CStock);
- // DialogServiceExtensions.ShowDialogHost(_dialogService, "AddManunoDialog", dialogParameters, DoDialogResult, "RootDialog");
-
- // }
-
- //}
private void DoDialogResult(IDialogResult dialogResult)
{
CStock = null;
+ Status = 0;
RequestData();
}
- //void DoMyPrismEvent(DeviceMsg msg)
- //{
- // if (msg.WindowName == "DrawerAddDrugWindow")
- // {
- // switch (msg.EventType)
- // {
- // // 抽屉打开
- // //case EventType.DRAWEROPEN:
- // // if (Status == 1)
- // // {
- // // Status = 2;
- // // }
-
- // // break;
- // //// 抽屉关闭
- // //case EventType.DRAWERCLOSE:
- // // if (Status == 2)
- // // {
- // // Status = 3;
- // // }
- // // break;
- // // 数量变化
- // //case EventType.UPDATEQUANTITY:
- // // if (Status == 4)
- // // {
- // // ChannelStocks.ToList().ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
- // // }
- // // break;
- // // 打开失败
- // //case EventType.OPENERROR:
- // // AlertMsg alertMsg = new AlertMsg
- // // {
- // // Message = msg.Message,
- // // Type = MsgType.ERROR,
- // // };
- // // _eventAggregator.GetEvent().Publish(alertMsg);
- // // Status = 0;
- // // break;
- // }
- // }
-
- //}
private int _drawerNo = Convert.ToInt32(ConfigurationManager.AppSettings["WeightDrawerNumber"].Split(',')[0]);
@@ -157,317 +108,153 @@ namespace DM_Weight.ViewModels
private bool _is17Drawer = false;
public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
- public DelegateCommand UpdateDrawerNo
- {
- get => new DelegateCommand((DrawerNo) =>
- {
- //BtnStatus = 0;
- this.DrawerNo = Convert.ToInt32(DrawerNo);
- RequestData();
- });
- }
+
+ //打开抽屉
public DelegateCommand OpenDrawer
{
- get => new DelegateCommand(OpenDrawerMethod
- // async () =>
- //{
- // try
- // {
- // List singleChannels = ChannelStocks.ToList().FindAll(it => it.BoardType == (Int32)BoardTypeEnum.weighBox && it.PosNo == 0 && it.Quantity == 0 && it.AddQuantity > 0);
- // if (singleChannels.Count > 0)
- // {
- // ChannelStocks = new ObservableCollection (singleChannels);
- // Status = 2;
- // _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- // //发送称重25指令
- // await SendClearCount(singleChannels);
- // _portUtil.Operate = true;
- // _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : (Int32)BoardTypeEnum.separation;
- // _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
- // //_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
- // _portUtil.DrawerNo = DrawerNo;
- // //_portUtil.Start();
- // byte[] buffer = await _portUtil.OpenDrawer();
- // int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
-
- // logger.Info($"OpenDrawer{string.Join(",", r)}");
- // if (DrawerState(r))
- // {
- // _portUtil.BoxLockLightOn2();
- // }
- // Status = 3;
- // }
-
- // else
- // {
- // _isFinishClick = false;
- // AlertMsg alertMsg = new AlertMsg
- // {
- // Message = "请填写药品数量",
- // Type = MsgType.ERROR
- // };
- // _eventAggregator.GetEvent().Publish(alertMsg);
- // }
- // }
-
- // catch (Exception ex)
- // {
- // _portUtil.ResetData();
- // logger.Info($"OpenDrawer异常:{ex.Message}");
- // _isFinishClick = false;
- // AlertMsg alertMsg = new AlertMsg
- // {
- // Message = $"异常:{ex.Message}",
- // Type = MsgType.ERROR
- // };
- // _eventAggregator.GetEvent().Publish(alertMsg);
- // //Status = 1;
- // }
- // //finally { BiaoDingLoading = false;}
-
- //}
- );
- }
- private void OpenDrawerMethod()
- {
- _portUtil.Operate = true;
- OpenDrawerMethodAction();
-
- }
- private async void OpenDrawerMethodAction()
- {
- try
+ get => new DelegateCommand(async () =>
{
- if (_portUtil.Operate)
+ try
{
- List singleChannels = ChannelStocks.ToList().FindAll(it => it.BoardType == (Int32)BoardTypeEnum.weighBox && it.PosNo == 0 && it.Quantity == 0 && it.AddQuantity > 0);
- if (singleChannels.Count > 0)
+ if (Status == 0)
{
- ChannelStocks = new ObservableCollection(singleChannels);
- Status = 2;
+ _portUtil.Operate = true;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- //发送称重25指令
- await SendClearCount(singleChannels);
- _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : (Int32)BoardTypeEnum.separation;
- _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
- //_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
- _portUtil.DrawerNo = DrawerNo;
- //_portUtil.Start();
byte[] buffer = await _portUtil.OpenDrawer();
+
int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
logger.Info($"OpenDrawer{string.Join(",", r)}");
if (DrawerState(r))
{
- _portUtil.BoxLockLightOn2();
+ new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) =>
+ {
+ Status = 1;
+ // 查询抽屉状态
+ byte[] buffer = await _portUtil.CheckDrawerStatus();
+ int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
+ if (DrawerState(r))
+ {
+ Status = 2;
+ next();
+ }
+ else
+ {
+ Status = 0;
+ //关闭抽屉
+ logger.Info($"抽屉【{DrawerNo}】已关闭");
+ // 重新初始化数据
+ _portUtil.ResetData();
+ stop();
+ }
+ });
}
- Status = 3;
- }
-
- else
- {
- _portUtil.Operate = false;
- _isFinishClick = false;
- AlertMsg alertMsg = new AlertMsg
+ else
{
- Message = "请填写药品数量",
- Type = MsgType.ERROR
- };
- _eventAggregator.GetEvent().Publish(alertMsg);
+ logger.Info($"抽屉【{DrawerNo}】打开失败");
+ // 重新初始化数据
+ _portUtil.ResetData();
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "抽屉打开失败",
+ Type = MsgType.ERROR,
+ };
+ // 返回消息 抽屉打开失败
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
}
}
- }
-
- catch (Exception ex)
- {
- _portUtil.ResetData();
- logger.Info($"OpenDrawer异常:{ex.Message}");
- _isFinishClick = false;
- AlertMsg alertMsg = new AlertMsg
+ catch (Exception ex)
{
- Message = $"异常:{ex.Message}",
- Type = MsgType.ERROR
- };
- _eventAggregator.GetEvent().Publish(alertMsg);
- //Status = 1;
- }
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = $"操作异常{ex.Message}",
+ Type = MsgType.ERROR,
+ };
+ // 返回消息 抽屉打开失败
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ });
}
+
+
+ //开药盒
+ public DelegateCommand
private string _wd = "恒温冷藏抽屉当前温度2.8(非真实数据)";
public string WD { get => _wd; set => SetProperty(ref _wd, value); }
- System.Timers.Timer WDTimer;
+ private SolidColorBrush _alertColor = Brushes.White;
+ public SolidColorBrush AlertColor
+ {
+ get => _alertColor;
+ set => SetProperty(ref _alertColor, value);
+ }
private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
public bool MultiLogin
{
get => loginMode == 2;
}
+ //温度区间
+ private string TemperatureRange = CommonClass.ReadAppSetting("temperatureRange").ToString();
+ //温度不在区间计时器(超过配置文件中的时间后要报警)
+ public DateTime? FridgeTime { get; set; }
+ //冰箱是否异常状态:0正常,1异常
+ //public string FridgeWorkingState = ConfigurationManager.AppSettings["FridgeworkingState"].ToString();
+ //冰箱开关状态:0开,1关
+ public string FridgeState = ConfigurationManager.AppSettings["FridgeState"].ToString();
+ //冰箱渡不在区间超时时间
+ private string _outRangeTime = ConfigurationManager.AppSettings["OutRangeTime"].ToString();
+ public string OutRangeTime { get => _outRangeTime; set => SetProperty(ref _outRangeTime, value); }
private PremissionDm? _selectedMenu;
@@ -186,7 +203,8 @@ namespace DM_Weight.ViewModels
IRegionManager _regionManager;
IUnityContainer _container;
-
+ //是否退出
+ bool IsLeave = false;
private bool _is16Drawer;
public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
public bool KeepAlive => false;
@@ -266,32 +284,6 @@ namespace DM_Weight.ViewModels
Is16Drawer = count == 16;
}
///
- /// 获取温度信息
- ///
- private async void GetWD(object sender, ElapsedEventArgs e)
- {
- if (!_portUtil.FridgeOperate)
- {
- string retStr = string.Empty;
- byte[] data = null;
- float retT = await _portUtil.GetFridgeTemperature();
- Thread.Sleep(80);
- WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃";
- }
- }
-
- private async void GetWD()
- {
- if (!_portUtil.FridgeOperate)
- {
- string retStr = string.Empty;
- byte[] data = null;
- float retT = await _portUtil.GetFridgeTemperature();
- Thread.Sleep(80);
- WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT),2)}℃";
- }
- }
- ///
/// 将收到的返回转换成具体温度数值
///
///
@@ -371,43 +363,229 @@ namespace DM_Weight.ViewModels
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
if (autoExit > 0)
{
- System.Timers.Timer timer = new System.Timers.Timer();
- timer.Interval = 1000;
- timer.Elapsed += (sender, e) =>
+ //int interval = autoExit * 1000;
+ new PromiseUtil().taskAsyncLoop(1000, 0, async (options, next, stop) =>
{
- // 串口无人操作
- if (!_portUtil.Operate)
+ try
{
- // 30秒内无人操作鼠标键盘
- if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
+ if (!_portUtil.Operate)
{
- logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
- Operator = null;
- Reviewer = null;
- Application.Current.Dispatcher.Invoke(() =>
+ // 无人操作鼠标键盘
+ if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
{
- _regionManager.RequestNavigate("MainRegion", "LoginWindow");
- timer.Stop();
- });
+ logger.Info($"设备{autoExit}内无人操作,用户【{Operator?.Nickname}】自动退出登录,_portUtil.Operate:{_portUtil.Operate},totalSecond:{(DateTime.Now - _portUtil.dateTime).TotalSeconds},lastInputTime:{CheckComputerFreeState.GetLastInputTime()},autoExit:{autoExit}");
+
+ Operator = null;
+ Reviewer = null;
+ //Application.Current.Dispatcher.Invoke(() =>
+ //{
+ stop();
+ System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+ {
+ _regionManager.RequestNavigate("MainRegion", "LoginWindow");
+ }));
+ //});
+ //timer.Dispose();
+ }
+ else
+ {
+ if (Operator == null)
+ {
+ stop();
+ }
+ else
+ {
+ next();
+ }
+ }
+ }
+ else
+ {
+ _portUtil.dateTime = DateTime.Now;
+ next();
}
}
- };
- timer.Start();
+ catch (Exception ex)
+ {
+ logger.Info($"自动退出异常:{ex.Message}");
+ }
+ });
}
- #region 温度查询定时
- int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
- if (interval > 0)
- {
- WDTimer = new System.Timers.Timer();
+ GetFridgeTemperature();
- WDTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetWD);
- WDTimer.Interval = interval;
- WDTimer.Start();
- //WDTimer.AutoReset = true;
- //WDTimer.Enabled = true;
- }
- #endregion
- GetWD();
+ _eventAggregator.GetEvent().Subscribe(GetFridgeTemperature);
+ }
+
+
+ //获取冰箱温度定时
+ private void GetFridgeTemperature()
+ {
+ //根据配置文件中的 冰箱温度定时时间循环
+ logger.Info("获取冰箱温度定时");
+ int TemperatureTimer = Convert.ToInt32(CommonClass.ReadAppSetting("TemperatureTimer")) * 1000;
+ logger.Info($"获取冰箱温度定时-TemperatureTimer");
+ string[] tempRange = TemperatureRange.Split('-');
+
+ new PromiseUtil().taskAsyncLoop(TemperatureTimer, 0, async (options, next, stop) =>
+ {
+ try
+ {
+ FridgeState = CommonClass.ReadAppSetting("FridgeState");
+ if (!_portUtil.FridgeOperate && FridgeState.Equals("0"))
+ {
+ string retStr = string.Empty;
+ byte[] data = null;
+ float retT = await _portUtil.GetFridgeTemperature();
+ Thread.Sleep(80);
+ WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃;";
+ AlertColor = Brushes.White;
+ logger.Info(WD);
+ if (tempRange != null && tempRange.Count() >= 2)
+ {
+ if (retT < Convert.ToSingle(tempRange[0]) || retT > Convert.ToSingle(tempRange[1]))
+ {
+ //查询制冷片温度
+ float retT2 = await _portUtil.GetFridgeTemperature2();
+ if (retT2 > 65)
+ {
+ if (!FridgeState.Equals("1"))
+ {
+ //停掉冰箱
+ await _portUtil.FridgeOff();
+ CommonClass.SaveAppSetting("FridgeState", "1");
+ //AlertMsg alertMsg = new AlertMsg
+ //{
+ // Message = $"冰箱制冷片温度超过65度,已关闭冰箱制冷功能!!!",
+ // Type = MsgType.ERROR
+ //};
+ //_eventAggregator.GetEvent().Publish(alertMsg);
+
+ System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+ {
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("warnMessage", "冰箱制冷片温度超过65度,已关闭冰箱制冷功能!!!");
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "WarnDialog", dialogParameters, DoDialogResult, "RootDialog");
+
+ }));
+ }
+ logger.Info($"制冷片温度超过65度");
+ Thread.Sleep(100);
+ //给出提示
+ WD += "冰箱温度异常,已关闭冰箱制冷功能";
+ AlertColor = Brushes.Red;
+ FridgeTime = null;
+ stop();
+ }
+ else
+ {
+ if (FridgeTime == null)
+ {
+ FridgeTime = DateTime.Now;
+ //温度不在范围,但没有超过时间
+ if (IsLeave)
+ {
+ FridgeTime = null;
+ stop();
+ }
+ else
+ {
+ next();
+ }
+ }
+ else
+ {
+ if ((DateTime.Now - FridgeTime.Value).TotalMinutes > Convert.ToInt32(OutRangeTime))
+ {
+ logger.Info($"冰箱温度不在范围内,超过{OutRangeTime}分钟");
+ //停掉冰箱
+ await _portUtil.FridgeOff();
+ Thread.Sleep(100);
+ CommonClass.SaveAppSetting("FridgeState", "0");
+ //给出提示
+ WD += "冰箱温度异常,已关闭冰箱制冷功能;";
+ AlertColor = Brushes.Red;
+ FridgeState = "1";
+ CommonClass.SaveAppSetting("FridgeState", "1");
+ //AlertMsg alertMsg = new AlertMsg
+ //{
+ // Message = $"冰箱温度异常,已关闭冰箱制冷功能!!!",
+ // Type = MsgType.ERROR
+ //};
+ //_eventAggregator.GetEvent().Publish(alertMsg);
+ System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+ {
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("warnMessage", "冰箱温度异常,已关闭冰箱制冷功能!!!");
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "WarnDialog", dialogParameters, DoDialogResult, "RootDialog");
+
+ }));
+ FridgeTime = null;
+ stop();
+ }
+ else
+ {
+ //温度不在范围,但没有超过时间
+ if (IsLeave)
+ {
+ FridgeTime = null;
+ stop();
+ }
+ else
+ {
+ next();
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if (IsLeave)
+ {
+ FridgeTime = null;
+ stop();
+ }
+ else
+ {
+ next();
+ }
+ }
+ }
+ else
+ {
+ logger.Info($"获取冰箱温度范围有误{TemperatureRange}");
+
+ //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
+ //{
+ // float retTemp = await _portUtil.GetFridgeTemperature(2);
+ // Thread.Sleep(80);
+ // WD += $"{retTemp}℃";
+ //}
+ if (IsLeave)
+ {
+ FridgeTime = null;
+ stop();
+ }
+ else
+ {
+ next();
+ }
+ }
+ }
+ else
+ {
+ WD = $"恒温冷藏抽屉串口关闭或冰箱制冷异常制冷关闭!!!";
+ AlertColor = Brushes.Red;
+ FridgeTime = null;
+ stop();
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.Info($"获取冰箱异常:{ex.Message}");
+ next();
+ }
+ });
}
//每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
@@ -419,7 +597,9 @@ namespace DM_Weight.ViewModels
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
+ IsLeave = true;
navigationContext.NavigationService.Region.RegionManager.Regions.Remove(PrismManager.SettingViewRegionName);
+ _eventAggregator.GetEvent().Unsubscribe(GetFridgeTemperature);
}
}
}
diff --git a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
index 1ceb700..a9901e4 100644
--- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
@@ -247,17 +247,19 @@ namespace DM_Weight.ViewModels
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
- if (it.BoardType == (Int32)BoardTypeEnum.weigh && it.PosNo == 0)
- {
- _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
- }
+ //if (it.BoardType == (Int32)BoardTypeEnum.weigh && it.PosNo == 0)
+ //{
+ // _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
+ //}
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity + it.AddQuantity,
PosNo = 1,
Id = it.Id,
- }).UpdateColumns(it => new { it.Quantity, it.PosNo }).ExecuteCommand();
+ ManuNo = it.ManuNo,
+ EffDate = it.EffDate,
+ }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// 获取更新完库存后的药品库存
List nowChannels = SqlSugarHelper.Db.Queryable()
.Where(cs => cs.MachineId.Equals(it.MachineId))
@@ -272,8 +274,8 @@ namespace DM_Weight.ViewModels
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
- //ManuNo = it.ManuNo,
- //EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ ManuNo = it.ManuNo,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
@@ -283,12 +285,12 @@ namespace DM_Weight.ViewModels
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
+ // Thread.Sleep(80);
+ //}
}
return true;
});
@@ -301,7 +303,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
+ _portUtil.WriteQuantityMethod(it.Quantity + it.AddQuantity,it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
});
}
diff --git a/DM_Weight/ViewModels/InvoiceInWindowViewModel.cs b/DM_Weight/ViewModels/InvoiceInWindowViewModel.cs
index a409e4f..3c930f4 100644
--- a/DM_Weight/ViewModels/InvoiceInWindowViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceInWindowViewModel.cs
@@ -206,8 +206,8 @@ namespace DM_Weight.ViewModels
{
List q = SqlSugarHelper.Db.Queryable()
.Includes(cs => cs.DrugInfo)
- //.WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
- //.WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
+ .WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
+ .WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
.Where(cs => cs.DrugId == invoice.DrugId)
.Where(cs => cs.DrawerType == (Int32)DrawerTypeEnum.drawerTypeOne)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
diff --git a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
index 5cf5b85..41f8995 100644
--- a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
@@ -192,10 +192,10 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.DrawerType == (Int32)DrawerTypeEnum.drawerTypeOne)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
- //.WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
- //.WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
+ .WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
+ .WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
.Where(cs => cs.DrugId == invoice.DrugId)
- //.OrderBy(cs => cs.EffDate)
+ .OrderBy(cs => cs.EffDate)
.ToList();
int total = HasQChannels.Sum(it => it.Quantity);
int TakeQ = invoice.quantity;
@@ -317,10 +317,10 @@ namespace DM_Weight.ViewModels
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
- //ManuNo = it.ManuNo,
- //EffDate = it.EffDate,
+ ManuNo = it.ManuNo,
+ EffDate = it.EffDate,
Id = it.Id,
- }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
+ }).UpdateColumns(it => new { it.Quantity,it.ManuNo,it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List nowChannels = SqlSugarHelper.Db.Queryable()
.Where(cs => cs.MachineId.Equals(it.MachineId))
@@ -335,8 +335,8 @@ namespace DM_Weight.ViewModels
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
- //ManuNo = it.ManuNo,
- //EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ ManuNo = it.ManuNo,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
@@ -346,12 +346,12 @@ namespace DM_Weight.ViewModels
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
+ // Thread.Sleep(80);
+ //}
}
return true;
});
@@ -364,7 +364,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
+ _portUtil.WriteQuantityMethod(it.Quantity - it.TakeQuantity,it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
});
}
AlertMsg alertMsg = new AlertMsg
diff --git a/DM_Weight/ViewModels/MainWindowViewModel.cs b/DM_Weight/ViewModels/MainWindowViewModel.cs
index e2247d8..06c6ea0 100644
--- a/DM_Weight/ViewModels/MainWindowViewModel.cs
+++ b/DM_Weight/ViewModels/MainWindowViewModel.cs
@@ -17,6 +17,7 @@ using DM_Weight.Views;
using Unity;
using System.Threading;
using System.Timers;
+using System.Configuration;
namespace DM_Weight.ViewModels
{
@@ -83,7 +84,7 @@ namespace DM_Weight.ViewModels
}));
#region 温度查询定时
- int interval = 60000;
+ int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
if (interval > 0)
{
System.Timers.Timer doorTimer = new System.Timers.Timer();
@@ -93,8 +94,6 @@ namespace DM_Weight.ViewModels
doorTimer.Start();
}
#endregion
-
-
}
///
/// 监测后门是否打开
diff --git a/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs
index 1bd3dec..5d3d4d3 100644
--- a/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs
@@ -178,7 +178,7 @@ namespace DM_Weight.ViewModels
.InnerJoin(SqlSugarHelper.Db.Queryable().Where(cs => cs.DrawerType == (Int32)DrawerTypeEnum.drawerTypeOne).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
.Where(od => OrderInfo.Select(o => o.OrderNo).Contains(od.OrderNo)).GroupBy(od => od.DrugId)
- .Select(od => new OrderDetail { DrugId = od.DrugId,Quantity = SqlFunc.AggregateSum(od.Quantity) })
+ .Select(od => new OrderDetail { DrugId = od.DrugId, SetEffDate = od.SetEffDate, SetManuNo = od.SetManuNo, Quantity = SqlFunc.AggregateSum(od.Quantity) })
//.Where(od => od.OrderNo. OrderInfo.OrderNo)
.ToList();
@@ -195,8 +195,8 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.DrawerType == (Int32)DrawerTypeEnum.drawerTypeOne)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
- //.WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
- //.WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
+ .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
+ .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
.Where(cs => cs.DrugId == orderDetail.DrugId)
.OrderBy(cs => cs.EffDate)
.OrderBy(cs => cs.DrawerNo)
@@ -375,8 +375,8 @@ namespace DM_Weight.ViewModels
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
- //ManuNo = it.ManuNo,
- //EffDate = it.EffDate,
+ ManuNo = it.ManuNo,
+ EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
@@ -393,8 +393,8 @@ namespace DM_Weight.ViewModels
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
- //ManuNo = it.ManuNo,
- //EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ ManuNo = it.ManuNo,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
@@ -405,12 +405,12 @@ namespace DM_Weight.ViewModels
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
+ // Thread.Sleep(80);
+ //}
}
//更新处方状态
SqlSugarHelper.Db.Updateable(new OrderInfo()
@@ -432,7 +432,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
+ _portUtil.WriteQuantityMethod(it.Quantity - it.TakeQuantity,it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
});
}
AlertMsg alertMsg = new AlertMsg
diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
index 755d9cb..af3b129 100644
--- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
@@ -342,12 +342,12 @@ namespace DM_Weight.ViewModels
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
+ // Thread.Sleep(80);
+ //}
}
return true;
});
@@ -360,7 +360,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity);
+ _portUtil.WriteQuantityMethod(it.Quantity + it.TakeQuantity,it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
});
}
AlertMsg alertMsg = new AlertMsg
diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
index db91d63..108e950 100644
--- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
@@ -190,10 +190,10 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.DrawerType == (Int32)DrawerTypeEnum.drawerTypeOne)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
- //.WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
- //.WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
+ .WhereIF(!string.IsNullOrEmpty(orderDetail.SetEffDate), cs => cs.EffDate.Equals(orderDetail.SetEffDate))
+ .WhereIF(!string.IsNullOrEmpty(orderDetail.SetManuNo), cs => cs.ManuNo.Equals(orderDetail.SetManuNo))
.Where(cs => cs.DrugId == orderDetail.DrugId)
- //.OrderBy(cs => cs.EffDate)
+ .OrderBy(cs => cs.EffDate)
.OrderBy(cs => cs.DrawerNo)
.ToList();
int total = HasQChannels.Sum(it => it.Quantity);
@@ -337,8 +337,8 @@ namespace DM_Weight.ViewModels
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
- //ManuNo = it.ManuNo,
- //EffDate = it.EffDate,
+ ManuNo = it.ManuNo,
+ EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
// 获取更新完库存后的药品库存
@@ -355,8 +355,8 @@ namespace DM_Weight.ViewModels
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
- //ManuNo = it.ManuNo,
- //EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ ManuNo = it.ManuNo,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
@@ -366,12 +366,12 @@ namespace DM_Weight.ViewModels
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
+ // Thread.Sleep(80);
+ //}
}
return true;
});
@@ -383,7 +383,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
+ _portUtil.WriteQuantityMethod(it.Quantity - it.TakeQuantity,it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
});
}
AlertMsg alertMsg = new AlertMsg
diff --git a/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
index 8f08d09..a76c0d9 100644
--- a/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
@@ -233,7 +233,7 @@ namespace DM_Weight.ViewModels
.Where(oi => oi.DmStatus == 0)
.Where(oi => oi.HisDispFlag == 0)
.Where(oi => oi.CancelFlag == 0)
- .GroupBy(oi => oi.RecvDate)
+ .GroupBy(oi => oi.ChargeDate)
.Select(oi => oi)
.ToPageList(PageNum, PageSize, ref totalCount);
//.ToList();
diff --git a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
index fead071..837081d 100644
--- a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
+++ b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
@@ -273,12 +273,12 @@ namespace DM_Weight.ViewModels
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (ChannelStock.BoardType == (Int32)BoardTypeEnum.weigh || ChannelStock.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (ChannelStock.BoardType == (Int32)BoardTypeEnum.weigh || ChannelStock.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.AddQuantity);
+ // Thread.Sleep(80);
+ //}
return true;
});
if (f.Data)
@@ -286,7 +286,8 @@ namespace DM_Weight.ViewModels
// 更新屏显库存
if (ChannelStock.BoardType == (Int32)BoardTypeEnum.smart|| ChannelStock.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
{
- _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
+ _portUtil.WriteQuantityMethod(ChannelStock.Quantity + ReturnQuantity,ChannelStock.DrawerNo, ChannelStock.ColNo);
+ Thread.Sleep(200);
}
AlertMsg alertMsg = new AlertMsg
diff --git a/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs b/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
index b0d4b93..c4ed3e9 100644
--- a/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
+++ b/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
@@ -281,12 +281,12 @@ namespace DM_Weight.ViewModels
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (ChannelStock.BoardType == (Int32)BoardTypeEnum.weigh || ChannelStock.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (ChannelStock.BoardType == (Int32)BoardTypeEnum.weigh || ChannelStock.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.AddQuantity);
+ // Thread.Sleep(80);
+ //}
}
return true;
@@ -296,7 +296,8 @@ namespace DM_Weight.ViewModels
// 更新屏显库存
if (ChannelStock.BoardType == (Int32)BoardTypeEnum.smart|| ChannelStock.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
{
- _portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
+ _portUtil.WriteQuantityMethod(ChannelStock.Quantity + ReturnQuantity,ChannelStock.DrawerNo, ChannelStock.ColNo);
+ Thread.Sleep(200);
}
AlertMsg alertMsg = new AlertMsg
diff --git a/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs b/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs
index f7ef66f..6c012ce 100644
--- a/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs
+++ b/DM_Weight/ViewModels/ReturnEmptyWindowViewModel.cs
@@ -57,7 +57,7 @@ namespace DM_Weight.ViewModels
{
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("channel", Channel);
- DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyDialog", dialogParameters, DoDialogResult, "RootDialog");
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "ReturnEmptyWithOrderDialog", dialogParameters, DoDialogResult, "RootDialog");
}
});
}
diff --git a/DM_Weight/ViewModels/ReturnWithOrderWindowViewModel.cs b/DM_Weight/ViewModels/ReturnWithOrderWindowViewModel.cs
new file mode 100644
index 0000000..ab7edfc
--- /dev/null
+++ b/DM_Weight/ViewModels/ReturnWithOrderWindowViewModel.cs
@@ -0,0 +1,716 @@
+using DM_Weight.Common;
+using DM_Weight.Models;
+using DM_Weight.msg;
+using DM_Weight.Port;
+using DM_Weight.select;
+using DM_Weight.util;
+using log4net;
+using log4net.Repository.Hierarchy;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using SqlSugar;
+using SqlSugar.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Drawing.Printing;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace DM_Weight.ViewModels
+{
+ public class ReturnWithOrderWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
+ {
+ private int _pageNum = 1;
+ public int PageNum
+ {
+ get => _pageNum;
+ set
+ {
+ SetProperty(ref _pageNum, value);
+ RequestData();
+ }
+ }
+
+ private int _pageCount = 1;
+ public int PageCount
+ {
+ get => _pageCount;
+ set
+ {
+ SetProperty(ref _pageCount, value);
+ }
+ }
+
+ private int _pageSize = 8;
+ public int PageSize
+ {
+ get => _pageSize;
+ set
+ {
+ SetProperty(ref _pageSize, value);
+ }
+ }
+
+ private int _totalCount = 0;
+ public int TotalCount
+ {
+ get => _totalCount;
+ set
+ {
+ SetProperty(ref _totalCount, value);
+ }
+ }
+ public static List StaticOrderTakeSelects = new()
+ {
+ new OrderTakeSelect
+ {
+ Code = "OrderNo",
+ Name = "处方号"
+ },
+ new OrderTakeSelect
+ {
+ Code = "PatientId",
+ Name = "患者编号"
+ }
+ };
+
+ private List _orderTakeSelects = StaticOrderTakeSelects;
+
+ public List OrderTakeSelects
+ {
+ get { return _orderTakeSelects; }
+ set
+ {
+ SetProperty(ref _orderTakeSelects, value);
+ }
+ }
+ private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
+ ///
+ /// 查询条件 查询字段
+ ///
+ public OrderTakeSelect SelectedItem
+ {
+ get { return _selectedItem; }
+ set
+ {
+ SetProperty(ref _selectedItem, value);
+ RequestData();
+ }
+ }
+
+ private OrderInfo? _selectedOrder;
+
+ public OrderInfo? SelectedOrder
+ {
+ get { return _selectedOrder; }
+ set
+ {
+ SetProperty(ref _selectedOrder, value);
+
+ //OpenOrderDialog();
+ }
+ }
+ private List _orderInfos = new();
+
+ public List OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
+ private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
+ ///
+ /// 查询条件 处方日期
+ ///
+ public string OrderDate
+ {
+ get { return _orderDate; }
+ set
+ {
+ if (!String.IsNullOrEmpty(value))
+ {
+ SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
+ }
+ else
+ {
+ SetProperty(ref _orderDate, value);
+ }
+
+ RequestData();
+ }
+ }
+
+ private string? _searchValue;
+
+ ///
+ /// 查询条件 查询字段值
+ ///
+ public string? SearchValue
+ {
+ get { return _searchValue; }
+ set
+ {
+ SetProperty(ref _searchValue, value);
+ RequestData();
+ }
+ }
+ ///
+ /// 取药日期
+ ///
+ private string _optDate;
+ public string OptDate
+ {
+ get { return _optDate; }
+ set
+ {
+ if (!String.IsNullOrEmpty(value))
+ {
+ SetProperty(ref _optDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
+ }
+ else
+ {
+ SetProperty(ref _optDate, value);
+ }
+ BindDrugInfo();
+ }
+ }
+
+ private int _status = 0;
+
+ public int Status
+ {
+ get => _status; set => SetProperty(ref _status, value);
+ }
+
+ private string _detailDrugName;
+ public string DetailDrugName { get => _detailDrugName; set => SetProperty(ref _detailDrugName, value); }
+
+ private string _detailDrugSpec;
+ public string DetailDrugSpec { get => _detailDrugSpec; set => SetProperty(ref _detailDrugSpec, value); }
+
+ private string _detailDrugFactory;
+ public string DetailDrugFactory { get => _detailDrugFactory; set => SetProperty(ref _detailDrugFactory, value); }
+
+ private MachineRecord _machineRecord;
+ public MachineRecord _MachineRecord
+ {
+ get => _machineRecord;
+ set
+ {
+ SetProperty(ref _machineRecord, value);
+ }
+ }
+
+
+
+ private ChannelList? _channelLsts;
+
+ public ChannelList? ChannelLsts
+ {
+ get => _channelLsts;
+ set => SetProperty(ref _channelLsts, value);
+ }
+ private List __channelStocks = new List();
+ public List ChannelStocks
+ {
+ get => __channelStocks;
+ set => SetProperty(ref __channelStocks, value);
+ }
+
+
+ //回收箱库位
+ public ChannelStock? CStock;
+
+ private List? _machineRecords;
+
+ public List? MachineRecords
+ {
+ get => _machineRecords;
+ set => SetProperty(ref _machineRecords, value);
+ }
+ private List? _ordertails;
+
+ public List? OrderDetails
+ {
+ get => _ordertails;
+ set => SetProperty(ref _ordertails, value);
+ }
+ ///
+ /// 取药人列表
+ ///
+ private List? _userLists = new() { new UserList() { UserName = "全部", Id = 0 } };
+ public List? UserLists
+ {
+ get => _userLists;
+ set => SetProperty(ref _userLists, value);
+ }
+ ///
+ /// 选中取药人
+ ///
+ private UserList? _userSelects = new UserList();
+ public UserList? UserSelects
+ {
+ get => _userSelects;
+ set
+ {
+ SetProperty(ref _userSelects, value);
+
+ BindDrugInfo();
+ }
+ }
+
+ private string WindowName = "ReturnWithOrderWindow";
+ private readonly ILog logger = LogManager.GetLogger(typeof(ReturnWithOrderWindowViewModel));
+ private bool _isFinishClick = false;
+ private static readonly DateTime Jan1st1970 = new DateTime
+ (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+ private IEnumerable> enumerable;
+ private IEnumerator> enumerator;
+
+ public bool IsFinishClick { get => _isFinishClick; set => SetProperty(ref _isFinishClick, value); }
+ IDialogService _dialogService;
+ private PortUtil _portUtil;
+ IEventAggregator _eventAggregator;
+ public ReturnWithOrderWindowViewModel(IDialogService dialogService, PortUtil portUtil, IEventAggregator eventAggregator)
+ {
+ _dialogService = dialogService;
+ _portUtil = portUtil;
+ _eventAggregator = eventAggregator;
+ }
+ public DelegateCommand RowSelected
+ {
+ get => new DelegateCommand(() =>
+ {
+ BindDrugInfo();
+ });
+ }
+ private void DoDialogResult(IDialogResult dialogResult)
+ {
+ //dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
+ //if (dialogResult.Result == ButtonResult.OK)
+ //{
+ // MachineRecords.ForEach(mr => mr.ManuNo = "123");
+ // _MachineRecord = dialogResult.Parameters.GetValue("MachineRecord");
+
+ //}
+ // 委托 被动执行 被子窗口执行
+ // dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
+ RequestData();
+ }
+
+ public bool KeepAlive => false;
+
+ public void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback)
+ {
+ continuationCallback(true);
+ }
+
+ public bool IsNavigationTarget(NavigationContext navigationContext)
+ {
+ return true;
+ }
+
+ ///
+ /// 还空瓶按钮--打开抽屉
+ ///
+ public DelegateCommand OpenDrawer
+ {
+ get => new DelegateCommand(() =>
+ {
+ if (Status == 0)
+ {
+ if (OrderDetails != null && OrderDetails.Count > 0)
+ {
+ List records = OrderDetails[0].MachineRecords.Where(rd => rd.CurrentReturn > 0).ToList();
+ if (records != null && records.Count > 0)
+ {
+ CStock = SqlSugarHelper.Db.Queryable()
+ .Where(c => c.DrawerType != 1 && c.DrugId == records[0].DrugId && c.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).First();
+ if (CStock != null)
+ {
+ Status = 1;
+ _portUtil.SpeakAsync("正在打开" + CStock.DrawerNo + "号抽屉");
+ _portUtil.WindowName = "ReturnWithOrderWindow";
+ _portUtil.Operate = true;
+ _portUtil.BoardType = CStock.BoardType;
+ _portUtil.ColNos = new int[] { };// singleChannels.Select(it => it.ColNo).ToArray();
+ _portUtil.DrawerNo = CStock.DrawerNo;
+ _portUtil.Start();
+ }
+ else
+ {
+ //药品未绑定回收药箱
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "药品未绑定回收药箱",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ }
+ else
+ {
+ //未输入还空瓶数量
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "没有与之对应的取药记录或没有填写空瓶数量",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ }
+ else
+ {
+ AlertMsg alert = new AlertMsg
+ {
+ Message = "该处方下无药品明细",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alert);
+ }
+ }
+ });
+ }
+ // 完成按钮
+ public DelegateCommand SaveCommand
+ {
+ get => new DelegateCommand(() =>
+ {
+ if (!_isFinishClick)
+ {
+ _isFinishClick = true;
+ var f = SqlSugarHelper.Db.UseTran(() =>
+ {
+ //0)检查处方中药品数量是否与还空瓶数量相等
+ if (OrderDetails != null && OrderDetails.Count > 0)
+ {
+ if (OrderDetails[0].Quantity != OrderDetails.Sum(it => it.MachineRecords.Sum(m => m.CurrentReturn)))
+ {
+ AlertMsg alert = new AlertMsg
+ {
+ Message = "处方用药数量与还空瓶数量不一致",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alert);
+ return false;
+ }
+ }
+ if (OrderDetails[0].MachineRecords != null && OrderDetails[0].MachineRecords.Count > 0)
+ {
+ List recordList = OrderDetails[0].MachineRecords.Where(mr=>mr.CanReturnQuantity>0).ToList();
+ for (int i = 0; i < recordList.Count; i++)
+ {
+ if (recordList[i].CanReturnQuantity < recordList[i].CurrentReturn)
+ {
+ AlertMsg alert = new AlertMsg
+ {
+ Message = "还空瓶数量不能大于可还空瓶数量",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alert);
+ break;
+ }
+
+ //1) 写一条还空瓶记录
+ SqlSugarHelper.Db.Insertable(new MachineRecord()
+ {
+ MachineId = recordList[i].MachineId,
+ DrawerNo = CStock.DrawerNo,
+ ColNo = CStock.ColNo,
+ DrugId = recordList[i].DrugId,
+ ManuNo = recordList[i].ManuNo,
+ EffDate = recordList[i].EffDate.HasValue ? recordList[i].EffDate.Value.Date : null,
+ Operator = HomeWindowViewModel.Operator?.Id,
+ Reviewer = HomeWindowViewModel.Reviewer?.Id,
+ OperationTime = DateTime.Now,
+ Quantity = recordList[i].CurrentReturn,
+ Type = 32,
+ InvoiceId = OrderDetails[0].OrderNo,
+ GetId = recordList[i].Id,
+ StockQuantity = recordList[i].ReturnQuantity2
+ }).ExecuteCommand();
+
+ //2)更改当前取药记录的状态
+ SqlSugarHelper.Db.Updateable(new MachineRecord()
+ {
+ ReturnQuantity2 = recordList[i].CurrentReturn + recordList[i].ReturnQuantity2,
+ Id = recordList[i].Id,
+ Status = recordList[i].ReturnQuantity2 + recordList[i].ReturnQuantity1+ recordList[i].CurrentReturn == recordList[i].Quantity ? 2 : 1,
+ }).UpdateColumns(it => new { it.ReturnQuantity2, it.Status }).ExecuteCommand();
+
+ ////3)写hkc_order_finished数据供his反查
+ //SqlSugarHelper.Db.Insertable(new OrderFinish()
+ //{
+ // OrderNo = OrderDetails[0].OrderNo,
+ // PatientId = SelectedOrder.PatientId,
+ // Pharmacy = SelectedOrder.Pharmacy,
+ // State = 1,
+ // Operator = HomeWindowViewModel.Operator?.Nickname,
+ // DrugId = OrderDetails[0].DrugId,
+ // Quantity = recordList[i].CurrentReturn,
+ // //ManuNo = recordList[i].ManuNo.ToString(),
+ // //EffDate =recordList[i].EffDate.HasValue ? recordList[i].EffDate.Value.ToString("yyyy-MM-dd") : null,
+
+ //}).ExecuteCommand();
+ }
+ //4)加回收箱的库存数
+ if (CStock != null)
+ {
+ CStock.Quantity = CStock.Quantity + OrderDetails[0].MachineRecords.Sum(m => m.CurrentReturn);
+ SqlSugarHelper.Db.Updateable(CStock).ExecuteCommand();
+ }
+ //5) 更新处方状态
+ SqlSugarHelper.Db.Updateable(new OrderInfo()
+ {
+ DmStatus = 1,
+ OrderNo = OrderDetails[0].OrderNo
+ }).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
+
+
+
+ }
+ return true;
+ });
+ if (f.Data)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "操作完成",
+ Type = MsgType.SUCCESS,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ if (!f.IsSuccess)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "操作失败!",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ Status = 0;
+ _isFinishClick = false;
+ }
+ RequestData();
+ });
+ }
+
+ public long CurrentTimeMillis()
+ {
+ return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
+ }
+
+ // 取消按钮
+ public DelegateCommand CancleTake
+ {
+ get => new DelegateCommand(() =>
+ {
+ IsFinishClick = false;
+ _portUtil.ResetData();
+ Status = 0;
+ });
+ }
+ void DoMyPrismEvent(DeviceMsg msg)
+ {
+
+ if (msg.WindowName.Equals(WindowName))
+ {
+ switch (msg.EventType)
+ {
+ // 抽屉打开
+ case EventType.DRAWEROPEN:
+ if (Status == 1)
+ {
+ Status = 2;
+ }
+ //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
+ //CheckIsFridgeOpen();
+ break;
+ // 抽屉关闭
+ case EventType.DRAWERCLOSE:
+ if (Status == 2)
+ {
+ //IGrouping groupingBefore = enumerator.Current;
+ //int DrawerNoBefore = groupingBefore.Key;
+ //if (enumerator.MoveNext())
+ //{
+ // IGrouping groupingAfter = enumerator.Current;
+ // int DrawerNoAfter = groupingAfter.Key;
+ // if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
+ // {
+ // Thread.Sleep(50);
+ // }
+ // //OpenOneByOne();
+ //}
+ //else
+ {
+ Status = 3;
+ }
+ }
+ //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
+ //CheckIsFridgeClose();
+ break;
+ // 数量变化
+ case EventType.UPDATEQUANTITY:
+ if (Status == 1)
+ {
+ logger.Info($"抽屉【{CStock.DrawerNo}】库位还空瓶数量【{msg.Quantitys}】");
+ //channelStocks.ForEach(it => it.ReturnQuantity = msg.Quantitys[it.ColNo - 1]);
+ }
+ break;
+ // 打开失败
+ case EventType.OPENERROR:
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = msg.Message,
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ Status = 0;
+ break;
+ }
+ }
+
+ }
+ public void OnNavigatedFrom(NavigationContext navigationContext)
+ {
+ // 取消消息订阅
+ _eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
+ }
+
+ public void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ //查询表格数据
+ RequestData();
+ BindUserList();
+ _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
+ }
+ private void RequestData()
+ {
+
+ OrderInfos.Clear();
+ int totalCount = 0;
+
+ List queryData = SqlSugarHelper.Db.Queryable()
+ .InnerJoin((oi, od) => oi.OrderNo == od.OrderNo)
+ // .InnerJoin(SqlSugarHelper.Db.Queryable().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
+ .WhereIF(OrderDate != null, oi => oi.RecvDate.ToString("yyyy-MM-dd") == OrderDate)
+ .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
+ .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
+ .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
+ .Where(oi => oi.DmStatus == 0)
+ .Where(oi => oi.HisDispFlag == 0)
+ .Where(oi => oi.CancelFlag == 0)
+ .GroupBy(oi => oi.ChargeDate)
+ .Select(oi => new OrderInfo()
+ {
+ PatientId= oi.PatientId,
+ IdNumber = oi.IdNumber,
+ PName=oi.PName,
+ Sex=oi.Sex,
+ ChargeDate=oi.ChargeDate,
+ OrderNo = oi.OrderNo,
+ orderDetail =SqlFunc.Subqueryable().Where(od => od.OrderNo == oi.OrderNo).First(),
+ })
+ .ToPageList(PageNum, PageSize, ref totalCount);
+ OrderInfos = queryData;
+ TotalCount = totalCount;
+ PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
+ }
+ private void BindUserList()
+ {
+ UserLists = SqlSugarHelper.Db.Queryable().Distinct()
+ .InnerJoin((ul, mr) => ul.Id == mr.Operator)
+ .Where(ul => ul.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
+ .Where((ul, mr) => mr.Type == 2 && mr.Status != 2 && mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
+ .ToList();
+ }
+
+ private void BindDrugInfo()
+ {
+ if (SelectedOrder != null)
+ {
+
+ OrderDetails = SqlSugarHelper.Db.Queryable()
+ .Includes(cl => cl.DrugInfo, di => di.DrugManuNos)
+ .Where(od => od.OrderNo == SelectedOrder.OrderNo).ToList();
+ if (OrderDetails != null && OrderDetails.Count > 0)
+ {
+ for (int i = 0; i < OrderDetails.Count; i++)
+ {
+ List machineRecords = new List();
+ machineRecords = SqlSugarHelper.Db.Queryable()
+ .Where(mr => mr.DrugId == OrderDetails[i].DrugId && mr.Type == 2 && mr.Status != 2 && mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
+ .WhereIF(!String.IsNullOrEmpty(OptDate), mr => mr.OperationTime.ToString("yyyy-MM-dd") == OptDate)
+ .WhereIF(!String.IsNullOrEmpty(UserSelects.UserName), mr => mr.Reviewer == UserSelects.Id)
+ .WhereIF(String.IsNullOrEmpty(UserSelects.UserName) && HomeWindowViewModel.Reviewer != null, mr => mr.Reviewer == HomeWindowViewModel.Reviewer.Id)
+ .ToList();
+ if (machineRecords != null && machineRecords.Count > 0)
+ {
+ machineRecords.ForEach(mr =>
+ {
+ mr.DrugInfo = OrderDetails[i].DrugInfo;
+ mr.drugManuNo = OrderDetails[i].DrugInfo.DrugManuNos.Find(it => it.ManuNo.Equals(mr.ManuNo));
+ });
+ //处方中取药数量大于第一个取药的可还空瓶数,需要将处方中数据平均分配到取药列表中的还空瓶数量中
+ if (OrderDetails[i].Quantity > machineRecords[0].CanReturnQuantity)
+ {
+ int orderQuantity = OrderDetails[i].Quantity;
+ for (int j = 0; j < machineRecords.Count; j++)
+ {
+ if (orderQuantity > machineRecords[j].CanReturnQuantity)
+ {
+ machineRecords[j].CurrentReturn = machineRecords[j].CanReturnQuantity;
+ orderQuantity = orderQuantity - machineRecords[j].CanReturnQuantity;
+ }
+ else
+ {
+ machineRecords[j].CurrentReturn = orderQuantity;
+ break;
+ }
+ }
+ }
+ else
+ {
+ machineRecords[0].CurrentReturn = OrderDetails[i].Quantity;
+ }
+ }
+ OrderDetails[i].MachineRecords = machineRecords;
+
+ }
+ }
+
+ //ChannelList queryData = SqlSugarHelper.Db.Queryable()
+ // .Includes(cl => cl.Drug, di => di.DrugManuNos)
+ // .Includes(cl => cl.channelStocks, dr => dr.DrugInfo, d => d.DrugManuNos)
+ // .Where(cl => cl.DrawerType == 2&&cl.DrugId== od.DrugId)
+ // .Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).First();
+
+ //queryData.channelStocks = queryData.channelStocks.Select(cs => {
+ // cs.drugManuNo = queryData.Drug.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
+ // return cs;
+ //}).ToList();
+ //ChannelLsts = queryData;
+ //if (Ordetails != null)
+ //{
+ // DetailDrugName = Ordetails[0].DrugInfo.DrugName;
+ // DetailDrugSpec = Ordetails[0].DrugInfo.DrugSpec;
+ // DetailDrugFactory = Ordetails[0].DrugInfo.Manufactory;
+ //}
+ //ChannelLsts.channelStocks.ForEach(cs => cs.DrugInfo = ChannelLsts.Drug);
+ }
+ else
+ {
+ OrderDetails = null;
+ }
+ }
+
+
+ }
+}
diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
index 3303906..99b5c63 100644
--- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
+++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs
@@ -250,11 +250,17 @@ namespace DM_Weight.ViewModels
PremissionName = "归还药品",
PremissionPath = "ReturnDrugWindow2",
};
+ //PremissionDm huanyao2 = new PremissionDm
+ //{
+ // Id = 32,
+ // PremissionName = "归还空瓶",
+ // PremissionPath = "ReturnEmptyWindow",
+ //};
PremissionDm huanyao2 = new PremissionDm
{
Id = 32,
PremissionName = "归还空瓶",
- PremissionPath = "ReturnEmptyWindow",
+ PremissionPath = "ReturnWithOrderWindow",
};
PremissionDm huanyao3 = new PremissionDm
{
diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
index 88e936f..a048c88 100644
--- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
@@ -243,10 +243,10 @@ namespace DM_Weight.ViewModels
{
Quantity = it.Quantity + it.AddQuantity,
PosNo = 1,
- //ManuNo = it.ManuNo,
- //EffDate = it.EffDate,
+ ManuNo = it.ManuNo,
+ EffDate = it.EffDate,
Id = it.Id,
- }).UpdateColumns(it => new { it.Quantity, it.PosNo }).ExecuteCommand();
+ }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// 获取更新完库存后的药品库存
List nowChannels = SqlSugarHelper.Db.Queryable()
.Where(cs => cs.MachineId.Equals(it.MachineId))
@@ -261,8 +261,8 @@ namespace DM_Weight.ViewModels
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
- //ManuNo = it.ManuNo,
- //EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ ManuNo = it.ManuNo,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
@@ -272,12 +272,12 @@ namespace DM_Weight.ViewModels
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
+ // Thread.Sleep(80);
+ //}
}
return true;
});
@@ -290,7 +290,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
+ _portUtil.WriteQuantityMethod(it.Quantity + it.AddQuantity,it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
});
}
diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
index b1df958..6a1d514 100644
--- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
@@ -220,10 +220,10 @@ namespace DM_Weight.ViewModels
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
- //ManuNo = it.ManuNo,
- //EffDate = it.EffDate,
+ ManuNo = it.ManuNo,
+ EffDate = it.EffDate,
Id = it.Id,
- }).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
+ }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List nowChannels = SqlSugarHelper.Db.Queryable()
.Where(cs => cs.MachineId.Equals(it.MachineId))
@@ -238,8 +238,8 @@ namespace DM_Weight.ViewModels
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
- //ManuNo = it.ManuNo,
- //EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
+ ManuNo = it.ManuNo,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
OperationTime = DateTime.Now,
Quantity = it.TakeQuantity,
@@ -249,12 +249,12 @@ namespace DM_Weight.ViewModels
StockQuantity = nowChannels.Sum(it => it.Quantity)
}).ExecuteCommand();
//称重计数或称重+智能显示+管控药盒 类型需要 发26指令
- if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
- {
- //计数数量设置,发送称重26指令
- _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
- Thread.Sleep(80);
- }
+ //if (it.BoardType == (Int32)BoardTypeEnum.weigh || it.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
+ //{
+ // //计数数量设置,发送称重26指令
+ // _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
+ // Thread.Sleep(80);
+ //}
}
return true;
});
@@ -267,7 +267,8 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
+ _portUtil.WriteQuantityMethod(it.Quantity - it.TakeQuantity,it.DrawerNo, it.ColNo);
+ Thread.Sleep(200);
});
}
diff --git a/DM_Weight/ViewModels/WarnDialogViewModel.cs b/DM_Weight/ViewModels/WarnDialogViewModel.cs
new file mode 100644
index 0000000..927bdd9
--- /dev/null
+++ b/DM_Weight/ViewModels/WarnDialogViewModel.cs
@@ -0,0 +1,50 @@
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.ViewModels
+{
+ public class WarnDialogViewModel:BindableBase, IDialogAware, IRegionMemberLifetime
+ {
+ private string _warnMessage;
+ public string WarnMessage
+ {
+ get => _warnMessage;
+ set => SetProperty(ref _warnMessage, value);
+ }
+
+ public string Title => "警告";
+
+ public bool KeepAlive => false;
+
+ public event Action RequestClose;
+
+ public bool CanCloseDialog()
+ {
+ return true;
+ }
+
+ public void OnDialogClosed()
+ {
+ }
+
+ public void OnDialogOpened(IDialogParameters parameters)
+ {
+ WarnMessage=parameters.GetValue("warnMessage");
+
+ }
+ public DelegateCommand CancleTake
+ {
+ get => new DelegateCommand(() =>
+ {
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ });
+ }
+ }
+}
diff --git a/DM_Weight/Views/BiaoDingWindow.xaml b/DM_Weight/Views/BiaoDingWindow.xaml
index 79d4c0b..62a1f87 100644
--- a/DM_Weight/Views/BiaoDingWindow.xaml
+++ b/DM_Weight/Views/BiaoDingWindow.xaml
@@ -16,6 +16,8 @@
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
+ ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
-
@@ -296,7 +322,14 @@
-
+
+
+
+
+
+
+
+ ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-
+
+
+
+
+
+
+
diff --git a/DM_Weight/Views/DrugListWindow.xaml b/DM_Weight/Views/DrugListWindow.xaml
index 6dcec50..4d01abb 100644
--- a/DM_Weight/Views/DrugListWindow.xaml
+++ b/DM_Weight/Views/DrugListWindow.xaml
@@ -162,7 +162,7 @@
-
+
diff --git a/DM_Weight/Views/FridgeWindow.xaml b/DM_Weight/Views/FridgeWindow.xaml
index f97a692..74baac6 100644
--- a/DM_Weight/Views/FridgeWindow.xaml
+++ b/DM_Weight/Views/FridgeWindow.xaml
@@ -15,24 +15,25 @@
-
+
-
-
-
-
+
+
+
+
+
-
+
@@ -41,37 +42,30 @@
-
+ HorizontalAlignment="Left"
+ x:Name="MaterialDesignFilledTextBoxEnabledComboBox"
+ Style="{StaticResource MaterialDesignActionToggleButton}"
+ IsChecked="{Binding FridgeState}"
+ ToolTip="冰箱状态"
+ Content="打开"
+ materialDesign:ToggleButtonAssist.OnContent="关闭" />
-
+ HorizontalAlignment="Left"
+ Style="{StaticResource MaterialDesignActionToggleButton}"
+ IsChecked="{Binding AlarmState}"
+ ToolTip="报警状态"
+ Content="打开"
+ materialDesign:ToggleButtonAssist.OnContent="关闭" />
+
+
+
+
diff --git a/DM_Weight/Views/HomeWindow.xaml b/DM_Weight/Views/HomeWindow.xaml
index abab955..8c1eef4 100644
--- a/DM_Weight/Views/HomeWindow.xaml
+++ b/DM_Weight/Views/HomeWindow.xaml
@@ -118,7 +118,7 @@
-
+
diff --git a/DM_Weight/Views/InvoiceInWindow.xaml b/DM_Weight/Views/InvoiceInWindow.xaml
index 05d8675..8493f58 100644
--- a/DM_Weight/Views/InvoiceInWindow.xaml
+++ b/DM_Weight/Views/InvoiceInWindow.xaml
@@ -199,7 +199,7 @@
Header="库位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-
+ ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-
+ Header="效期"/>
diff --git a/DM_Weight/Views/ReturnWithOrderWindow.xaml b/DM_Weight/Views/ReturnWithOrderWindow.xaml
new file mode 100644
index 0000000..959edd2
--- /dev/null
+++ b/DM_Weight/Views/ReturnWithOrderWindow.xaml
@@ -0,0 +1,316 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DM_Weight/Views/ReturnWithOrderWindow.xaml.cs b/DM_Weight/Views/ReturnWithOrderWindow.xaml.cs
new file mode 100644
index 0000000..1dc8a05
--- /dev/null
+++ b/DM_Weight/Views/ReturnWithOrderWindow.xaml.cs
@@ -0,0 +1,40 @@
+using DM_Weight.Models;
+using DM_Weight.msg;
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace DM_Weight.Views
+{
+ ///
+ /// ReturnWithOrderWindow.xaml 的交互逻辑
+ ///
+ public partial class ReturnWithOrderWindow : UserControl
+ {
+ //IEventAggregator _eventAggregator;
+ public ReturnWithOrderWindow()
+ {
+ InitializeComponent();
+ //_eventAggregator = eventAggregator;
+ }
+ //private void Button_Click(object sender, RoutedEventArgs e)
+ //{
+ // Button btn = (Button)sender;
+ // OrderDetail od = (OrderDetail)btn.CommandParameter;
+ // //vms.AddAction(cls);
+ // _eventAggregator.GetEvent().Publish(od);
+ //}
+ }
+}
diff --git a/DM_Weight/Views/SelfAddWindow.xaml b/DM_Weight/Views/SelfAddWindow.xaml
index f213bb2..b7880d9 100644
--- a/DM_Weight/Views/SelfAddWindow.xaml
+++ b/DM_Weight/Views/SelfAddWindow.xaml
@@ -128,7 +128,7 @@
Header="库位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-
+ ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-
+ ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-
+ ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
+ {
+ }
+}
diff --git a/DM_Weight/util/PromiseUtil.cs b/DM_Weight/util/PromiseUtil.cs
new file mode 100644
index 0000000..1638a60
--- /dev/null
+++ b/DM_Weight/util/PromiseUtil.cs
@@ -0,0 +1,41 @@
+using SharpPromise;
+using System;
+using System.Threading.Tasks;
+
+namespace DM_Weight.util
+{
+ public class PromiseUtil
+ {
+
+ public int _delay { get; set; }
+
+ public T? _data { get; set; }
+
+ public async Task taskAsyncLoop(int delay, T data, Action, Action, Action> action)
+ {
+ _data = data;
+ _delay = 0;
+ while (_delay >= 0)
+ {
+ await new Promise(async (Action onResolve, Action onReject) =>
+ {
+ await Task.Delay(_delay);
+ try
+ {
+ await Task.Run(() => action(this, onResolve, onReject));
+ }
+ catch (Exception ex)
+ {
+ onReject();
+ }
+ }).Then(() =>
+ {
+ _delay = delay;
+ }).Catch((Exception e) =>
+ {
+ _delay = -1;
+ });
+ }
+ }
+ }
+}