添加交接柜补药页面
This commit is contained in:
parent
10bbb0d627
commit
3fd569bf6e
|
@ -121,6 +121,15 @@ namespace DM_Weight
|
||||||
|
|
||||||
|
|
||||||
#region 取药
|
#region 取药
|
||||||
|
|
||||||
|
//交接柜补药
|
||||||
|
containerRegistry.RegisterForNavigation<AddToJiaoJieWindow, AddToJiaoJieWindowViewModel>();
|
||||||
|
//交接柜补药页面弹窗
|
||||||
|
containerRegistry.RegisterDialog<AddToJiaoJieDialog>();
|
||||||
|
containerRegistry.RegisterForNavigation<AddToJiaoJieDialog, AddToJiaoJieDialogViewModel>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 处方取药页面
|
// 处方取药页面
|
||||||
containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
|
containerRegistry.RegisterForNavigation<OrderTakeDrugWindow, OrderTakeDrugWindowViewModel>();
|
||||||
// 处方取药模态框
|
// 处方取药模态框
|
||||||
|
|
|
@ -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)
|
||||||
|
{
|
||||||
|
int status = int.Parse(value.ToString());
|
||||||
|
if(status == 3||status==35)
|
||||||
|
{
|
||||||
|
return Visibility.Visible;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -196,5 +196,11 @@ namespace DM_Weight.Models
|
||||||
private string _drugSpec;
|
private string _drugSpec;
|
||||||
[SugarColumn(ColumnName = "drug_manu_no")]
|
[SugarColumn(ColumnName = "drug_manu_no")]
|
||||||
public string DrugSpec { get=> _drugSpec;set=>SetProperty(ref _drugSpec, value); }
|
public string DrugSpec { get=> _drugSpec;set=>SetProperty(ref _drugSpec, value); }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "yh_no")]
|
||||||
|
public string BelongUser
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,12 @@ namespace DM_Weight.Models
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName = "quantity")]
|
[SugarColumn(ColumnName = "quantity")]
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// 交接柜中库存基数
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName = "check_quantity")]
|
||||||
|
public int BaseQuantity { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// 默认值: 1
|
/// 默认值: 1
|
||||||
|
@ -98,11 +103,18 @@ namespace DM_Weight.Models
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public InOutInvoice Invoice { get; set; }
|
public InOutInvoice Invoice { get; set; }
|
||||||
|
|
||||||
|
//[SugarColumn(IsIgnore = true)]
|
||||||
|
//public string Location
|
||||||
|
//{
|
||||||
|
// get => DrawerNo + "-" + ColNo;
|
||||||
|
//}
|
||||||
|
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public string Location
|
public string Location
|
||||||
{
|
{
|
||||||
get => DrawerNo + "-" + ColNo;
|
get => ColNo == 0 ? DrawerNo + "号交接柜" : DrawerNo + "-" + ColNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _addQuantity = 0;
|
private int _addQuantity = 0;
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public int AddQuantity
|
public int AddQuantity
|
||||||
|
@ -187,5 +199,12 @@ namespace DM_Weight.Models
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public DrugPleaseClaim PleaseClaim { get; set; }
|
public DrugPleaseClaim PleaseClaim { get; set; }
|
||||||
|
|
||||||
|
//dm_machine_record表id值
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public int? MachineRecordId { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public string OrderNos { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,9 +17,9 @@ namespace DM_Weight.Models
|
||||||
private int _baseId = 0;
|
private int _baseId = 0;
|
||||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
||||||
public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } }
|
public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } }
|
||||||
private long _drugId = 0;
|
private string _drugId = "0";
|
||||||
[SugarColumn(ColumnName = "drugid")]
|
[SugarColumn(ColumnName = "drugid")]
|
||||||
public long DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } }
|
public string DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } }
|
||||||
private string _machineId = "";
|
private string _machineId = "";
|
||||||
[SugarColumn(ColumnName = "machine_id")]
|
[SugarColumn(ColumnName = "machine_id")]
|
||||||
public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } }
|
public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } }
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace DM_Weight.Models
|
||||||
/// ҩƷID
|
/// ҩƷID
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
|
[SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
|
||||||
public long DrugId { get; set; }
|
public string DrugId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ƴ
|
/// ƴ
|
||||||
///</summary>
|
///</summary>
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DM_Weight.Models
|
||||||
|
{
|
||||||
|
[SugarTable("rejection_report")]
|
||||||
|
public class RejectionReport
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 主键
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 发药时间
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "SendDate")]
|
||||||
|
public DateTime SendDate { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 发药者
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "SendUser")]
|
||||||
|
public string SendUser { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 领药者
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "ReceiveUser")]
|
||||||
|
public string ReceiveUser { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 实发数
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "RealNum")]
|
||||||
|
public int RealNum { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 实物数
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "InfactNum")]
|
||||||
|
public int InfactNum { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 空安瓿
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "EmptyNum")]
|
||||||
|
public int EmptyNum { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 还药时间
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "ReturnTime")]
|
||||||
|
public string ReturnTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 还药者
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "ReturnUser")]
|
||||||
|
public string ReturnUser { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 接收者
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "ReturnReceiveUser")]
|
||||||
|
public string ReturnReceiveUser { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 补充者
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "AddUser")]
|
||||||
|
public string AddUser { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 核对者
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "AddCheckUser")]
|
||||||
|
public string AddCheckUser { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 操作时间
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "OperationTime")]
|
||||||
|
public DateTime OperationTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "DrugId")]
|
||||||
|
public string DrugId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 药品名称
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "DrugName")]
|
||||||
|
public string DrugName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 药品规格
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "DrugSpec")]
|
||||||
|
public string DrugSpec { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 总基数
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "BaseNum")]
|
||||||
|
public string BaseNum { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 药箱号
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "DrawerNo")]
|
||||||
|
public int DrawerNo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -129,6 +129,107 @@ namespace DM_Weight.Port
|
||||||
ColNos = new int[] { };
|
ColNos = new int[] { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 开抽屉
|
||||||
|
/// <summary>
|
||||||
|
/// 打开抽屉
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ColNo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task OpenAllDrawer()
|
||||||
|
{
|
||||||
|
byte[] buffer = await OpenDrawer();
|
||||||
|
int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
|
||||||
|
|
||||||
|
logger.Info($"OpenDrawer{string.Join(",", r)}");
|
||||||
|
if (DrawerState(r))
|
||||||
|
{
|
||||||
|
statue = 1;
|
||||||
|
// 返回消息 抽屉已经打开
|
||||||
|
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
|
||||||
|
{
|
||||||
|
EventType = util.EventType.DRAWEROPEN,
|
||||||
|
WindowName = WindowName,
|
||||||
|
});
|
||||||
|
logger.Info($"抽屉【{DrawerNo}】打开成功");
|
||||||
|
// 查询抽屉状态
|
||||||
|
await Task.Delay(200);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string _WindowName = WindowName;
|
||||||
|
// 重新初始化数据
|
||||||
|
ResetData();
|
||||||
|
// 返回消息 抽屉打开失败
|
||||||
|
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
|
||||||
|
{
|
||||||
|
EventType = util.EventType.OPENERROR,
|
||||||
|
WindowName = WindowName,
|
||||||
|
Message = $"抽屉【{DrawerNo}】打开失败"
|
||||||
|
});
|
||||||
|
logger.Info($"抽屉【{DrawerNo}】打开失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 查询抽屉状态
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task GetAllDrawerLockState()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Operate)
|
||||||
|
{
|
||||||
|
// 查询抽屉状态
|
||||||
|
byte[] buffer = await CheckDrawerStatus();
|
||||||
|
|
||||||
|
int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
|
||||||
|
|
||||||
|
logger.Info($"GetAllDrawerLockState{string.Join(",", r)}");
|
||||||
|
int[] subArray = new int[8];
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
subArray[i] = r[2 + i];
|
||||||
|
}
|
||||||
|
bool state = subArray.All(r => r > 0);
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
//抽屉全部关闭
|
||||||
|
|
||||||
|
string _WindowName = WindowName;
|
||||||
|
// 重新初始化数据
|
||||||
|
ResetData();
|
||||||
|
// 返回消息 抽屉已经关闭
|
||||||
|
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
|
||||||
|
{
|
||||||
|
EventType = util.EventType.DRAWERCLOSE,
|
||||||
|
WindowName = _WindowName,
|
||||||
|
});
|
||||||
|
logger.Info($"抽屉【{DrawerNo}】已关闭");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 继续监听抽屉状态
|
||||||
|
await Task.Delay(200);
|
||||||
|
GetAllDrawerLockState();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
|
||||||
|
{
|
||||||
|
EventType = util.EventType.OPENERROR,
|
||||||
|
WindowName = WindowName,
|
||||||
|
Message = $"GetDrawerStatus异常:{ex.Message}"
|
||||||
|
});
|
||||||
|
logger.Info($"GetDrawerStatus异常:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
public async void Start()
|
public async void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,532 @@
|
||||||
|
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;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DM_Weight.ViewModels
|
||||||
|
{
|
||||||
|
public class AddToJiaoJieDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
|
||||||
|
{
|
||||||
|
private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDialogViewModel));
|
||||||
|
|
||||||
|
|
||||||
|
private List<ChannelStock> _channelStocks = new List<ChannelStock>();
|
||||||
|
|
||||||
|
public List<ChannelStock> ChannelStocks
|
||||||
|
{
|
||||||
|
get => _channelStocks;
|
||||||
|
set => SetProperty(ref _channelStocks, value);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 交接柜的库位信息
|
||||||
|
/// </summary>
|
||||||
|
private List<ChannelStock> _jiaojie_channelStocks;
|
||||||
|
|
||||||
|
public List<ChannelStock> Jiaojie_ChannelStocks
|
||||||
|
{
|
||||||
|
get => _jiaojie_channelStocks;
|
||||||
|
set => SetProperty(ref _jiaojie_channelStocks, value);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 交接柜的库位信息
|
||||||
|
/// </summary>
|
||||||
|
private ChannelStock _jiaojei_cs;
|
||||||
|
|
||||||
|
public ChannelStock Jiaojie_cs
|
||||||
|
{
|
||||||
|
get => _jiaojei_cs;
|
||||||
|
set => SetProperty(ref _jiaojei_cs, value);
|
||||||
|
}
|
||||||
|
private static readonly DateTime Jan1st1970 = new DateTime
|
||||||
|
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||||
|
|
||||||
|
private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
|
||||||
|
private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
|
||||||
|
|
||||||
|
|
||||||
|
public string Title => "交接柜补药";
|
||||||
|
|
||||||
|
public bool KeepAlive => false;
|
||||||
|
|
||||||
|
public event Action<IDialogResult> RequestClose;
|
||||||
|
|
||||||
|
public bool CanCloseDialog()
|
||||||
|
{
|
||||||
|
return Status == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDialogClosed()
|
||||||
|
{
|
||||||
|
// 取消消息订阅
|
||||||
|
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDialogOpened(IDialogParameters parameters)
|
||||||
|
{
|
||||||
|
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
|
||||||
|
Jiaojie_ChannelStocks = parameters.GetValue<List<ChannelStock>>("ChannelStocks");
|
||||||
|
|
||||||
|
for (int i = 0; i < Jiaojie_ChannelStocks.Count; i++)
|
||||||
|
{
|
||||||
|
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.Trans(Jiaojie_ChannelStocks[i]);
|
||||||
|
ChannelStocks.Add(copy);
|
||||||
|
}
|
||||||
|
ChannelStocks = Jiaojie_ChannelStocks.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();
|
||||||
|
RequestData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private PortUtil _portUtil;
|
||||||
|
IEventAggregator _eventAggregator;
|
||||||
|
IDialogService _dialogService;
|
||||||
|
public AddToJiaoJieDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
|
||||||
|
{
|
||||||
|
_dialogService = DialogService;
|
||||||
|
_portUtil = portUtil;
|
||||||
|
_eventAggregator = eventAggregator;
|
||||||
|
}
|
||||||
|
void DoMyPrismEvent(DeviceMsg msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (msg.WindowName == "OrderTakeDrugWindow")
|
||||||
|
{
|
||||||
|
IGrouping<int, ChannelStock> grouping = enumerator.Current;
|
||||||
|
int DrawerNo = grouping.Key;
|
||||||
|
List<ChannelStock> 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<int, ChannelStock> groupingBefore = enumerator.Current;
|
||||||
|
int DrawerNoBefore = groupingBefore.Key;
|
||||||
|
if (enumerator.MoveNext())
|
||||||
|
{
|
||||||
|
IGrouping<int, ChannelStock> 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<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
Status = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _status = 0;
|
||||||
|
|
||||||
|
public int Status
|
||||||
|
{
|
||||||
|
get => _status; set => SetProperty(ref _status, value);
|
||||||
|
}
|
||||||
|
public async void RequestData()
|
||||||
|
{
|
||||||
|
List<ChannelStock> channelStocks = new List<ChannelStock>();
|
||||||
|
List<string> msg = new List<string>();
|
||||||
|
for (int i = 0; i < ChannelStocks.Count; i++)
|
||||||
|
{
|
||||||
|
List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
|
.Includes<DrugInfo>(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 == ChannelStocks[i].DrugId)
|
||||||
|
.OrderBy(cs => cs.EffDate)
|
||||||
|
.OrderBy(cs => cs.DrawerNo)
|
||||||
|
.ToList();
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
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($"药品【{HasQChannels[0].DrugInfo.DrugName}】库存不足,应取【{TakeQ}】库存【{total}】");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public DelegateCommand OpenDrawer
|
||||||
|
{
|
||||||
|
get => new DelegateCommand(async () =>
|
||||||
|
{
|
||||||
|
if (Status == 0)
|
||||||
|
{
|
||||||
|
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
|
||||||
|
{
|
||||||
|
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开,其他6层管理员才能开
|
||||||
|
bool bDrawer = ChannelStocks.Select(it => it.DrawerNo).Where(n => n > 2).Any();
|
||||||
|
if (bDrawer)
|
||||||
|
{
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "当前用户没有打开抽屉的权限!",
|
||||||
|
Type = MsgType.ERROR,
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
|
||||||
|
enumerator = enumerable.GetEnumerator();
|
||||||
|
enumerator.MoveNext();
|
||||||
|
Status = 1;
|
||||||
|
OpenOneByOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenOneByOne()
|
||||||
|
{
|
||||||
|
IGrouping<int, ChannelStock> grouping = enumerator.Current;
|
||||||
|
int DrawerNo = grouping.Key;
|
||||||
|
List<ChannelStock> channelStocks = grouping.ToList();
|
||||||
|
channelStocks.ForEach(it => it.process = 1);
|
||||||
|
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
|
||||||
|
|
||||||
|
|
||||||
|
List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
|
||||||
|
|
||||||
|
// 发送取药数量
|
||||||
|
singleChannels.ForEach(it =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
_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<SnackbarEvent>().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;
|
||||||
|
// 完成按钮
|
||||||
|
public DelegateCommand TakeFinish
|
||||||
|
{
|
||||||
|
get => new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
if (!_isFinishClick)
|
||||||
|
{
|
||||||
|
_isFinishClick = true;
|
||||||
|
List<ChannelStock> 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<ChannelStock> jiaojie = Jiaojie_ChannelStocks.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,
|
||||||
|
Status = 2,//给交接柜补药不用还空瓶,等真正用了以后再还空瓶,所以先把状态置为2
|
||||||
|
InvoiceId = InvoiceId
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存注射剂报表信息
|
||||||
|
for (int j = 0; j < Jiaojie_ChannelStocks.Count; j++)
|
||||||
|
{
|
||||||
|
ChannelStock jStock = Jiaojie_ChannelStocks[j];
|
||||||
|
if (jStock.DrugInfo.Dosage == "注射剂")
|
||||||
|
{
|
||||||
|
int totalBaseNum = SqlSugarHelper.Db.Queryable<DrugBase>().
|
||||||
|
Where(db => db.DrugId == jStock.DrugId && db.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM3")).Select(db => db.BaseQuantity).First();
|
||||||
|
|
||||||
|
string belognUser = SqlSugarHelper.Db.Queryable<ChannelList>().
|
||||||
|
Where(cl => cl.DrawerNo == jStock.DrawerNo && cl.MachineId == jStock.MachineId).Select(cl => cl.BelongUser).First();
|
||||||
|
DrugInfo di = SqlSugarHelper.Db.Queryable<DrugInfo>().Where(di => di.DrugId == jStock.DrugId).First();
|
||||||
|
SqlSugarHelper.Db.Insertable(new RejectionReport()
|
||||||
|
{
|
||||||
|
SendDate = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm")),
|
||||||
|
SendUser = HomeWindowViewModel.Operator?.Nickname,
|
||||||
|
ReceiveUser = belognUser,//Jiaojie_ChannelStocks
|
||||||
|
DrugId = jStock.DrugId,
|
||||||
|
DrugName = di.DrugName,
|
||||||
|
DrugSpec = di.DrugSpec,
|
||||||
|
BaseNum = totalBaseNum + "支",//总基数
|
||||||
|
DrawerNo = jStock.DrawerNo
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
if (f.Data)
|
||||||
|
{
|
||||||
|
// 更新屏显库存
|
||||||
|
List<ChannelStock> 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<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
}
|
||||||
|
if (!f.IsSuccess)
|
||||||
|
{
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "抽屉取药完成,库存更新失败!",
|
||||||
|
Type = MsgType.ERROR,
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
}
|
||||||
|
Status = 0;
|
||||||
|
_isFinishClick = false;
|
||||||
|
//RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
|
||||||
|
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_isFinishClick = false;
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "没有填写取药数量",
|
||||||
|
Type = MsgType.ERROR
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public long CurrentTimeMillis()
|
||||||
|
{
|
||||||
|
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
public DelegateCommand CancleTake
|
||||||
|
{
|
||||||
|
get => new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
_portUtil.ResetData();
|
||||||
|
Status = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//检查是否是冰箱抽屉(冰箱抽屉打开时需要发送冰箱延迟报警的指令)
|
||||||
|
public async Task CheckIsFridgeOpen()
|
||||||
|
{
|
||||||
|
//if (ChannelStocks != null && ChannelStocks.Count > 0)
|
||||||
|
//{
|
||||||
|
// if (_portUtil.BoardType == (Int32)BoardTypeEnum.fridge)
|
||||||
|
// {
|
||||||
|
// _portUtil.FridgeOperate = true;
|
||||||
|
// //发送冰箱延迟报警的指令
|
||||||
|
// await _portUtil.FridgeDelayWarm();
|
||||||
|
// _portUtil.FridgeOperate = false;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
//检查是否是冰箱抽屉(冰箱抽屉关闭时需要查询冰箱温度如温度不在范围则发送冰箱延迟报警的指令)
|
||||||
|
public async Task CheckIsFridgeClose()
|
||||||
|
{
|
||||||
|
//if (ChannelStocks != null && ChannelStocks.Count > 0)
|
||||||
|
//{
|
||||||
|
// if (_portUtil.BoardType == (Int32)BoardTypeEnum.fridge)
|
||||||
|
// {
|
||||||
|
// string[] iTempertureRange = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
|
||||||
|
// //发送查询冰箱温度的指令
|
||||||
|
// float temperature = await _portUtil.GetFridgeTemperature();
|
||||||
|
// if (temperature > Convert.ToSingle(iTempertureRange[0]) && temperature < Convert.ToSingle(iTempertureRange[1]))
|
||||||
|
// {
|
||||||
|
// _portUtil.FridgeOperate = true;
|
||||||
|
// //发送冰箱延迟报警的指令
|
||||||
|
// await _portUtil.FridgeDelayWarm();
|
||||||
|
// _portUtil.FridgeOperate = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DelegateCommand BtnCloseCommand
|
||||||
|
{
|
||||||
|
get => new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
if (Status != 0)
|
||||||
|
{
|
||||||
|
_portUtil.ResetData();
|
||||||
|
Status = 0;
|
||||||
|
}
|
||||||
|
//DialogParameters parameters = new DialogParameters();
|
||||||
|
//parameters.Add("",);
|
||||||
|
// 关闭当前窗口
|
||||||
|
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,454 @@
|
||||||
|
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
|
||||||
|
{
|
||||||
|
public class AddToJiaoJieWindowViewModel : 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<ChannelStock> channelStocks;
|
||||||
|
public List<ChannelStock> ChannelStocks
|
||||||
|
{
|
||||||
|
get => channelStocks;
|
||||||
|
set => SetProperty(ref channelStocks, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||||
|
{
|
||||||
|
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
|
||||||
|
RequestData();
|
||||||
|
}
|
||||||
|
private PortUtil _portUtil;
|
||||||
|
IEventAggregator _eventAggregator;
|
||||||
|
IDialogService _dialogService;
|
||||||
|
public AddToJiaoJieWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService)
|
||||||
|
{
|
||||||
|
_portUtil = portUtil;
|
||||||
|
_eventAggregator = eventAggregator;
|
||||||
|
_dialogService = DialogService;
|
||||||
|
}
|
||||||
|
private void RequestData()
|
||||||
|
{
|
||||||
|
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.BaseQuantity > cs.Quantity)
|
||||||
|
.OrderBy(cs => cs.Chnguid)
|
||||||
|
.OrderBy(cs => cs.DrawerNo)
|
||||||
|
.ToList();
|
||||||
|
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
|
||||||
|
}
|
||||||
|
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 OpenDragCommand
|
||||||
|
{
|
||||||
|
get => new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Status = 1;
|
||||||
|
IsEnable = false;
|
||||||
|
|
||||||
|
var varDrawerNO = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
|
.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<SnackbarEvent>().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<SnackbarEvent>().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<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<ChannelStock> jiaojieStocks = new List<ChannelStock>();
|
||||||
|
List<ChannelStock> cs = ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
|
||||||
|
for (int i = 0; i < cs.Count; i++)
|
||||||
|
{
|
||||||
|
ChannelStock copy = TransExpV2<ChannelStock, ChannelStock>.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<ChannelStock> channelStocks = new List<ChannelStock>();
|
||||||
|
List<string> msg = new List<string>();
|
||||||
|
for (int i = 0; i < csList.Count; i++)
|
||||||
|
{
|
||||||
|
List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
|
.Includes<DrugInfo>(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<ChannelStock> 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<ChannelStock> 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<ChannelStock> 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<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
RequestData();
|
||||||
|
}
|
||||||
|
if (!f.IsSuccess)
|
||||||
|
{
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "补药操作失败,库存更新失败!",
|
||||||
|
Type = MsgType.ERROR,
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "补药数量有误",
|
||||||
|
Type = MsgType.ERROR
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//取消
|
||||||
|
public DelegateCommand CancleAdd
|
||||||
|
{
|
||||||
|
get => new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
_portUtil.ResetData();
|
||||||
|
Status = 0;
|
||||||
|
IsEnable = true;
|
||||||
|
CurrentNum = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 () =>
|
||||||
|
{
|
||||||
|
//选中channelStock.channel_list的isSelected则选中channelStock的isSelected
|
||||||
|
//var o= ChannelStocks.FindAll(cs => cs.ChannelLst.IsSelected).ToList();
|
||||||
|
|
||||||
|
//csList = ChannelStocks.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();
|
||||||
|
|
||||||
|
csList = 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("ChannelStocks", 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)
|
||||||
|
{
|
||||||
|
// 委托 被动执行 被子窗口执行
|
||||||
|
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
|
||||||
|
//if(dialogResult.Result == ButtonResult.OK)
|
||||||
|
//{
|
||||||
|
RequestData();
|
||||||
|
//}
|
||||||
|
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -199,7 +199,7 @@ namespace DM_Weight.ViewModels
|
||||||
|
|
||||||
|
|
||||||
//查询最大药品id并+1赋值给新增药品
|
//查询最大药品id并+1赋值给新增药品
|
||||||
long maxDrugId = SqlSugarHelper.Db.Queryable<DrugInfo>().Max(it => it.DrugId);
|
string maxDrugId = SqlSugarHelper.Db.Queryable<DrugInfo>().Max(it => it.DrugId);
|
||||||
SelectedDrug.DrugId = maxDrugId + 1;
|
SelectedDrug.DrugId = maxDrugId + 1;
|
||||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||||
{
|
{
|
||||||
|
@ -246,7 +246,7 @@ namespace DM_Weight.ViewModels
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}, () => SelectedDrug.DrugId <= 0).ObservesProperty(() => SelectedDrug);
|
}, () => SelectedDrug.DrugId == null).ObservesProperty(() => SelectedDrug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateCommand EditDrugCommand
|
public DelegateCommand EditDrugCommand
|
||||||
|
@ -306,7 +306,7 @@ namespace DM_Weight.ViewModels
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
}
|
}
|
||||||
RequestData();
|
RequestData();
|
||||||
}, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
|
}, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateCommand AddManuCommand
|
public DelegateCommand AddManuCommand
|
||||||
|
@ -322,7 +322,7 @@ namespace DM_Weight.ViewModels
|
||||||
GetManuNos();
|
GetManuNos();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
|
}, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateCommand EditManuCommand
|
public DelegateCommand EditManuCommand
|
||||||
|
|
|
@ -165,11 +165,17 @@ namespace DM_Weight.ViewModels
|
||||||
PremissionImage = "/Images/TbQyao.png",
|
PremissionImage = "/Images/TbQyao.png",
|
||||||
};
|
};
|
||||||
ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>();
|
ObservableCollection<PremissionDm> quyaoChild = new ObservableCollection<PremissionDm>();
|
||||||
|
//PremissionDm quyao1 = new PremissionDm
|
||||||
|
//{
|
||||||
|
// Id = 11,
|
||||||
|
// PremissionName = "处方取药",
|
||||||
|
// PremissionPath = "OrderTakeDrugWindow",
|
||||||
|
//};
|
||||||
PremissionDm quyao1 = new PremissionDm
|
PremissionDm quyao1 = new PremissionDm
|
||||||
{
|
{
|
||||||
Id = 11,
|
Id = 11,
|
||||||
PremissionName = "处方取药",
|
PremissionName = "交接柜补药",
|
||||||
PremissionPath = "OrderTakeDrugWindow",
|
PremissionPath = "AddToJiaoJieWindow",
|
||||||
};
|
};
|
||||||
PremissionDm quyao2 = new PremissionDm
|
PremissionDm quyao2 = new PremissionDm
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,173 @@
|
||||||
|
<UserControl x:Class="DM_Weight.Views.AddToJiaoJieWindow"
|
||||||
|
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">
|
||||||
|
<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" />
|
||||||
|
</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
|
||||||
|
Margin="6 0 6 0"
|
||||||
|
ToolTip="一键补药"
|
||||||
|
Content="一键补药"
|
||||||
|
Command="{Binding OpenDragCommand}"
|
||||||
|
IsEnabled="{Binding IsEnable}"
|
||||||
|
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||||
|
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||||
|
Style="{StaticResource MaterialDesignOutlinedLightButton}" />
|
||||||
|
<Button
|
||||||
|
Margin="0 0 6 0"
|
||||||
|
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
|
||||||
|
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||||
|
Content="完成"
|
||||||
|
Command="{Binding AddFinish}"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Margin="0 0 6 0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Command="{Binding CancleAdd}"
|
||||||
|
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
|
||||||
|
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||||
|
Content="取消" />-->
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Margin="3 0 3 0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Command="{Binding RejectReport_Download}"
|
||||||
|
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||||
|
Content="注射剂报表" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Margin="3 0 3 0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Command="{Binding Account_Download}"
|
||||||
|
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||||
|
Content="账册报表" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Margin="3 0 3 0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Command="{Binding TakeDrugCommand}"
|
||||||
|
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>
|
||||||
|
<DataGrid
|
||||||
|
Grid.Row="1"
|
||||||
|
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
|
||||||
|
ItemsSource="{Binding Source={StaticResource GroupedDataList}}"
|
||||||
|
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
|
||||||
|
IsSynchronizedWithCurrentItem="True"
|
||||||
|
materialDesign:DataGridAssist.CellPadding="13"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
AutoGenerateColumns="False">
|
||||||
|
<DataGrid.Resources>
|
||||||
|
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
|
||||||
|
<Setter Property="Background" Value="#31ccec" />
|
||||||
|
<Setter Property="Foreground" Value="white" />
|
||||||
|
<Setter Property="Height" Value="56" />
|
||||||
|
<Setter Property="BorderBrush" Value="white"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0.6"/>
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
<!--<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsReadOnly" Value="True">
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
</Style>-->
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="DataGridCell">
|
||||||
|
<TextBlock TextAlignment="Center" VerticalAlignment="Center" >
|
||||||
|
<ContentPresenter Margin="13" />
|
||||||
|
</TextBlock>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.Resources>
|
||||||
|
<DataGrid.GroupStyle>
|
||||||
|
<GroupStyle>
|
||||||
|
<GroupStyle.ContainerStyle>
|
||||||
|
<Style TargetType="{x:Type GroupItem}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type GroupItem}">
|
||||||
|
<Expander IsExpanded="True"
|
||||||
|
materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise">
|
||||||
|
<Expander.Header >
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<CheckBox Margin="0 0 3 0" IsChecked="{Binding Path=Name.IsSelected}" FontSize="24" />
|
||||||
|
<TextBlock Text="{Binding Path=Name.DrawerNo,StringFormat={}{0}号药箱}" FontWeight="Bold" />
|
||||||
|
</StackPanel>
|
||||||
|
</Expander.Header>
|
||||||
|
<ItemsPresenter/>
|
||||||
|
</Expander>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</GroupStyle.ContainerStyle>
|
||||||
|
|
||||||
|
</GroupStyle>
|
||||||
|
</DataGrid.GroupStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn IsReadOnly="True" Header="药品名称" Binding="{Binding DrugInfo.DrugName}"/>
|
||||||
|
<DataGridTextColumn IsReadOnly="True" Header="规格" Binding="{Binding DrugInfo.DrugSpec}"/>
|
||||||
|
<DataGridTextColumn IsReadOnly="True" Header="厂家" Binding="{Binding DrugInfo.Manufactory}"/>
|
||||||
|
<DataGridTextColumn IsReadOnly="True" Header="药品基数" Binding="{Binding BaseQuantity}"/>
|
||||||
|
<DataGridTextColumn IsReadOnly="True" Header="需补药数量" Binding="{Binding AddQuantity}"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
|
@ -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>
|
||||||
|
/// AddToJiaoJieWindow.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class AddToJiaoJieWindow : UserControl
|
||||||
|
{
|
||||||
|
public AddToJiaoJieWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,152 @@
|
||||||
|
<UserControl x:Class="DM_Weight.Views.Dialog.AddToJiaoJieDialog"
|
||||||
|
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.Dialog"
|
||||||
|
|
||||||
|
xmlns:prism="http://prismlibrary.com/"
|
||||||
|
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||||
|
xmlns:convert="clr-namespace:DM_Weight.Converter"
|
||||||
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
MinWidth="880"
|
||||||
|
Width="Auto"
|
||||||
|
Height="Auto"
|
||||||
|
mc:Ignorable="d" >
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:StatusConverter x:Key="StatusConverter" />
|
||||||
|
</UserControl.Resources>
|
||||||
|
<materialDesign:Card Padding="0">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid Background="#03a9f4" Grid.Row="0">
|
||||||
|
<TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="交接柜补药" />
|
||||||
|
<Button
|
||||||
|
Style="{StaticResource MaterialDesignIconForegroundButton}"
|
||||||
|
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Command="{Binding BtnCloseCommand}"
|
||||||
|
IsEnabled="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CloseBtn}"
|
||||||
|
ToolTip="关闭"
|
||||||
|
>
|
||||||
|
<materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
<DataGrid Grid.Row="1" ItemsSource="{Binding ChannelStocks}" AutoGenerateColumns="False" CanUserAddRows="False">
|
||||||
|
<DataGrid.Resources>
|
||||||
|
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||||
|
<Setter Property="Background" Value="#31ccec" />
|
||||||
|
<Setter Property="Foreground" Value="white" />
|
||||||
|
<Setter Property="Height" Value="48" />
|
||||||
|
<Setter Property="BorderBrush" Value="white"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0.6"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="left" />
|
||||||
|
<Setter Property="Padding" Value="13" />
|
||||||
|
</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}"
|
||||||
|
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
||||||
|
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||||
|
/>
|
||||||
|
<DataGridTextColumn Width="180"
|
||||||
|
Header="规格"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Binding="{Binding DrugInfo.DrugSpec}"
|
||||||
|
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
||||||
|
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||||
|
/>
|
||||||
|
<DataGridTextColumn Width="100"
|
||||||
|
Header="数量"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Binding="{Binding Quantity}"
|
||||||
|
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
||||||
|
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||||
|
/>
|
||||||
|
<DataGridTextColumn Width="130"
|
||||||
|
Header="批次"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Binding="{Binding ManuNo}"
|
||||||
|
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
||||||
|
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"
|
||||||
|
/>
|
||||||
|
<DataGridTextColumn 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}"
|
||||||
|
/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
<Grid Grid.Row="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Center">
|
||||||
|
|
||||||
|
<!--<Button
|
||||||
|
Margin="2"
|
||||||
|
Style="{StaticResource MaterialDesignRaisedAccentButton}"
|
||||||
|
Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
|
||||||
|
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||||
|
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||||
|
Content="取药"
|
||||||
|
Command="{Binding OpenDrawer}">
|
||||||
|
</Button>-->
|
||||||
|
<Button
|
||||||
|
Margin="2"
|
||||||
|
Style="{StaticResource MaterialDesignRaisedAccentButton}"
|
||||||
|
Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
|
||||||
|
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||||
|
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||||
|
Content="取药"
|
||||||
|
Command="{Binding OpenDrawer}">
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
Margin="2"
|
||||||
|
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
|
||||||
|
Style="{StaticResource MaterialDesignRaisedAccentButton}"
|
||||||
|
Content="完成"
|
||||||
|
Command="{Binding TakeFinish}"/>
|
||||||
|
<Button
|
||||||
|
Margin="2"
|
||||||
|
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
|
||||||
|
Style="{StaticResource MaterialDesignRaisedButton}"
|
||||||
|
Background="Orange"
|
||||||
|
BorderBrush="Orange"
|
||||||
|
Content="取消"
|
||||||
|
Command="{Binding CancleTake}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</materialDesign:Card>
|
||||||
|
</UserControl>
|
|
@ -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.Dialog
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// AddToJiaoJieDialog.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class AddToJiaoJieDialog : UserControl
|
||||||
|
{
|
||||||
|
public AddToJiaoJieDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
|
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
|
||||||
<convert:StatusConverter x:Key="StatusConverter" />
|
<convert:StatusConverter x:Key="StatusConverter" />
|
||||||
|
<convert:OpenBoxConverter x:Key="OpenBoxConverter" />
|
||||||
<convert:InputQuantityConverter x:Key="InputQuantityConverter" />
|
<convert:InputQuantityConverter x:Key="InputQuantityConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
|
@ -259,7 +260,8 @@
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
<DataGridTemplateColumn Width="100"
|
<DataGridTemplateColumn Width="100"
|
||||||
|
Visibility="{Binding DrawerType,Converter={StaticResource OpenBoxConverter}}"
|
||||||
Header="操作">
|
Header="操作">
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|
Loading…
Reference in New Issue