修改录屏方式

This commit is contained in:
马巧 2025-07-21 15:24:38 +08:00
parent 3e34ffe912
commit 9915812808
18 changed files with 784 additions and 224 deletions

View File

@ -37,12 +37,12 @@
<!-- 按处方还药或者按取药记录还药 1:处方ReturnDrugWindow22药品ReturnDrugWindow-->
<add key="returnDrugMode" value="1" />
<!-- 自动退出时间单位秒为0时不自动退出 -->
<add key="autoExit" value="10"/>
<add key="autoExit" value="0"/>
<!-- 无操作退出录像时间单位秒为0时不退出录像 -->
<add key="stopRecord" value="180"/>
<add key="gridConnectionString" value="MYSQL; Database=xiangtan_mazuike; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
<add key="gridConnectionString" value="MYSQL; Database=xiangtanTest; Password=root; Port=3306; Server=192.168.50.84; User=root;"/>
<!-- 查询处方是orderNo还是orderGroupNo -->
<add key="OrderNoName" value="orderNo" />
<!-- 后门耗材板地址 没有则填写0-->

View File

@ -266,6 +266,8 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation<EmptyWindow, EmptyWindowViewModel>();
//紧急开锁页面
containerRegistry.RegisterForNavigation<EmergencyWindow, EmergencyWindowViewModel>();
//交接柜加药页面
containerRegistry.RegisterForNavigation<AddToJiaoJieNewWindow, AddToJiaoJieNewWindowViewModel>();
}

View File

@ -71,7 +71,6 @@
<PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Prism.Unity" Version="8.1.97" />
<PackageReference Include="ScreenRecorderLib" Version="6.5.1" />
<PackageReference Include="SharpPromise" Version="1.7.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
<PackageReference Include="SuperSimpleTcp" Version="3.0.10" />

View File

@ -112,7 +112,7 @@ namespace DM_Weight.Models
[SugarColumn(IsIgnore = true)]
public string Location
{
get => ColNo == 0 ? DrawerNo + "号交接柜" :ColNo==-1?"未绑定": ColNo == -2 ? "库存不足" : DrawerNo + "-" + ColNo;
get => ColNo == 0 ? DrawerNo + "号交接柜" :ColNo==-1?"未绑定/无库存": ColNo == -2 ? "库存不足" : DrawerNo + "-" + ColNo;
}
private int _addQuantity = 0;

View File

@ -94,7 +94,9 @@ namespace DM_Weight.Models
set { SetProperty(ref _base, value); }
}
//交接柜补药弹窗对应的需补药数
[SugarColumn(IsIgnore = true)]
public int? NeedQuantity { get; set; }
}
}

View File

