From 3e34ffe9127ce22b19033454260e60052a011bf3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=A9=AC=E5=B7=A7?= <625215135@qq.com>
Date: Thu, 10 Jul 2025 11:52:24 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=95=E5=B1=8F=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=8F=AF=E5=A4=9A=E6=AC=A1?=
=?UTF-8?q?=E5=8A=A0=E8=8D=AF=EF=BC=8C=E6=AF=92=E9=BA=BB=E6=9F=9C=E6=97=A0?=
=?UTF-8?q?=E8=8D=AF=E5=88=99=E6=98=BE=E7=A4=BA=E6=97=A0=E5=BA=93=E5=AD=98?=
=?UTF-8?q?=E6=88=96=E6=9C=AA=E7=BB=91=E5=AE=9A=EF=BC=8C=E5=AF=B9=E5=BA=94?=
=?UTF-8?q?=E7=9A=84=E8=8D=AF=E5=93=81=E5=85=88=E4=B8=8D=E8=A1=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DM_Weight/App.config | 10 +-
DM_Weight/Converter/StockStatusConverter.cs | 37 +-
.../Converter/TakeQuantityEnabelConverter.cs | 25 ++
DM_Weight/Converter/TakeQuantityVisiable.cs | 24 ++
DM_Weight/DM_Weight.csproj | 1 +
DM_Weight/Models/ChannelStock.cs | 2 +-
DM_Weight/Port/PortUtil.cs | 9 +-
.../ViewModels/AddToJiaoJieDialogViewModel.cs | 240 ++++++++-----
.../AddToJiaoJieNewDialogViewModel.cs | 13 -
.../ViewModels/AddToJiaoJieWindowViewModel.cs | 340 +-----------------
.../ViewModels/CheckStockWindowViewModel.cs | 1 +
.../DrawerAddDrugWindowViewModel.cs | 2 +
.../DrawerTakeDrugWindowViewModel.cs | 2 +
DM_Weight/ViewModels/HomeWindowViewModel.cs | 2 +-
.../ViewModels/InvoiceAddDialogViewModel.cs | 3 +-
.../ViewModels/InvoiceTakeDialogViewModel.cs | 2 +
DM_Weight/ViewModels/LoginWindowViewModel.cs | 57 +--
DM_Weight/ViewModels/MainWindowViewModel.cs | 113 +++++-
.../MultiOrderTakeDialogViewModel.cs | 2 +
.../ViewModels/OrderReturnDialogViewModel.cs | 4 +-
.../ViewModels/OrderTakeDialogViewModel.cs | 2 +
.../ViewModels/ReturnDrugDialogViewModel.cs | 2 +
.../ViewModels/ReturnEmptyDialogViewModel.cs | 2 +
.../ViewModels/SelfAddDialogViewModel.cs | 4 +-
.../ViewModels/SelfTakeDialogViewModel.cs | 2 +
DM_Weight/Views/AddToJiaoJieWindow.xaml | 18 +-
.../Views/Dialog/AddToJiaoJieDialog.xaml | 4 +-
.../Views/Dialog/AddToJiaoJieNewDialog.xaml | 174 ---------
.../Dialog/AddToJiaoJieNewDialog.xaml.cs | 28 --
DM_Weight/Views/MainWindow.xaml.cs | 15 +-
DM_Weight/msg/PrintScreenEvent.cs | 14 +
31 files changed, 447 insertions(+), 707 deletions(-)
create mode 100644 DM_Weight/Converter/TakeQuantityEnabelConverter.cs
create mode 100644 DM_Weight/Converter/TakeQuantityVisiable.cs
delete mode 100644 DM_Weight/ViewModels/AddToJiaoJieNewDialogViewModel.cs
delete mode 100644 DM_Weight/Views/Dialog/AddToJiaoJieNewDialog.xaml
delete mode 100644 DM_Weight/Views/Dialog/AddToJiaoJieNewDialog.xaml.cs
create mode 100644 DM_Weight/msg/PrintScreenEvent.cs
diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 9002993..68a8d03 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -3,7 +3,7 @@
-
+
-
+
@@ -54,9 +54,9 @@
-
+
-
+
@@ -99,7 +99,7 @@
-
+
diff --git a/DM_Weight/Converter/StockStatusConverter.cs b/DM_Weight/Converter/StockStatusConverter.cs
index cb18a15..46adfda 100644
--- a/DM_Weight/Converter/StockStatusConverter.cs
+++ b/DM_Weight/Converter/StockStatusConverter.cs
@@ -13,27 +13,30 @@ namespace DM_Weight.Converter
//是否给交接柜补药已补药的则不可勾选,未补药的可勾选以进行补药:0未补1已补
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- int status = int.Parse(value.ToString());
- if (parameter.ToString() == "EnableState")
+ if (value != null)
{
- if (status == 0)
+ int status = int.Parse(value.ToString());
+ if (parameter.ToString() == "EnableState")
{
- return true;
+ if (status == 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
- else
+ if (parameter.ToString() == "TextState")
{
- return false;
- }
- }
- if (parameter.ToString() == "TextState")
- {
- if (status == 0)
- {
- return "未取药";
- }
- else
- {
- return "已取药待入库";
+ if (status == 0)
+ {
+ return "未取药";
+ }
+ else
+ {
+ return "已取药待入库";
+ }
}
}
return "";
diff --git a/DM_Weight/Converter/TakeQuantityEnabelConverter.cs b/DM_Weight/Converter/TakeQuantityEnabelConverter.cs
new file mode 100644
index 0000000..4c05203
--- /dev/null
+++ b/DM_Weight/Converter/TakeQuantityEnabelConverter.cs
@@ -0,0 +1,25 @@
+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 TakeQuantityEnabelConverter : IValueConverter
+ {
+ //-1未绑定
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (int)value == -1 ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return Binding.DoNothing;
+ }
+ }
+}
diff --git a/DM_Weight/Converter/TakeQuantityVisiable.cs b/DM_Weight/Converter/TakeQuantityVisiable.cs
new file mode 100644
index 0000000..8a692f9
--- /dev/null
+++ b/DM_Weight/Converter/TakeQuantityVisiable.cs
@@ -0,0 +1,24 @@
+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 TakeQuantityVisiable: IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (int)(value) <0 ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/DM_Weight/DM_Weight.csproj b/DM_Weight/DM_Weight.csproj
index 2b270b6..b75f7e8 100644
--- a/DM_Weight/DM_Weight.csproj
+++ b/DM_Weight/DM_Weight.csproj
@@ -71,6 +71,7 @@
+
diff --git a/DM_Weight/Models/ChannelStock.cs b/DM_Weight/Models/ChannelStock.cs
index 248b1dc..2256fea 100644
--- a/DM_Weight/Models/ChannelStock.cs
+++ b/DM_Weight/Models/ChannelStock.cs
@@ -112,7 +112,7 @@ namespace DM_Weight.Models
[SugarColumn(IsIgnore = true)]
public string Location
{
- get => ColNo == 0 ? DrawerNo + "号交接柜" :ColNo==-1?"未绑定": DrawerNo + "-" + ColNo;
+ get => ColNo == 0 ? DrawerNo + "号交接柜" :ColNo==-1?"未绑定": ColNo == -2 ? "库存不足" : DrawerNo + "-" + ColNo;
}
private int _addQuantity = 0;
diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs
index 4a87ef2..82345c5 100644
--- a/DM_Weight/Port/PortUtil.cs
+++ b/DM_Weight/Port/PortUtil.cs
@@ -87,6 +87,9 @@ namespace DM_Weight.Port
// 是否正在操作中
public bool Operate { get; set; }
+ // 操作完抽屉是否点完成按钮
+ public bool OperateFinish { get; set; } = true;
+
//冰箱是否正在操作中
public bool FridgeOperate { get; set; }
@@ -197,7 +200,7 @@ namespace DM_Weight.Port
if (state)
{
//抽屉全部关闭
-
+ OperateFinish = false;
string _WindowName = WindowName;
// 重新初始化数据
ResetData();
@@ -550,7 +553,8 @@ namespace DM_Weight.Port
}
string _WindowName = WindowName;
// 重新初始化数据
- ResetData();
+ ResetData();
+ OperateFinish = false;
// 返回消息 抽屉已经关闭
_eventAggregator.GetEvent().Publish(new util.DeviceMsg()
{
@@ -656,6 +660,7 @@ namespace DM_Weight.Port
statue = 2;
string _WindowName = WindowName;
+ OperateFinish = false;
// 重新初始化数据
ResetData();
_eventAggregator.GetEvent().Publish(new util.DeviceMsg()
diff --git a/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs b/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs
index 14d8cc1..4754524 100644
--- a/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs
+++ b/DM_Weight/ViewModels/AddToJiaoJieDialogViewModel.cs
@@ -222,53 +222,73 @@ namespace DM_Weight.ViewModels
//.OrderBy(cs => cs.EffDate)
.OrderBy(cs => new { cs.EffDate, cs.DrawerNo, cs.ColNo })
.ToList();
- if (HasQChannels == null || HasQChannels.Count <= 0)
+ //if (HasQChannels == null || HasQChannels.Count <= 0)
+ //{
+ // msg.Add($"有药品未绑定,请先绑定");
+ // continue;
+ //}
+ if (HasQChannels != null && HasQChannels.Count > 0)
{
- msg.Add($"有药品未绑定,请先绑定");
- continue;
- }
- int total = HasQChannels.Sum(it => it.Quantity);
- int TakeQ = ChannelStocks[i].AddQuantity;
- // 说明数量足够
- if (total >= TakeQ)
- {
- //for (int j = 0; TakeQ > 0; j++)
+ int total = HasQChannels.Sum(it => it.Quantity);
+ int TakeQ = ChannelStocks[i].AddQuantity;
+ // 说明数量足够
+ //if (total >= TakeQ)
//{
- // ChannelStock stock = HasQChannels[j];
- // if (TakeQ > stock.Quantity)
- // {
- // stock.TakeQuantity = stock.Quantity;
- // channelStocks.Add(stock);
- // TakeQ -= stock.Quantity;
- // }
- // else
- // {
- // stock.TakeQuantity = TakeQ;
- // channelStocks.Add(stock);
- // TakeQ = 0;
- // }
+ //for (int j = 0; TakeQ > 0; j++)
+ //{
+ // ChannelStock stock = HasQChannels[j];
+ // if (TakeQ > stock.Quantity)
+ // {
+ // stock.TakeQuantity = stock.Quantity;
+ // channelStocks.Add(stock);
+ // TakeQ -= stock.Quantity;
+ // }
+ // else
+ // {
+ // stock.TakeQuantity = TakeQ;
+ // channelStocks.Add(stock);
+ // TakeQ = 0;
+ // }
+ //}
+ int hadTakeQ = 0;
+ for (int j = 0; j < HasQChannels.Count; j++)
+ {
+ if ((ChannelStocks[i].AddQuantity - hadTakeQ) > HasQChannels[j].Quantity)
+ {
+ HasQChannels[j].TakeQuantity = HasQChannels[j].Quantity;
+ hadTakeQ += HasQChannels[j].Quantity;
+ }
+ else
+ {
+ HasQChannels[j].TakeQuantity = ChannelStocks[i].AddQuantity - hadTakeQ;
+ break;
+ }
+ }
+ channelStocks.AddRange(HasQChannels);
+ //}
+ //else
+ //{
+ // //msg.Add($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
+ // ChannelStock channel = ChannelStocks[i];
+ // channel.ColNo = -2;
+ // channel.Quantity = 0;
+ // channel.ManuNo = null;
+ // channel.EffDate = null;
+ // channel.Quantity = total;
+ // channel.TakeQuantity = 0;
+ // channelStocks.Add(channel);
//}
- int hadTakeQ = 0;
- for (int j = 0; j < HasQChannels.Count; j++)
- {
- if ((ChannelStocks[i].AddQuantity - hadTakeQ) > HasQChannels[j].Quantity)
- {
- HasQChannels[j].TakeQuantity = HasQChannels[j].Quantity;
- hadTakeQ += HasQChannels[j].Quantity;
- }
- else
- {
- HasQChannels[j].TakeQuantity = ChannelStocks[i].AddQuantity - hadTakeQ;
- break;
- }
- }
- channelStocks.AddRange(HasQChannels);
}
else
{
- msg.Add($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
+ ChannelStock channel = ChannelStocks[i];
+ channel.ColNo = -1;
+ channel.Quantity = 0;
+ channel.ManuNo = null;
+ channel.EffDate = null;
+ channel.TakeQuantity = 0;
+ channelStocks.Add(channel);
}
-
}
if (msg.Count > 0)
{
@@ -317,10 +337,23 @@ namespace DM_Weight.ViewModels
}
enumerable = ChannelStocks.Where(cs => cs.TakeQuantity > 0).GroupBy(cs => cs.DrawerNo, cs => cs);
- enumerator = enumerable.GetEnumerator();
- enumerator.MoveNext();
- Status = 1;
- OpenOneByOne();
+ if (enumerable != null && enumerable.Count() > 0)
+ {
+ enumerator = enumerable.GetEnumerator();
+ enumerator.MoveNext();
+ Status = 1;
+ OpenOneByOne();
+ }
+ else
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "没有可补药品!",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ return;
+ }
}
});
@@ -329,38 +362,41 @@ namespace DM_Weight.ViewModels
private void OpenOneByOne()
{
IGrouping grouping = enumerator.Current;
- int DrawerNo = grouping.Key;
- List channelStocks = grouping.ToList();
- channelStocks.ForEach(it => it.process = 1);
- _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
-
-
- List singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
-
- // 发送取药数量
- singleChannels.ForEach(it =>
+ if (grouping != null)
{
- try
- {
+ int DrawerNo = grouping.Key;
+ List channelStocks = grouping.ToList();
+ channelStocks.ForEach(it => it.process = 1);
+ _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
- }
- catch (Exception ex)
+
+ List singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
+
+ // 发送取药数量
+ singleChannels.ForEach(it =>
{
- AlertMsg alertMsg = new AlertMsg
+ try
{
- Message = $"打开抽屉异常{ex.Message}",
- Type = MsgType.ERROR,
- };
- _eventAggregator.GetEvent().Publish(alertMsg);
- }
- });
- _portUtil.WindowName = "OrderTakeDrugWindow";
- _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
- _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
- _portUtil.DrawerNo = DrawerNo;
- _portUtil.Start();
+ _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
+ }
+ catch (Exception ex)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = $"打开抽屉异常{ex.Message}",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ });
+
+ _portUtil.WindowName = "OrderTakeDrugWindow";
+ _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
+ _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
+ _portUtil.DrawerNo = DrawerNo;
+ _portUtil.Start();
+ }
}
private bool _isFinishClick = false;
@@ -388,10 +424,11 @@ namespace DM_Weight.ViewModels
{
if (jjItem.DrugId == csItem.DrugId)
{
- if (jjItem.Quantity != csItem.Quantity)
+ if (jjItem.Quantity < csItem.Quantity)
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
- SnackbarMessageQueue.Enqueue("输入药品数量与需要补药品数不一致!");
+ //SnackbarMessageQueue.Enqueue("输入药品数量与需要补药品数不一致!");
+ SnackbarMessageQueue.Enqueue("输入药品数量大于需要补药数!");
_isFinishClick = false;
return;
}
@@ -439,10 +476,12 @@ namespace DM_Weight.ViewModels
for (int i = 0; i < Jiaojie_ChannelStocks.Count; i++)
{
ChannelStock jiaoStock = Jiaojie_ChannelStocks[i];
- SqlSugarHelper.Db.Deleteable().Where(cs => cs.DrawerNo == Jiaojie_ChannelStocks[i].DrawerNo && cs.DrugId == Jiaojie_ChannelStocks[i].DrugId && cs.MachineId == Jiaojie_ChannelStocks[i].MachineId && cs.Quantity <= 0).ExecuteCommand();
List csStockList = record.Where(cs => cs.DrugId == Jiaojie_ChannelStocks[i].DrugId && cs.TakeQuantity > 0).ToList();
if (csStockList != null && csStockList.Count > 0)
{
+ int jjNeedQuantity = SqlSugarHelper.Db.Queryable().Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.MachineId == jiaoStock.MachineId).Sum(cs => cs.NeedNum);
+ SqlSugarHelper.Db.Deleteable().Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.MachineId == jiaoStock.MachineId && cs.Quantity <= 0).ExecuteCommand();
+
for (int j = 0; j < csStockList.Count; j++)
{
ChannelStock csStock = (ChannelStock)csStockList[j].Clone();
@@ -466,6 +505,7 @@ namespace DM_Weight.ViewModels
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.AddToJJNum = addNum;
newStock.Id = jjStockManuNo.Id;
+ newStock.State = 1;
//newStock.MachineId = jiaoStock.MachineId;
//newStock.NeedNum = 0;
//newStock.Quantity = jiaoStock.Quantity + csStock.TakeQuantity;
@@ -492,6 +532,7 @@ namespace DM_Weight.ViewModels
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].NeedNum;
newStock.Id = jjStockManuNo.Id;
+ newStock.State = 1;
//newStock.MachineId = jiaoStock.MachineId;
//newStock.NeedNum = 0;
//newStock.Quantity = jiaoStock.Quantity + csStock.TakeQuantity;
@@ -519,6 +560,7 @@ namespace DM_Weight.ViewModels
newStock.MachineId = Jiaojie_ChannelStocks[i].MachineId;
newStock.DrawerType = 1;
newStock.NeedNum = 0;
+ newStock.State = 1;
AddJJStock.Add(newStock);
Jiaojie_ChannelStocks[i].NeedNum = Jiaojie_ChannelStocks[i].NeedNum - csStock.TakeQuantity;
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
@@ -539,6 +581,7 @@ namespace DM_Weight.ViewModels
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = Jiaojie_ChannelStocks[i].MachineId;
newStock.DrawerType = 1;
+ newStock.State = 1;
AddJJStock.Add(newStock);
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
csStockList[j].TakeQuantity = csStock.TakeQuantity - newStock.AddToJJNum;
@@ -546,11 +589,18 @@ namespace DM_Weight.ViewModels
}
}
}
+ int addQuantity= AddJJStock.Where(aj => aj.DrugId == jiaoStock.DrugId).Sum(aj => aj.AddToJJNum);
+ int updateQuantity = UpdateJJStock.Where(aj => aj.DrugId == jiaoStock.DrugId).Sum(aj => aj.AddToJJNum);
+ int iUpdateResult= SqlSugarHelper.Db.Updateable()
+ .SetColumns(cs => new ChannelStock() { NeedNum = 0,State=1 })
+ .Where(cs => cs.DrawerNo == Jiaojie_ChannelStocks[i].DrawerNo && cs.DrugId == Jiaojie_ChannelStocks[i].DrugId && cs.MachineId == Jiaojie_ChannelStocks[i].MachineId)
+ .ExecuteCommand();
+ jiaoStock.NeedNum = jjNeedQuantity - (addQuantity + updateQuantity);
+ int iUpdateResult2 = SqlSugarHelper.Db.Updateable(jiaoStock)
+ .UpdateColumns(it => new { it.NeedNum })
+ .ExecuteCommand();
}
- SqlSugarHelper.Db.Updateable()
- .SetColumns(cs => new ChannelStock() { NeedNum = 0 })
- .Where(cs => cs.DrawerNo == Jiaojie_ChannelStocks[i].DrawerNo)
- .ExecuteCommand();
+
}
//保存交接柜数据
@@ -561,6 +611,7 @@ namespace DM_Weight.ViewModels
{
var ret = jj.First();
ret.AddToJJNum = jj.Sum(itx => itx.AddToJJNum);
+ ret.NeedNum = 0;
return ret;
}).ToList();
SqlSugarHelper.Db.Insertable(AddJJStock).ExecuteCommand();
@@ -572,11 +623,12 @@ namespace DM_Weight.ViewModels
{
var ret = jj.First();
ret.AddToJJNum = jj.Sum(itx => itx.AddToJJNum);
+ ret.NeedNum = 0;
return ret;
}).ToList();
for (int i = 0; i < UpdateJJStock.Count; i++)
{
- SqlSugarHelper.Db.Updateable().SetColumns(cs => new ChannelStock() { AddToJJNum = UpdateJJStock[i].AddToJJNum }).Where(cs => cs.Id == UpdateJJStock[i].Id).ExecuteCommand();
+ SqlSugarHelper.Db.Updateable().SetColumns(cs => new ChannelStock() { AddToJJNum = UpdateJJStock[i].AddToJJNum, State = 1 }).Where(cs => cs.Id == UpdateJJStock[i].Id).ExecuteCommand();
}
}
@@ -606,21 +658,21 @@ namespace DM_Weight.ViewModels
}
}
//更新交接柜状态为 已取药未入库(等在交接柜入库后再更新交接柜库存)
- if (Jiaojie_ChannelStocks != null)
- {
- Jiaojie_ChannelStocks.ForEach(jj =>
- {
- //更新交接柜状态为 已取药未入库
- SqlSugarHelper.Db.Updateable(new ChannelList()
- {
- State = 1,
- Id = jj.ChannelLst.Id
- }).UpdateColumns(it => it.State).ExecuteCommand();
+ //if (Jiaojie_ChannelStocks != null)
+ //{
+ // Jiaojie_ChannelStocks.ForEach(jj =>
+ // {
+ // //更新交接柜状态为 已取药未入库
+ // SqlSugarHelper.Db.Updateable(new ChannelList()
+ // {
+ // State = 1,
+ // Id = jj.ChannelLst.Id
+ // }).UpdateColumns(it => it.State).ExecuteCommand();
- }
+ // }
- );
- }
+ // );
+ //}
return true;
});
if (f.Data)
@@ -664,7 +716,8 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent().Publish(alertMsg);
}
Status = 0;
- _isFinishClick = false;
+ _isFinishClick = false;
+ _portUtil.OperateFinish = true;
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@@ -696,6 +749,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
//检查是否是冰箱抽屉(冰箱抽屉打开时需要发送冰箱延迟报警的指令)
diff --git a/DM_Weight/ViewModels/AddToJiaoJieNewDialogViewModel.cs b/DM_Weight/ViewModels/AddToJiaoJieNewDialogViewModel.cs
deleted file mode 100644
index db14983..0000000
--- a/DM_Weight/ViewModels/AddToJiaoJieNewDialogViewModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DM_Weight.ViewModels
-{
- public class AddToJiaoJieNewDialogViewModel
- {
-
- }
-}
diff --git a/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs b/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs
index f34baa7..54028c3 100644
--- a/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs
+++ b/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs
@@ -90,35 +90,6 @@ namespace DM_Weight.ViewModels
}
private void RequestData()
{
- //ChannelStocks = SqlSugarHelper.Db.Queryable()
- // .Includes(cs => cs.ChannelLst)
- // .Includes(cs => cs.DrugInfo)
- // .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cs.BaseQuantity > cs.Quantity)
- // .OrderBy(cs => cs.Chnguid)
- // .OrderBy(cs => cs.DrawerNo)
- // .ToList();
- ////ChannelStocks = ChannelStocks.GroupBy(it => new { it.DrawerNo, it.DrugId })
- //// .Select(it =>
- //// {
- //// var ret = it.First();
- //// ret.Quantity = it.Sum(itx => itx.Quantity);
- //// ret.NeedNum=it.Sum(itx => itx.NeedNum);
- //// return ret;
- //// }).Where(it=>it.BaseQuantity>it.Quantity)
- //// .ToList();
- //ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
-
- //ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks);
- //vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst"));
-
- //_ChannelLists = SqlSugarHelper.Db.Queryable()
- // .Includes(cl => cl.channelStocks)
- // .Includes(cl => cl.Drug)
- // .InnerJoin((cl, cs) => cl.Id == cs.Chnguid && cs.BaseQuantity > cs.Quantity)
- // .Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5"))
- // .OrderBy(cl => cl.Id)
- // .OrderBy(cl => cl.DrawerNo)
- // .ToList();
ChannelStocks?.Clear();
_ChannelLists?.Clear();
//1)查询channel_stock所有要补药的药箱
@@ -159,8 +130,8 @@ namespace DM_Weight.ViewModels
channelList.channelStocks.AddRange(ChannelStocks.Where(cs => cs.DrawerNo == DrawerNoList[i]&&(cs.NeedNum>0||cs.AddToJJNum>0)).ToList());
if (channelList != null)
{
- if (channelList.channelStocks[0].AddToJJNum>0)
- channelList.State=1; //表示有补药
+ //if (channelList.channelStocks[0].AddToJJNum>0)
+ // channelList.State=1; //表示有补药
channelLists.Add(channelList);
}
}
@@ -189,307 +160,6 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() => RequestData());
}
- //一键补药
- //public DelegateCommand OpenDragCommand
- //{
- // get => new DelegateCommand(() =>
- // {
- // try
- // {
- // Status = 1;
- // IsEnable = false;
-
- // var varDrawerNO = SqlSugarHelper.Db.Queryable()
- // .Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
- // .GroupBy(cs => cs.DrawerNo).Select(DrawerNo => DrawerNo).ToList();
-
- // iDrawerNoLst = varDrawerNO.Select(item => item.DrawerNo).ToList();
- // CurrentNum = 0;
- // _portUtil.SpeakAsync($"正在打开 {iDrawerNoLst[CurrentNum]} 号抽屉");
-
-
- // _portUtil.WindowName = "AddToJiaoJieWindow";
- // _portUtil.Operate = true;
- // //_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
- // //_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
- // _portUtil.DrawerNo = iDrawerNoLst[CurrentNum];
- // _portUtil.OpenAllDrawer();
-
- // }
- // catch (Exception ex)
- // {
-
- // AlertMsg alertMsg = new AlertMsg
- // {
- // Message = $"补药异常{ex.Message}",
- // Type = MsgType.ERROR,
- // };
- // _eventAggregator.GetEvent().Publish(alertMsg);
- // logger.Info($"AddToJiaoJieWindowViewModel异常:{ex.Message}");
- // _portUtil.Operate = false;
- // }
-
- // });
- //}
- //void DoMyPrismEvent(DeviceMsg msg)
- //{
- // if (msg.WindowName == "AddToJiaoJieWindow")
- // {
- // switch (msg.EventType)
- // {
- // // 抽屉打开
- // case EventType.DRAWEROPEN:
- // if (Status == 1)
- // {
- // Status = 2;
- // }
- // CurrentNum += 1;
- // if (CurrentNum < iDrawerNoLst.Count)
- // {
- // _portUtil.WindowName = "AddToJiaoJieWindow";
- // _portUtil.Operate = true;
- // _portUtil.DrawerNo = iDrawerNoLst[CurrentNum];
- // _portUtil.OpenAllDrawer();
- // }
- // else
- // {
- // _portUtil.GetAllDrawerLockState();
- // }
- // break;
- // // 抽屉关闭
- // case EventType.DRAWERCLOSE:
- // if (Status == 2)
- // {
- // Status = 3;
- // }
- // _portUtil.Operate = false;
- // IsEnable = true;
- // CurrentNum = 0;
-
- // break;
- // // 数量变化
- // case EventType.UPDATEQUANTITY:
- // if (Status == 2)
- // {
- // ChannelStocks.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;
- // _portUtil.Operate = false;
- // IsEnable = false;
- // CurrentNum = 0;
- // break;
- // }
- // }
-
- //}
- //完成按钮
- //public DelegateCommand AddFinish
- //{
- // get => new DelegateCommand(() =>
- // {
- // if (ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).Count <= 0)
- // {
-
- // AlertMsg alertMsg = new AlertMsg
- // {
- // Message = "请选择药箱",
- // Type = MsgType.SUCCESS,
- // };
- // _eventAggregator.GetEvent().Publish(alertMsg);
- // return;
- // }
- // List jiaojieStocks = new List();
- // List cs = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
- // for (int i = 0; i < cs.Count; i++)
- // {
- // ChannelStock copy = TransExpV2.Trans(cs[i]);
- // jiaojieStocks.Add(copy);
- // }
- // csList = jiaojieStocks.FindAll(cs => cs.ChannelLst.IsSelected).GroupBy(cs => cs.DrugId).Select(g => new
- // {
- // DrugId = g.Key,
- // AddQuantity = g.Sum(s => s.AddQuantity)
- // }).Select(cs => new ChannelStock() { DrugId = cs.DrugId, AddQuantity = cs.AddQuantity }).ToList();
-
- // List channelStocks = new List();
- // List msg = new List();
- // for (int i = 0; i < csList.Count; i++)
- // {
- // List HasQChannels = SqlSugarHelper.Db.Queryable()
- // .Includes(cs => cs.DrugInfo)
- // .Where(cs => cs.Quantity > 0)
- // .Where(cs => cs.DrawerType == 1)
- // .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
- // .Where(cs => cs.DrugId == csList[i].DrugId)
- // .OrderBy(cs => cs.EffDate)
- // .OrderBy(cs => cs.DrawerNo)
- // .ToList();
- // int total = HasQChannels.Sum(it => it.Quantity);
- // int TakeQ = csList[i].AddQuantity;
- // // 说明数量足够
- // if (total >= TakeQ)
- // {
- // for (int j = 0; TakeQ > 0; j++)
- // {
- // ChannelStock stock = HasQChannels[j];
- // if (TakeQ > stock.Quantity)
- // {
- // stock.TakeQuantity = stock.Quantity;
- // channelStocks.Add(stock);
- // TakeQ -= stock.Quantity;
- // }
- // else
- // {
- // stock.TakeQuantity = TakeQ;
- // channelStocks.Add(stock);
- // TakeQ = 0;
- // }
- // }
- // }
- // else
- // {
- // msg.Add($"药品【{ChannelStocks[i].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
- // }
-
- // }
- // if (msg.Count > 0)
- // {
- // DialogParameters dialogParameters = new DialogParameters();
- // dialogParameters.Add("msgInfo", msg);
- // DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
- // return;
-
- // }
- // else
- // {
- // channelStocks.Sort((a, b) =>
- // {
- // if ((a.DrawerNo - b.DrawerNo) == 0)
- // {
- // return a.ColNo - b.ColNo;
- // }
- // return a.DrawerNo - b.DrawerNo;
- // });
- // }
- // List record = channelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
- // if (record.Count > 0)
- // {
- // string InvoiceId = "AddJiaoJie_" + CurrentTimeMillis();
- // var f = SqlSugarHelper.Db.UseTran(() =>
- // {
- // for (int i = 0; i < record.Count; i++)
- // {
- // ChannelStock it = record[i];
- // // 更新数据 库存信息
- // SqlSugarHelper.Db.Updateable(new ChannelStock()
- // {
- // Quantity = it.Quantity - it.TakeQuantity,
- // ManuNo = it.ManuNo,
- // EffDate = it.EffDate,
- // Id = it.Id,
- // }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
-
- // //更新 交接柜 库存信息
- // List jiaojie = jiaojieStocks.Where(cs => cs.DrugId == it.DrugId).ToList();
- // if (jiaojie != null && jiaojie.Count > 0)
- // {
- // for (int j = 0; j < jiaojie.Count; j++)
- // {
- // // 更新数据 交接柜 库存信息
- // ChannelStock jiaojie_it = jiaojie[j];
- // SqlSugarHelper.Db.Updateable(new ChannelStock()
- // {
- // Quantity = jiaojie_it.BaseQuantity,
- // //ManuNo = it.ManuNo,
- // //EffDate = it.EffDate,
- // Id = jiaojie_it.Id,
- // }).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).ExecuteCommand();
- // }
- // }
-
-
- // // 保存数据 出库记录
- // SqlSugarHelper.Db.Insertable(new MachineRecord()
- // {
- // MachineId = it.MachineId,
- // 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,
- // Operator = HomeWindowViewModel.Operator?.Id,
- // Reviewer = HomeWindowViewModel.Reviewer?.Id,
- // OperationTime = DateTime.Now,
- // Quantity = it.TakeQuantity,
- // Type = 2,
- // InvoiceId = InvoiceId
- // }).ExecuteCommand();
- // }
- // return true;
- // });
- // if (f.Data)
- // {
- // // 更新屏显库存
- // List singleChannels = record.FindAll(it => it.BoardType != 5);
- // if (singleChannels.Count > 0)
- // {
- // singleChannels.ForEach(it =>
- // {
- // _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
- // });
- // }
- // AlertMsg alertMsg = new AlertMsg
- // {
- // Message = "补药完成,库存已更新",
- // Type = MsgType.SUCCESS,
- // };
- // _eventAggregator.GetEvent().Publish(alertMsg);
- // RequestData();
- // }
- // if (!f.IsSuccess)
- // {
- // 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);
- // }
- // });
- //}
-
- //取消
- //public DelegateCommand CancleAdd
- //{
- // get => new DelegateCommand(() =>
- // {
- // _portUtil.ResetData();
- // Status = 0;
- // IsEnable = true;
- // CurrentNum = 0;
- // });
- //}
-
-
public DelegateCommand RejectReport_Download
{
get => new DelegateCommand(() =>
@@ -598,17 +268,17 @@ namespace DM_Weight.ViewModels
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
public async void OpenOrderDialog()
{
- if (_ChannelList != null && _ChannelList.channelStocks != null && _ChannelList.State == 0)
+ if (_ChannelList != null && _ChannelList.channelStocks != null && _ChannelList.channelStocks.Any(cs=>cs.State==0))
{
// 此处延时1毫秒,等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
//选中药箱号下的所有药品id
DialogParameters dialogParameters = new DialogParameters();
- dialogParameters.Add("_ChannelStock", _ChannelList.channelStocks);
+ dialogParameters.Add("_ChannelStock", _ChannelList.channelStocks.Where(cs=>cs.State==0).ToList());
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddToJiaoJieDialog", dialogParameters, DoDialogResult, "RootDialog");
}
- if(_ChannelList!=null&& _ChannelList.State == 1)
+ if(_ChannelList!=null)
{
AlertMsg alertMsg = new AlertMsg
{
diff --git a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs
index 692d520..9c68f90 100644
--- a/DM_Weight/ViewModels/CheckStockWindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckStockWindowViewModel.cs
@@ -238,6 +238,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
+ _portUtil.OperateFinish = true;
}
else
{
diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
index a5ce4a4..7ad6476 100644
--- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
@@ -383,6 +383,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
+ _portUtil.OperateFinish = true;
}
else
{
@@ -407,6 +408,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
index ce4b35d..49ae933 100644
--- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
@@ -387,6 +387,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
+ _portUtil.OperateFinish = true;
}
else
{
@@ -411,6 +412,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs
index 5b9cb61..7a6186a 100644
--- a/DM_Weight/ViewModels/HomeWindowViewModel.cs
+++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs
@@ -550,7 +550,7 @@ namespace DM_Weight.ViewModels
{
try
{
- if (!_portUtil.Operate)
+ if (!_portUtil.Operate &&_portUtil.OperateFinish)
{
// 无人操作鼠标键盘
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
diff --git a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
index 4af7337..ef5629a 100644
--- a/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceAddDialogViewModel.cs
@@ -425,7 +425,7 @@ namespace DM_Weight.ViewModels
Status = 0;
_isFinishClick = false;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
-
+ _portUtil.OperateFinish = true;
}
});
@@ -444,6 +444,7 @@ namespace DM_Weight.ViewModels
RequestData();
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
index 2ce137c..08fbfa9 100644
--- a/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceTakeDialogViewModel.cs
@@ -479,6 +479,7 @@ namespace DM_Weight.ViewModels
Status = 0;
_isFinishClick = false;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+ _portUtil.OperateFinish = true;
}
else
{
@@ -508,6 +509,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/LoginWindowViewModel.cs b/DM_Weight/ViewModels/LoginWindowViewModel.cs
index 4f6160c..889cc5c 100644
--- a/DM_Weight/ViewModels/LoginWindowViewModel.cs
+++ b/DM_Weight/ViewModels/LoginWindowViewModel.cs
@@ -1,36 +1,41 @@
-using log4net;
-using log4net.Core;
-using log4net.Repository.Hierarchy;
-using Prism.Commands;
-using Prism.Events;
-using Prism.Ioc;
-using Prism.Mvvm;
-using Prism.Regions;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Configuration;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using DM_Weight.Finger;
+using DM_Weight.Finger;
+using DM_Weight.HIKVISION;
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using DM_Weight.Views;
-using System.Collections.ObjectModel;
+using log4net;
+using log4net.Core;
+using log4net.Repository.Hierarchy;
using Microsoft.Win32;
-using System.Xml;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Mvvm;
+using Prism.Regions;
+using ScreenRecorderLib;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
using System.Diagnostics;
-using DM_Weight.HIKVISION;
+using System.IO;
+using System.Linq;
using System.Security.AccessControl;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Threading;
+using System.Xml;
namespace DM_Weight.ViewModels
{
public class LoginWindowViewModel : BindableBase, IRegionMemberLifetime, IConfirmNavigationRequest
{
+
+
private readonly ILog logger = LogManager.GetLogger(typeof(LoginWindowViewModel));
private string username;
@@ -357,6 +362,8 @@ _exitCommand ??= new DelegateCommand(Exit);
void Exit()
{
+ //清录屏进程
+ _eventAggregator.GetEvent().Publish(2);
//_chkFunction.HIKLoginOut();
Process.GetCurrentProcess().Kill();
Environment.Exit(0);
@@ -463,8 +470,10 @@ _exitCommand ??= new DelegateCommand(Exit);
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
- //FingerMsg = !_fingerprintUtil.bIsConnected;
+ FingerMsg = !_fingerprintUtil.bIsConnected;
_eventAggregator.GetEvent().Subscribe(LoginEvent);
+ //结束录屏
+ _eventAggregator.GetEvent().Publish(0);
}
@@ -478,6 +487,11 @@ _exitCommand ??= new DelegateCommand(Exit);
public void OnNavigatedFrom(NavigationContext navigationContext)
{
_eventAggregator.GetEvent().Unsubscribe(LoginEvent);
+
+ #region 录屏
+ //登录进来后开始录屏
+ _eventAggregator.GetEvent().Publish(1);
+ #endregion
}
//手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
public string ReadAppSetting(string key)
@@ -489,5 +503,6 @@ _exitCommand ??= new DelegateCommand(Exit);
XmlNode node = doc.SelectSingleNode(xPath);
return node.Attributes["value"].Value.ToString();
}
+
}
}
diff --git a/DM_Weight/ViewModels/MainWindowViewModel.cs b/DM_Weight/ViewModels/MainWindowViewModel.cs
index 59c71da..7a93d39 100644
--- a/DM_Weight/ViewModels/MainWindowViewModel.cs
+++ b/DM_Weight/ViewModels/MainWindowViewModel.cs
@@ -1,26 +1,38 @@
-using MaterialDesignThemes.Wpf;
+using DM_Weight.Finger;
+using DM_Weight.HIKVISION;
+using DM_Weight.msg;
+using DM_Weight.Port;
+using DM_Weight.util;
+using DM_Weight.Views;
+using log4net;
+using log4net.Repository.Hierarchy;
+using MaterialDesignThemes.Wpf;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
+using ScreenRecorderLib;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
-using DM_Weight.msg;
-using DM_Weight.Port;
-using DM_Weight.util;
-using DM_Weight.Finger;
-using DM_Weight.Views;
using Unity;
-using DM_Weight.HIKVISION;
namespace DM_Weight.ViewModels
{
internal class MainWindowViewModel : BindableBase
{
+ #region 录屏相关
+ public Recorder _recorder;
+ private string _outputFolder;
+ private string _outputFilePath;
+ public static MainWindowViewModel vm;
+ #endregion
+ private readonly ILog logger = LogManager.GetLogger(typeof(MainWindowViewModel));
+
private string _title = "Prism App"; //标题
private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
@@ -66,9 +78,11 @@ namespace DM_Weight.ViewModels
//private CHKFunction _cHKFunction;
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil)
{
+ vm = this;
//_portUtil = portUtil;
this.eventAggregator = eventAggregator;
this.eventAggregator.GetEvent().Subscribe(doMyPrismEvent2);
+ this.eventAggregator.GetEvent().Subscribe(PrintScreen);
_screenUtil = screenUtil;
_fingerprintUtil = fingerprintUtil;
_regionManager = regionManager;
@@ -106,5 +120,90 @@ namespace DM_Weight.ViewModels
SnackbarMessageQueue.Enqueue(msg.Message);
}
+ #region 录屏
+ ///
+ /// 录屏事件
+ ///
+ /// 0停止录屏;1开始录屏;2退出软件清进程
+ void PrintScreen(int type)
+ {
+ if(type==0)
+ {
+ StopPrintScreen();
+ //删除7天前的录屏文件
+
+ if (Directory.Exists(_outputFolder))
+ {
+ var files = Directory.GetFiles(_outputFolder);
+ foreach (var file in files)
+ {
+ var fileInfo = new FileInfo(file);
+ if (fileInfo.CreationTime < DateTime.Now.AddDays(-7))
+ {
+ try
+ {
+ fileInfo.Delete();
+ }
+ catch (Exception ex)
+ {
+ logger.Error($"删除录屏文件失败: {ex.Message}");
+ }
+ }
+ }
+ }
+ }
+ else if (type == 1)
+ {
+ StartPrintScreen();
+ }
+ else if (type == 2)
+ {
+ _recorder?.Dispose();
+ }
+ }
+ #endregion
+ void StopPrintScreen()
+ {
+
+ //退出登录结束录屏
+ _recorder?.Stop();
+ }
+ //录屏
+ void StartPrintScreen()
+ {
+
+ // 创建输出目录
+ _outputFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "Log", "ScreenRecordings");
+ if (!Directory.Exists(_outputFolder))
+ {
+ Directory.CreateDirectory(_outputFolder);
+ }
+ // 生成输出文件名
+ string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
+ _outputFilePath = Path.Combine(_outputFolder, $"{timestamp}.mp4");
+
+ // 设置录制选项
+ var options = new RecorderOptions();
+
+ // 创建录制器实例
+ _recorder = Recorder.CreateRecorder(options);
+
+ // 设置事件处理
+ _recorder.OnRecordingComplete += Recorder_OnRecordingComplete;
+ _recorder.OnRecordingFailed += Recorder_OnRecordingFailed;
+
+ // 开始录制
+ _recorder.Record(_outputFilePath);
+ }
+ //录制失败
+ private void Recorder_OnRecordingFailed(object sender, RecordingFailedEventArgs e)
+ {
+ logger.Info($"录制失败: {e.Error}");
+ }
+ //录制完成
+ private void Recorder_OnRecordingComplete(object sender, RecordingCompleteEventArgs e)
+ {
+ logger.Info($"录制完成: {e.FilePath}");
+ }
}
}
diff --git a/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs
index ccd3e7e..4aa139c 100644
--- a/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/MultiOrderTakeDialogViewModel.cs
@@ -444,6 +444,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
+ _portUtil.OperateFinish = true;
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@@ -464,6 +465,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
index 353e3d7..7dd89c4 100644
--- a/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderReturnDialogViewModel.cs
@@ -459,7 +459,8 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent().Publish(alertMsg);
}
Status = 0;
- _isFinishClick = false;
+ _isFinishClick = false;
+ _portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
//}
//else
@@ -490,6 +491,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
index 33b5e9d..4f1da94 100644
--- a/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDialogViewModel.cs
@@ -497,6 +497,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
+ _portUtil.OperateFinish = true;
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@@ -528,6 +529,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
index 4d7cbf9..5c7e013 100644
--- a/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
+++ b/DM_Weight/ViewModels/ReturnDrugDialogViewModel.cs
@@ -398,6 +398,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
IsFinishClick = false;
+ _portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}, () => !IsFinishClick && ReturnQuantity > 0).ObservesProperty(() => IsFinishClick).ObservesProperty(() => ReturnQuantity);
@@ -416,6 +417,7 @@ namespace DM_Weight.ViewModels
IsFinishClick = false;
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs b/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
index f1164ae..d256d4a 100644
--- a/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
+++ b/DM_Weight/ViewModels/ReturnEmptyDialogViewModel.cs
@@ -334,6 +334,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
IsFinishClick = false;
+ _portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
} else
{
@@ -361,6 +362,7 @@ namespace DM_Weight.ViewModels
IsFinishClick = false;
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
index cb4a3af..713d7af 100644
--- a/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfAddDialogViewModel.cs
@@ -412,7 +412,8 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent().Publish(alertMsg);
}
Status = 0;
- _isFinishClick = false;
+ _isFinishClick = false;
+ _portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@@ -433,6 +434,7 @@ namespace DM_Weight.ViewModels
RequestData();
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
index cf16785..493dcf6 100644
--- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
@@ -383,6 +383,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
+ _portUtil.OperateFinish = true;
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@@ -402,6 +403,7 @@ namespace DM_Weight.ViewModels
{
_portUtil.ResetData();
Status = 0;
+ _portUtil.OperateFinish = true;
});
}
diff --git a/DM_Weight/Views/AddToJiaoJieWindow.xaml b/DM_Weight/Views/AddToJiaoJieWindow.xaml
index 14e0ba8..de40c9f 100644
--- a/DM_Weight/Views/AddToJiaoJieWindow.xaml
+++ b/DM_Weight/Views/AddToJiaoJieWindow.xaml
@@ -263,9 +263,21 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DM_Weight/Views/Dialog/AddToJiaoJieNewDialog.xaml.cs b/DM_Weight/Views/Dialog/AddToJiaoJieNewDialog.xaml.cs
deleted file mode 100644
index 0c7eebd..0000000
--- a/DM_Weight/Views/Dialog/AddToJiaoJieNewDialog.xaml.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-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.Dialog
-{
- ///
- /// AddToJiaoJieNewDialog.xaml 的交互逻辑
- ///
- public partial class AddToJiaoJieNewDialog : UserControl
- {
- public AddToJiaoJieNewDialog()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/DM_Weight/Views/MainWindow.xaml.cs b/DM_Weight/Views/MainWindow.xaml.cs
index 73ee566..057a3dd 100644
--- a/DM_Weight/Views/MainWindow.xaml.cs
+++ b/DM_Weight/Views/MainWindow.xaml.cs
@@ -1,6 +1,10 @@
-using Prism.Events;
+using DM_Weight.msg;
+using DM_Weight.util;
+using DM_Weight.ViewModels;
+using Prism.Events;
using Prism.Ioc;
using Prism.Regions;
+using ScreenRecorderLib;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -16,8 +20,6 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Unity;
using Unity.Lifetime;
-using DM_Weight.msg;
-using DM_Weight.util;
namespace DM_Weight.Views
{
@@ -28,9 +30,11 @@ namespace DM_Weight.Views
{
//IRegionManager _regionManager;
//IUnityContainer _container;
+ MainWindowViewModel vms;
public MainWindow()
{
InitializeComponent();
+ vms = MainWindowViewModel.vm;
//_regionManager = regionManager;
//_container = container;
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
@@ -42,6 +46,11 @@ namespace DM_Weight.Views
//}));
}
+ protected override void OnClosed(EventArgs e)
+ {
+ vms._recorder?.Dispose();
+ base.OnClosed(e);
+ }
}
}
diff --git a/DM_Weight/msg/PrintScreenEvent.cs b/DM_Weight/msg/PrintScreenEvent.cs
new file mode 100644
index 0000000..c351a0b
--- /dev/null
+++ b/DM_Weight/msg/PrintScreenEvent.cs
@@ -0,0 +1,14 @@
+using DM_Weight.Models;
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.msg
+{
+ internal class PrintScreenEvent : PubSubEvent
+ {
+ }
+}