@ -9,6 +9,7 @@ using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
@ -24,6 +25,13 @@ namespace DM_Weight.ViewModels
public class AddToJiaoJieDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
private List<DrugInfo> _drugInfoList = new List<DrugInfo>();
public List<DrugInfo> _DrugInfoList
{
get => _drugInfoList;
set => SetProperty(ref _drugInfoList, value);
}
private List<ChannelStock> _channelStocks = new List<ChannelStock>();
@ -52,12 +60,12 @@ namespace DM_Weight.ViewModels
/// <summary>
/// 交接柜的库位信息
/// </summary>
private ChannelStock _jiaojei_cs;
private ChannelStock _jiaojie_cs;
public ChannelStock Jiaojie_cs
{
get => _jiaojei_cs;
set => SetProperty(ref _jiaojei_cs, value);
get => _jiaojie_cs;
set => SetProperty(ref _jiaojie_cs, value);
}
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
@ -209,12 +217,14 @@ namespace DM_Weight.ViewModels
}
public async void RequestData()
{
List<ChannelStock> channelStocks = new List<ChannelStock>();
List<string> msg = new List<string>();
//List<ChannelStock> channelStocks = new List<ChannelStock>();
List<DrugInfo> drugList = new List<DrugInfo>();
for (int i = 0; i < ChannelStocks.Count; i++)
{
DrugInfo drug = ChannelStocks[i].DrugInfo;
drug.NeedQuantity = ChannelStocks[i].AddQuantity;
List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
//.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM3"))
@ -222,11 +232,6 @@ namespace DM_Weight.ViewModels
//.OrderBy(cs => cs.EffDate)
.OrderBy(cs => new { cs.EffDate, cs.DrawerNo, cs.ColNo })
.ToList();
//if (HasQChannels == null || HasQChannels.Count <= 0)
//{
// msg.Add($"有药品未绑定,请先绑定");
// continue;
//}
if (HasQChannels != null && HasQChannels.Count > 0)
{
int total = HasQChannels.Sum(it => it.Quantity);
@ -234,37 +239,42 @@ namespace DM_Weight.ViewModels
// 说明数量足够
//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;
// }
//}
int hadTakeQ = 0;
for (int j = 0; j < HasQChannels.Count; j++)
//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)
{
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;
}
HasQChannels[j].TakeQuantity = HasQChannels[j].Quantity;
hadTakeQ += HasQChannels[j].Quantity;
}
channelStocks.AddRange(HasQChannels);
else
{
HasQChannels[j].TakeQuantity = ChannelStocks[i].AddQuantity - hadTakeQ;
break;
}
}
if (drug.channelStocks == null)
{
drug.channelStocks = new List<ChannelStock>();
}
drug.channelStocks.AddRange(HasQChannels);
//}
//else
//{
@ -287,31 +297,13 @@ namespace DM_Weight.ViewModels
channel.ManuNo = null;
channel.EffDate = null;
channel.TakeQuantity = 0;
channelStocks.Add(channel);
if (drug.channelStocks == null)
{
drug.channelStocks = new List<ChannelStock>();
}
drug.channelStocks.Add(channel);
}
}
if (msg.Count > 0)
{
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
//MessageBox.Show(string.Join("\n", msg));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("msgInfo", msg);
DialogServiceExtensions.ShowDialogHost(_dialogService, "ShowMessageDialog", dialogParameters, "RootDialog");
}
else
{
//channelStocks.Sort((a, b) =>
//{
// if ((a.DrawerNo - b.DrawerNo) == 0)
// {
// return a.ColNo - b.ColNo;
// }
// return a.DrawerNo - b.DrawerNo;
//});
ChannelStocks = channelStocks;
_DrugInfoList.Add(drug);
}
}
public DelegateCommand OpenDrawer
@ -323,7 +315,7 @@ namespace DM_Weight.ViewModels
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
{
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开其他6层管理员才能开
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 2).Any();
bool bDrawer = _DrugInfoList.Where(di => di.channelStocks.Select(it => it.DrawerNo).Where(n => n > 2).Any()).Count() > 0;
if (bDrawer)
{
AlertMsg alertMsg = new AlertMsg
@ -336,7 +328,9 @@ namespace DM_Weight.ViewModels
}
}
enumerable = ChannelStocks.Where(cs => cs.TakeQuantity > 0).GroupBy(cs => cs.DrawerNo, cs => cs);
enumerable = _DrugInfoList.SelectMany(di => di.channelStocks).Where(cs => cs.TakeQuantity > 0).GroupBy(cs => cs.DrawerNo, cs => cs);
// enumerable = ChannelStocks.Where(cs => cs.TakeQuantity > 0).GroupBy(cs => cs.DrawerNo, cs => cs);
if (enumerable != null && enumerable.Count() > 0)
{
enumerator = enumerable.GetEnumerator();
@ -410,12 +404,12 @@ namespace DM_Weight.ViewModels
_isFinishClick = true;
List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
List<ChannelStock> record = _DrugInfoList.SelectMany(di => di.channelStocks).Where(cs => cs.TakeQuantity > 0).ToList();
if (record.Count > 0)
{
//交接柜需要补药数量与加药数量对比,数量不一致则提示
var jjSum = from item in Jiaojie_ChannelStocks orderby item.DrugId group item by item.DrugId into g select new { DrugId = g.Key, Quantity = g.Sum(item => item.NeedNum) };
var jjSum = from item in Jiaojie_ChannelStocks orderby item.DrugId group item by item.DrugId into g select new { DrugId = g.Key, Quantity = g.Sum(item => item.AddQuantity) };
var csSum = from item in record orderby item.DrugId group item by item.DrugId into g select new { DrugId = g.Key, Quantity = g.Sum(item => item.TakeQuantity) };
foreach (var jjItem in jjSum)
@ -476,14 +470,30 @@ namespace DM_Weight.ViewModels
for (int i = 0; i < Jiaojie_ChannelStocks.Count; i++)
{
ChannelStock jiaoStock = Jiaojie_ChannelStocks[i];
List<ChannelStock> csStockList = record.Where(cs => cs.DrugId == Jiaojie_ChannelStocks[i].DrugId && cs.TakeQuantity > 0).ToList();
List<ChannelStock> csStockList = record.Where(cs => cs.DrugId == jiaoStock.DrugId && cs.TakeQuantity > 0).ToList();
if (csStockList != null && csStockList.Count > 0)
{
int jjNeedQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.MachineId == jiaoStock.MachineId).Sum(cs => cs.NeedNum);
int jjNeedQuantity = jiaoStock.AddQuantity;// SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == jiaoStock.DrawerNo && cs.DrugId == jiaoStock.DrugId && cs.MachineId == jiaoStock.MachineId).Sum(cs => (cs.BaseQuantity-cs.Quantity));
SqlSugarHelper.Db.Deleteable<ChannelStock>().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++)
{
// 保存数据 记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = jiaoStock.MachineId,
DrawerNo = jiaoStock.DrawerNo,
DrugId = jiaoStock.DrugId,
ManuNo = csStockList[i].ManuNo,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = csStockList[i].TakeQuantity,
Type = 55,
Status = 2,//给交接柜补药不用还空瓶等真正用了以后再还空瓶所以先把状态置为2
InvoiceId = $"毒麻柜{csStockList[i].Location}给交接柜{jiaoStock.DrawerNo}补药"
}).ExecuteCommand();
ChannelStock csStock = (ChannelStock)csStockList[j].Clone();
ChannelStock jjStockManuNo = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.DrawerNo == Jiaojie_ChannelStocks[i].DrawerNo && cs.DrugId == Jiaojie_ChannelStocks[i].DrugId && cs.ManuNo == csStock.ManuNo && cs.MachineId == "DM5").First();
@ -491,9 +501,9 @@ namespace DM_Weight.ViewModels
if (jjStockManuNo != null)
{
int addNum = csStock.TakeQuantity;
logger.Info($"需补药数{Jiaojie_ChannelStocks[i].NeedNum},该批次取药数{csStock.TakeQuantity}");
logger.Info($"需补药数{Jiaojie_ChannelStocks[i].AddQuantity},该批次取药数{csStock.TakeQuantity}");
//有该批次
if (Jiaojie_ChannelStocks[i].NeedNum > csStock.TakeQuantity)
if (Jiaojie_ChannelStocks[i].AddQuantity > csStock.TakeQuantity)
{
//不够取
ChannelStock newStock = new ChannelStock();
@ -512,7 +522,7 @@ namespace DM_Weight.ViewModels
UpdateJJStock.Add(newStock);
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
csStockList[j].TakeQuantity = 0;
Jiaojie_ChannelStocks[i].NeedNum = Jiaojie_ChannelStocks[i].NeedNum - csStock.TakeQuantity;
Jiaojie_ChannelStocks[i].AddQuantity = Jiaojie_ChannelStocks[i].AddQuantity - csStock.TakeQuantity;
}
else
{
@ -530,7 +540,7 @@ namespace DM_Weight.ViewModels
newStock.EffDate = Jiaojie_ChannelStocks[i].EffDate;
newStock.DrawerNo = Jiaojie_ChannelStocks[i].DrawerNo;
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].NeedNum;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].AddQuantity;
newStock.Id = jjStockManuNo.Id;
newStock.State = 1;
//newStock.MachineId = jiaoStock.MachineId;
@ -538,14 +548,14 @@ namespace DM_Weight.ViewModels
//newStock.Quantity = jiaoStock.Quantity + csStock.TakeQuantity;
UpdateJJStock.Add(newStock);
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
csStockList[j].TakeQuantity = csStock.TakeQuantity - Jiaojie_ChannelStocks[i].NeedNum;
Jiaojie_ChannelStocks[i].NeedNum = 0;
csStockList[j].TakeQuantity = csStock.TakeQuantity - Jiaojie_ChannelStocks[i].AddQuantity;
Jiaojie_ChannelStocks[i].AddQuantity = 0;
break;
}
}
else //没有该批次
{
if (Jiaojie_ChannelStocks[i].NeedNum > csStock.TakeQuantity)
if (Jiaojie_ChannelStocks[i].AddQuantity > csStock.TakeQuantity)
{
//不够取
ChannelStock newStock = new ChannelStock();
@ -559,10 +569,10 @@ namespace DM_Weight.ViewModels
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = Jiaojie_ChannelStocks[i].MachineId;
newStock.DrawerType = 1;
newStock.NeedNum = 0;
newStock.AddQuantity = 0;
newStock.State = 1;
AddJJStock.Add(newStock);
Jiaojie_ChannelStocks[i].NeedNum = Jiaojie_ChannelStocks[i].NeedNum - csStock.TakeQuantity;
Jiaojie_ChannelStocks[i].AddQuantity = Jiaojie_ChannelStocks[i].AddQuantity - csStock.TakeQuantity;
csStockList[j].CheckQuantity = csStockList[j].TakeQuantity;
csStockList[j].TakeQuantity = 0;
}
@ -576,8 +586,8 @@ namespace DM_Weight.ViewModels
newStock.DrugId = Jiaojie_ChannelStocks[i].DrugId;
newStock.ManuNo = csStock.ManuNo;
newStock.EffDate = csStock.EffDate;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].NeedNum;
newStock.NeedNum = 0;
newStock.AddToJJNum = Jiaojie_ChannelStocks[i].AddQuantity;
newStock.AddQuantity = 0;
newStock.Id = Guid.NewGuid().ToString();
newStock.MachineId = Jiaojie_ChannelStocks[i].MachineId;
newStock.DrawerType = 1;
@ -589,18 +599,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<ChannelStock>()
.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();
//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<ChannelStock>()
.SetColumns(cs => new ChannelStock() { 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();
}
}
//保存交接柜数据
@ -611,7 +621,7 @@ namespace DM_Weight.ViewModels
{
var ret = jj.First();
ret.AddToJJNum = jj.Sum(itx => itx.AddToJJNum);
ret.NeedNum = 0;
//ret.NeedNum = 0;
return ret;
}).ToList();
SqlSugarHelper.Db.Insertable(AddJJStock).ExecuteCommand();
@ -623,7 +633,7 @@ namespace DM_Weight.ViewModels
{
var ret = jj.First();
ret.AddToJJNum = jj.Sum(itx => itx.AddToJJNum);
ret.NeedNum = 0;
//ret.NeedNum = 0;
return ret;
}).ToList();
for (int i = 0; i < UpdateJJStock.Count; i++)
@ -716,7 +726,7 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
Status = 0;
_isFinishClick = false;
_isFinishClick = false;
_portUtil.OperateFinish = true;
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));

View File

@ -0,0 +1,241 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
internal class AddToJiaoJieNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(AddToJiaoJieWindowViewModel));
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public bool KeepAlive => false;
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public void OnNavigatedFrom(NavigationContext navigationContext)
{
// 取消消息订阅
//_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
//_eventAggregator.GetEvent<IsSelectedEvent>().Unsubscribe(SetIsSelected);
}
private List<ChannelStock>? channelStocks;
public List<ChannelStock>? ChannelStocks
{
get => channelStocks;
set => SetProperty(ref channelStocks, value);
}
private ChannelStock _channelStock;
public ChannelStock _ChannelStock
{
get => _channelStock;
set => SetProperty(ref _channelStock, value);
}
private List<ChannelStock>? _channelStocksList;
public List<ChannelStock>? _ChannelStocksList
{
get => _channelStocksList;
set => SetProperty(ref _channelStocksList, value);
}
private List<ChannelList>? _channelLists;
public List<ChannelList>? _ChannelLists
{
get => _channelLists;
set => SetProperty(ref _channelLists, value);
}
private ChannelList _channelList;
public ChannelList _ChannelList
{
get => _channelList;
set => SetProperty(ref _channelList, value);
}
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
}
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
public AddToJiaoJieNewWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
_dialogService = DialogService;
}
private void RequestData()
{
ChannelStocks?.Clear();
_ChannelLists?.Clear();
//1)查询channel_stock所有要补药的药箱
ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<ChannelList>(cs => cs.ChannelLst)
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5"))
.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 = ret.BaseQuantity-it.Sum(itx => itx.Quantity);
return ret;
}).Where(it => it.BaseQuantity > it.Quantity)
.ToList();
if (ChannelStocks != null && ChannelStocks.Count > 0)
{
ChannelStocks.ForEach(cs => cs.AddQuantity =cs.BaseQuantity- cs.Quantity);
//2)查询channel_list将1中查询的添加到channel_list的channel_stock里供页面呈现显示
List<int> DrawerNoList = ChannelStocks.Select(cs => cs.DrawerNo).Distinct().ToList();
List<ChannelList> channelLists = new List<ChannelList>();
for (int i = 0; i < DrawerNoList.Count; i++)
{
var channelList = SqlSugarHelper.Db.Queryable<ChannelList>()
.Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && cl.DrawerNo == DrawerNoList[i])
.OrderBy(cl => cl.Id)
.OrderBy(cl => cl.DrawerNo)
.First();
if (channelList.channelStocks == null)
{
channelList.channelStocks = new List<ChannelStock>();
}
channelList.channelStocks.AddRange(ChannelStocks.Where(cs => cs.DrawerNo == DrawerNoList[i]).ToList());
if (channelList != null)
{
//if (channelList.channelStocks[0].AddToJJNum>0)
// channelList.State=1; //表示有补药
channelLists.Add(channelList);
}
}
_ChannelLists = channelLists;
}
else
{
_ChannelLists?.Clear();
_ChannelLists = new List<ChannelList>();
}
}
private int _status = 0;
public int Status { get => _status; set => SetProperty(ref _status, value); }
private bool _isEnable = true;
public bool IsEnable { get => _isEnable; set => SetProperty(ref _isEnable, value); }
private List<int> iDrawerNoLst
{ get; set; }
private int CurrentNum { get; set; }
//刷新
public DelegateCommand QueryCommand
{
get => new DelegateCommand(() => RequestData());
}
public DelegateCommand RejectReport_Download
{
get => new DelegateCommand(() =>
{
//GridReportUtil.RejectionReport("");
});
}
public DelegateCommand Account_Download
{
get => new DelegateCommand(() =>
{
//GridReportUtil.AccountNewReport();
});
}
private List<ChannelStock> csList = new List<ChannelStock>();
//取药 弹出出药列表
public DelegateCommand TakeDrugCommand
{
get => new DelegateCommand(async () =>
{
csList = _ChannelList.channelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
if (csList != null && csList.Count > 0)
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("_ChannelStock", csList);
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddToJiaoJieDialog", dialogParameters, DoDialogResult, "RootDialog");
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"未选择药品,请先点选药箱号",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
_portUtil.Operate = false;
}
});
}
private void DoDialogResult(IDialogResult dialogResult)
{
RequestData();
}
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
public async void OpenOrderDialog()
{
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.Where(cs => cs.State == 0).ToList());
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddToJiaoJieDialog", dialogParameters, DoDialogResult, "RootDialog");
}
if (_ChannelList != null)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"药品已取出,待入库",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
}
}

View File

@ -96,7 +96,7 @@ namespace DM_Weight.ViewModels
ChannelStocks = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<ChannelList>(cs => cs.ChannelLst)
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5") && (cs.NeedNum > 0 || cs.AddToJJNum > 0))
.Where(cs => cs.MachineId == (ConfigurationManager.AppSettings["jj_machineId"] ?? "DM5"))
.OrderBy(cs => cs.Chnguid)
.OrderBy(cs => cs.DrawerNo)
.ToList();
@ -105,16 +105,16 @@ namespace DM_Weight.ViewModels
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.NeedNum = it.Sum(itx => itx.NeedNum);
//ret.NeedNum = it.Sum(itx => itx.NeedNum);
return ret;
}).Where(it => it.BaseQuantity > it.Quantity)
.ToList();
if (ChannelStocks != null && ChannelStocks.Count > 0)
{
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.NeedNum);
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity-cs.Quantity);
//2)查询channel_list将1中查询的添加到channel_list的channel_stock里供页面呈现显示
List<int> DrawerNoList = ChannelStocks.Select(cs => cs.DrawerNo).Distinct().ToList();
List<int> DrawerNoList = ChannelStocks.Select(cs => cs.DrawerNo).Distinct().OrderBy(cs=>cs).ToList();
List<ChannelList> channelLists = new List<ChannelList>();
for (int i = 0; i < DrawerNoList.Count; i++)
{
@ -127,7 +127,7 @@ namespace DM_Weight.ViewModels
{
channelList.channelStocks = new List<ChannelStock>();
}
channelList.channelStocks.AddRange(ChannelStocks.Where(cs => cs.DrawerNo == DrawerNoList[i]&&(cs.NeedNum>0||cs.AddToJJNum>0)).ToList());
channelList.channelStocks.AddRange(ChannelStocks.Where(cs => cs.DrawerNo == DrawerNoList[i]).ToList());
if (channelList != null)
{
//if (channelList.channelStocks[0].AddToJJNum>0)

View File

@ -349,6 +349,8 @@ namespace DM_Weight.ViewModels
IEventAggregator _eventAggregator;
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator)
{
logger.Info("HomeWindowViewModel");
_portUtil = portUtil;
_regionManager = iRegionManager;
_dialogService = dialogService;

View File

@ -14,7 +14,6 @@ using Prism.Events;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Regions;
using ScreenRecorderLib;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -471,6 +470,7 @@ _exitCommand ??= new DelegateCommand(Exit);
public void OnNavigatedTo(NavigationContext navigationContext)
{
FingerMsg = !_fingerprintUtil.bIsConnected;
logger.Info("OnNavigatedTo");
_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
//结束录屏
_eventAggregator.GetEvent<PrintScreenEvent>().Publish(0);
@ -486,8 +486,9 @@ _exitCommand ??= new DelegateCommand(Exit);
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<FingerprintEvent>().Unsubscribe(LoginEvent);
_eventAggregator.GetEvent<FingerprintEvent>().Unsubscribe(LoginEvent);
logger.Info("OnNavigatedFrom");
#region
//登录进来后开始录屏
_eventAggregator.GetEvent<PrintScreenEvent>().Publish(1);

View File

@ -11,7 +11,6 @@ using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using ScreenRecorderLib;
using System;
using System.Collections.Generic;
using System.IO;
@ -26,10 +25,10 @@ namespace DM_Weight.ViewModels
internal class MainWindowViewModel : BindableBase
{
#region
public Recorder _recorder;
//public Recorder _recorder;
private string _outputFolder;
private string _outputFilePath;
public static MainWindowViewModel vm;
//public static MainWindowViewModel vm;
#endregion
private readonly ILog logger = LogManager.GetLogger(typeof(MainWindowViewModel));
@ -76,9 +75,10 @@ namespace DM_Weight.ViewModels
IRegionManager _regionManager;
IUnityContainer _container;
//private CHKFunction _cHKFunction;
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil)
FFmpegHelper fFmpegHelper;
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil, FFmpegHelper fFmpegHelper)
{
vm = this;
//vm = this;
//_portUtil = portUtil;
this.eventAggregator = eventAggregator;
this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
@ -101,6 +101,7 @@ namespace DM_Weight.ViewModels
}
}));
this.fFmpegHelper = fFmpegHelper;
}
void doMyPrismEvent2(AlertMsg msg)
@ -127,83 +128,97 @@ namespace DM_Weight.ViewModels
/// <param name="type">0停止录屏1开始录屏2退出软件清进程</param>
void PrintScreen(int type)
{
if(type==0)
logger.Info($"录屏事件PrintScreen{type}");
if (type == 0)
{
StopPrintScreen();
//删除7天前的录屏文件
fFmpegHelper.stopFlag = true;
fFmpegHelper.StopRecording();
//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}");
}
}
}
}
//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.Info($"删除录屏文件失败: {ex.Message}");
// }
// }
// }
//}
}
else if (type == 1)
{
StartPrintScreen();
fFmpegHelper.stopFlag = false;
// 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}.webm");
fFmpegHelper.StartRecording(_outputFilePath, 25);
}
else if (type == 2)
{
_recorder?.Dispose();
// _recorder?.Dispose();
}
}
#endregion
void StopPrintScreen()
{
//void StopPrintScreen()
//{
//退出登录结束录屏
_recorder?.Stop();
}
//录屏
void StartPrintScreen()
{
// //退出登录结束录屏
// _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");
// // 创建输出目录
// _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();
// // 设置录制选项
// var options = new RecorderOptions();
// 创建录制器实例
_recorder = Recorder.CreateRecorder(options);
// // 创建录制器实例
// _recorder = Recorder.CreateRecorder(options);
// 设置事件处理
_recorder.OnRecordingComplete += Recorder_OnRecordingComplete;
_recorder.OnRecordingFailed += Recorder_OnRecordingFailed;
// // 设置事件处理
// _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}");
}
// // 开始录制
// _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}");
//}
}
}

View File

@ -0,0 +1,165 @@
<UserControl x:Class="DM_Weight.Views.AddToJiaoJieNewWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:prism="http://prismlibrary.com/"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</UserControl.Resources>
<Grid>
<Grid.Resources>
<!--<CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="ChannelLst" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>-->
<convert:GroupSumConverter x:Key="GroupSumConverter" />
<convert:TotalCountConverter x:Key="TotalCountConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
<convert:StockStatusConverter x:Key="StockStatusConverter" />
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Visibility="Collapsed"
Margin="3 0 3 0"
VerticalAlignment="Center"
Command="{Binding RejectReport_Download}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="注射剂报表" />
<Button Visibility="Collapsed"
Margin="3 0 3 0"
VerticalAlignment="Center"
Command="{Binding Account_Download}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="账册报表" />
<Button
Margin="6 0 6 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="刷新" Command="{Binding QueryCommand}">
<materialDesign:PackIcon
Kind="Refresh" />
</Button>
</StackPanel>
</Grid>
<ListView Grid.ColumnSpan="2"
Padding="0 6 0 0" Grid.Row="1"
ItemsSource="{Binding _ChannelLists, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectedItem="{Binding _ChannelList}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
materialDesign:ListViewAssist.ListViewItemPadding="13">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Foreground" Value="White" />
</Style>
</ListView.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding RowSelected}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding DrawerNo}"
Header="药箱号"/>
<GridViewColumn Header="药品名称" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.DrugName" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="厂家" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.Manufactory" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="规格" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="DrugInfo.DrugSpec" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="基数" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="BaseQuantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="需补药数" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="AddQuantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="130"
Header="状态">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" materialDesign:ListBoxItemAssist.ShowSelection="False">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="130" Text="{Binding State,Converter={StaticResource StockStatusConverter},ConverterParameter=TextState}">
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
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
{
/// <summary>
/// AddToJiaoJieNewWindow.xaml 的交互逻辑
/// </summary>
public partial class AddToJiaoJieNewWindow : UserControl
{
public AddToJiaoJieNewWindow()
{
InitializeComponent();
}
}
}

View File

@ -259,7 +259,7 @@
<GridViewColumn Header="需补药数" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="NeedNum" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="AddQuantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

View File

@ -37,7 +37,7 @@
<materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
</Button>
</Grid>
<DataGrid Grid.Row="1" ItemsSource="{Binding ChannelStocks}" AutoGenerateColumns="False" CanUserAddRows="False">
<DataGrid Grid.Row="1" ItemsSource="{Binding _DrugInfoList}" AutoGenerateColumns="False" CanUserAddRows="False">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
@ -53,66 +53,70 @@
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Width="100"
Header="库位"
IsReadOnly="True"
Binding="{Binding Location}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="180"
Header="药品名称"
IsReadOnly="True"
Binding="{Binding DrugInfo.DrugName}"
Binding="{Binding DrugName}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="180"
Header="规格"
IsReadOnly="True"
Binding="{Binding DrugInfo.DrugSpec}"
Binding="{Binding DrugSpec}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="100"
Header="库存"
<DataGridTextColumn
Header="需补药数"
IsReadOnly="True"
Binding="{Binding Quantity}"
Binding="{Binding NeedQuantity}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="130"
Header="批次"
IsReadOnly="True"
Binding="{Binding ManuNo}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<DataGridTextColumn Width="130"
/>
<DataGridTemplateColumn Header="库存" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Header="库位" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="Location" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True"
Header="批次">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="ManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="130"
Header="效期"
IsReadOnly="True"
Binding="{Binding EffDate}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>
<!--<DataGridTextColumn Width="100"
Header="取出数量"
IsReadOnly="True"
Binding="{Binding TakeQuantity}"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
/>-->
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="EffDate" materialDesign:ListBoxItemAssist.ShowSelection="False"></ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="取出数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Width="80" Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
Visibility="{Binding ColNo,Converter={StaticResource TakeQuantityVisiable}}">
<TextBox.Text>
<Binding Path="TakeQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
</Binding>
</TextBox.Text>
</TextBox>
<ListBox ItemsSource="{Binding channelStocks}" materialDesign:ListBoxItemAssist.ShowSelection="False">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox Width="60" Visibility="{Binding ColNo,Converter={StaticResource TakeQuantityVisiable}}" Text="{Binding TakeQuantity}">
</TextBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

View File

@ -4,7 +4,6 @@ using DM_Weight.ViewModels;
using Prism.Events;
using Prism.Ioc;
using Prism.Regions;
using ScreenRecorderLib;
using System;
using System.Collections.Generic;
using System.Linq;
@ -30,11 +29,11 @@ namespace DM_Weight.Views
{
//IRegionManager _regionManager;
//IUnityContainer _container;
MainWindowViewModel vms;
//MainWindowViewModel vms;
public MainWindow()
{
InitializeComponent();
vms = MainWindowViewModel.vm;
//vms = MainWindowViewModel.vm;
//_regionManager = regionManager;
//_container = container;
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
@ -46,11 +45,11 @@ namespace DM_Weight.Views
//}));
}
protected override void OnClosed(EventArgs e)
{
vms._recorder?.Dispose();
base.OnClosed(e);
}
//protected override void OnClosed(EventArgs e)
//{
// vms._recorder?.Dispose();
// base.OnClosed(e);
//}
}
}

View File

@ -0,0 +1,79 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace DM_Weight.util
{
public class FFmpegHelper
{
private Process _ffmpegProcess;
private string _ffmpegPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ffmpeg.exe");
//是否停止录屏标志
public bool stopFlag = false;
public void StartRecording(string outputPath, int frameRate = 30)
{
//int width = (int)SystemParameters.PrimaryScreenWidth;
//int height =(int)SystemParameters.PrimaryScreenHeight;
int segmentDuration = 1800; // 每段半小时
string args = $"-f gdigrab -framerate {frameRate} " +
$"-i desktop -preset ultrafast -t {segmentDuration} {outputPath}";
_ffmpegProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = _ffmpegPath,
Arguments = args,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardInput = true
}
};
_ffmpegProcess.Start();
ThreadPool.QueueUserWorkItem(CheckFFmpegProcess); // 检查FFmpeg进程是否完成以开始下一个录制段
}
public void StopRecording()
{
_ffmpegProcess?.StandardInput.WriteLine("q");
_ffmpegProcess?.WaitForExit(1000);
_ffmpegProcess?.Close();
stopFlag = true;
}
private void CheckFFmpegProcess(object state)
{
try
{
if (!stopFlag)
{
_ffmpegProcess.WaitForExit(); // 等待FFmpeg进程结束
if (!_ffmpegProcess.HasExited) return; // 如果进程未结束,则不继续
// 开始下一个录制段,如果需要循环录制,可以取消注释下面的代码行并适当调整逻辑
// StartRecording(); // 注意:这将无限循环录制,可能需要用户界面干预来停止或重置计数器。
string _outputFolder;
string _outputFilePath;
_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}.webm");
StartRecording(_outputFilePath, 25);
}
}
catch (Exception)
{
}
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.util
{
public class OpenCVScreenRecord
{
}
}