抽屉加药、抽屉取药去掉完成与取消按钮
This commit is contained in:
parent
1059dc01b0
commit
8478ac3626
|
@ -37,7 +37,7 @@
|
|||
<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
|
||||
<add key="returnDrugMode" value="2" />
|
||||
<!-- 自动退出时间,单位秒,为0时不自动退出 -->
|
||||
<add key="autoExit" value="0"/>
|
||||
<add key="autoExit" value="3"/>
|
||||
|
||||
<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
|
||||
<add key="stopRecord" value="0"/>
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
<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="SharpPromise" Version="1.7.0" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
|
||||
<PackageReference Include="SuperSimpleTcp" Version="3.0.10" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
|
||||
|
|
|
@ -65,6 +65,8 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
Status = 3;
|
||||
}
|
||||
//保存库存
|
||||
SaveStock();
|
||||
break;
|
||||
// 数量变化
|
||||
case EventType.UPDATEQUANTITY:
|
||||
|
@ -128,7 +130,7 @@ namespace DM_Weight.ViewModels
|
|||
if (HomeWindowViewModel.Operator.Role != null && HomeWindowViewModel.Operator.Role.RoleName != "管理员")
|
||||
{
|
||||
//查看当前用户是否有所在药品抽屉的权限;1-2层所有人能开,其他6层管理员才能开
|
||||
if (DrawerNo>3)
|
||||
if (DrawerNo > 3)
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
|
@ -178,198 +180,237 @@ namespace DM_Weight.ViewModels
|
|||
}, () => Status == 0).ObservesProperty(() => Status);
|
||||
}
|
||||
|
||||
private bool _isFinishClick = false;
|
||||
|
||||
// 完成按钮
|
||||
public DelegateCommand TakeFinish
|
||||
// private bool _isFinishClick = false;
|
||||
//保存库存
|
||||
private void SaveStock()
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
try
|
||||
{
|
||||
if (!_isFinishClick)
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
|
||||
if (record.Count > 0)
|
||||
{
|
||||
_isFinishClick = true;
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
|
||||
if (record.Count > 0)
|
||||
string InvoiceId = "DRAWER_" + CurrentTimeMillis();
|
||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
{
|
||||
string InvoiceId = "DRAWER_" + CurrentTimeMillis();
|
||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
|
||||
for (int i = 0; i < record.Count; i++)
|
||||
{
|
||||
ChannelStock it = record[i];
|
||||
it.ManuNo = it.drugManuNo.ManuNo;
|
||||
it.EffDate = it.drugManuNo.EffDate;
|
||||
|
||||
for (int i = 0; i < record.Count; i++)
|
||||
|
||||
// 更新数据 库存信息
|
||||
SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||
{
|
||||
ChannelStock it = record[i];
|
||||
it.ManuNo = it.drugManuNo.ManuNo;
|
||||
it.EffDate = it.drugManuNo.EffDate;
|
||||
|
||||
|
||||
// 更新数据 库存信息
|
||||
SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||
{
|
||||
Quantity = it.Quantity + it.AddQuantity,
|
||||
ManuNo = it.ManuNo,
|
||||
EffDate = it.EffDate,
|
||||
Id = it.Id,
|
||||
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
|
||||
// 获取更新完库存后的药品库存
|
||||
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId.Equals(it.MachineId))
|
||||
.Where(cs => cs.DrugId.Equals(it.DrugId))
|
||||
.Where(cs => cs.DrawerType == 1)
|
||||
.ToList();
|
||||
|
||||
// 保存数据 入库记录
|
||||
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.AddQuantity,
|
||||
Type = 1,
|
||||
InvoiceId = InvoiceId
|
||||
//,StockQuantity = nowChannels.Sum(it => it.Quantity)
|
||||
}).ExecuteCommand();
|
||||
|
||||
|
||||
//保存账册
|
||||
SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
{
|
||||
DrugId = it.DrugId,
|
||||
Type = 1,
|
||||
Department = ConfigurationManager.AppSettings["department"].ToString(),
|
||||
InvoiceNo = InvoiceId,
|
||||
ManuNo = it.ManuNo,
|
||||
EffDate = it.EffDate,
|
||||
AddQuantity = it.AddQuantity,
|
||||
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
CreateTime = DateTime.Now
|
||||
|
||||
}).ExecuteCommand();
|
||||
//修改凌晨生成的日结存数据
|
||||
AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||
.Where(ab => ab.Type == 3)
|
||||
.Where(ab => ab.DrugId == it.DrugId)
|
||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||
if (accountBookG2Day != null)
|
||||
{
|
||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
{
|
||||
DrugId = it.DrugId,
|
||||
Type = 3,
|
||||
ManuNo = it.ManuNo,
|
||||
EffDate = it.EffDate,
|
||||
YQuantity = 0,
|
||||
ManuStock = it.AddQuantity,
|
||||
TotalStock = it.AddQuantity,
|
||||
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
InvoiceNo = "日结存"
|
||||
}).ExecuteCommand();
|
||||
if (iDayResult <= 0)
|
||||
{
|
||||
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||
}
|
||||
}
|
||||
//修改凌晨生成的总结存数据
|
||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||
.Where(ab => ab.Type == 4)
|
||||
.Where(ab => ab.DrugId == it.DrugId)
|
||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||
if (accountBookG2Total != null)
|
||||
{
|
||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
{
|
||||
DrugId = it.DrugId,
|
||||
Type = 4,
|
||||
YQuantity = 0,
|
||||
ManuStock = it.AddQuantity,
|
||||
TotalStock = it.AddQuantity,
|
||||
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
InvoiceNo = "总结存"
|
||||
}).ExecuteCommand();
|
||||
if (iTotalResult <= 0)
|
||||
{
|
||||
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (f.Data)
|
||||
{
|
||||
RequestData();
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "抽屉加药完成,库存已更新",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
Quantity = it.Quantity + it.AddQuantity,
|
||||
ManuNo = it.ManuNo,
|
||||
EffDate = it.EffDate,
|
||||
Id = it.Id,
|
||||
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
|
||||
|
||||
logger.Info($"库存已更新{it.DrugId},{it.Quantity+it.AddQuantity}");
|
||||
}
|
||||
else
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "更新库存失败",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
Status = 0;
|
||||
_isFinishClick = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isFinishClick = false;
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "没有填写加药数量",
|
||||
Type = MsgType.ERROR
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
|
||||
});
|
||||
RequestData();
|
||||
Status = 0;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
public DelegateCommand CancleTake
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_portUtil.ResetData();
|
||||
Status = 0;
|
||||
});
|
||||
logger.Info($"保存库存异常{ex.Message}");
|
||||
}
|
||||
}
|
||||
//// 完成按钮
|
||||
//public DelegateCommand TakeFinish
|
||||
//{
|
||||
// get => new DelegateCommand(() =>
|
||||
// {
|
||||
// if (!_isFinishClick)
|
||||
// {
|
||||
// _isFinishClick = true;
|
||||
// List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
|
||||
// if (record.Count > 0)
|
||||
// {
|
||||
// string InvoiceId = "DRAWER_" + CurrentTimeMillis();
|
||||
// var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
// {
|
||||
|
||||
// for (int i = 0; i < record.Count; i++)
|
||||
// {
|
||||
// ChannelStock it = record[i];
|
||||
// it.ManuNo = it.drugManuNo.ManuNo;
|
||||
// it.EffDate = it.drugManuNo.EffDate;
|
||||
|
||||
|
||||
// // 更新数据 库存信息
|
||||
// SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||
// {
|
||||
// Quantity = it.Quantity + it.AddQuantity,
|
||||
// ManuNo = it.ManuNo,
|
||||
// EffDate = it.EffDate,
|
||||
// Id = it.Id,
|
||||
// }).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
|
||||
// // 获取更新完库存后的药品库存
|
||||
// List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
// .Where(cs => cs.MachineId.Equals(it.MachineId))
|
||||
// .Where(cs => cs.DrugId.Equals(it.DrugId))
|
||||
// .Where(cs => cs.DrawerType == 1)
|
||||
// .ToList();
|
||||
|
||||
// // 保存数据 入库记录
|
||||
// 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.AddQuantity,
|
||||
// Type = 1,
|
||||
// InvoiceId = InvoiceId
|
||||
// //,StockQuantity = nowChannels.Sum(it => it.Quantity)
|
||||
// }).ExecuteCommand();
|
||||
|
||||
|
||||
// //保存账册
|
||||
// SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
// {
|
||||
// DrugId = it.DrugId,
|
||||
// Type = 1,
|
||||
// Department = ConfigurationManager.AppSettings["department"].ToString(),
|
||||
// InvoiceNo = InvoiceId,
|
||||
// ManuNo = it.ManuNo,
|
||||
// EffDate = it.EffDate,
|
||||
// AddQuantity = it.AddQuantity,
|
||||
// UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
// UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
// MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
// CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// CreateTime = DateTime.Now
|
||||
|
||||
// }).ExecuteCommand();
|
||||
// //修改凌晨生成的日结存数据
|
||||
// AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||
// .Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||
// .Where(ab => ab.Type == 3)
|
||||
// .Where(ab => ab.DrugId == it.DrugId)
|
||||
// .Where(ab => ab.ManuNo == it.ManuNo)
|
||||
// .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||
// if (accountBookG2Day != null)
|
||||
// {
|
||||
// accountBookG2Day.ManuStock = accountBookG2Day.ManuStock + it.AddQuantity;
|
||||
// SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||
// int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
// {
|
||||
// DrugId = it.DrugId,
|
||||
// Type = 3,
|
||||
// ManuNo = it.ManuNo,
|
||||
// EffDate = it.EffDate,
|
||||
// YQuantity = 0,
|
||||
// ManuStock = it.AddQuantity,
|
||||
// TotalStock = it.AddQuantity,
|
||||
// UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
// UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
// MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
// CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// InvoiceNo = "日结存"
|
||||
// }).ExecuteCommand();
|
||||
// if (iDayResult <= 0)
|
||||
// {
|
||||
// logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||
// }
|
||||
// }
|
||||
// //修改凌晨生成的总结存数据
|
||||
// AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||
// .Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||
// .Where(ab => ab.Type == 4)
|
||||
// .Where(ab => ab.DrugId == it.DrugId)
|
||||
// .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||
// if (accountBookG2Total != null)
|
||||
// {
|
||||
// accountBookG2Total.TotalStock = accountBookG2Total.TotalStock + it.AddQuantity;
|
||||
// SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||
// int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
// {
|
||||
// DrugId = it.DrugId,
|
||||
// Type = 4,
|
||||
// YQuantity = 0,
|
||||
// ManuStock = it.AddQuantity,
|
||||
// TotalStock = it.AddQuantity,
|
||||
// UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
// UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
// MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
// CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// InvoiceNo = "总结存"
|
||||
// }).ExecuteCommand();
|
||||
// if (iTotalResult <= 0)
|
||||
// {
|
||||
// logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// });
|
||||
// if (f.Data)
|
||||
// {
|
||||
// RequestData();
|
||||
// AlertMsg alertMsg = new AlertMsg
|
||||
// {
|
||||
// Message = "抽屉加药完成,库存已更新",
|
||||
// Type = MsgType.SUCCESS,
|
||||
// };
|
||||
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AlertMsg alertMsg = new AlertMsg
|
||||
// {
|
||||
// Message = "更新库存失败",
|
||||
// Type = MsgType.SUCCESS,
|
||||
// };
|
||||
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
// }
|
||||
// Status = 0;
|
||||
// _isFinishClick = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _isFinishClick = false;
|
||||
// AlertMsg alertMsg = new AlertMsg
|
||||
// {
|
||||
// Message = "没有填写加药数量",
|
||||
// Type = MsgType.ERROR
|
||||
// };
|
||||
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
//}
|
||||
|
||||
//// 取消按钮
|
||||
//public DelegateCommand CancleTake
|
||||
//{
|
||||
// get => new DelegateCommand(() =>
|
||||
// {
|
||||
// _portUtil.ResetData();
|
||||
// Status = 0;
|
||||
// });
|
||||
//}
|
||||
|
||||
public long CurrentTimeMillis()
|
||||
{
|
||||
|
|
|
@ -70,7 +70,9 @@ namespace DM_Weight.ViewModels
|
|||
if (Status == 2)
|
||||
{
|
||||
Status = 3;
|
||||
}
|
||||
}
|
||||
//保存库存
|
||||
SaveStock();
|
||||
break;
|
||||
// 数量变化
|
||||
case EventType.UPDATEQUANTITY:
|
||||
|
@ -178,200 +180,240 @@ namespace DM_Weight.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
private bool _isFinishClick = false;
|
||||
|
||||
// 完成按钮
|
||||
public DelegateCommand TakeFinish
|
||||
//保存库存
|
||||
private void SaveStock()
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
try
|
||||
{
|
||||
if (!_isFinishClick)
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity != 0).ToList();
|
||||
if (record.Count > 0)
|
||||
{
|
||||
_isFinishClick = true;
|
||||
List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity != 0).ToList();
|
||||
logger.Info("点击完成按钮,库位数据:" + JsonConvert.SerializeObject(record));
|
||||
if (record.Count > 0)
|
||||
string InvoiceId = "DRAWER_" + CurrentTimeMillis();
|
||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
{
|
||||
string InvoiceId = "DRAWER_" + CurrentTimeMillis();
|
||||
var f = SqlSugarHelper.Db.UseTran(() =>
|
||||
|
||||
for (int i = 0; i < record.Count; i++)
|
||||
{
|
||||
ChannelStock it = record[i];
|
||||
it.ManuNo = it.ManuNo;
|
||||
it.EffDate = it.EffDate;
|
||||
|
||||
for (int i = 0; i < record.Count; i++)
|
||||
|
||||
// 更新数据 库存信息
|
||||
SqlSugarHelper.Db.Updateable(new ChannelStock()
|
||||
{
|
||||
ChannelStock it = record[i];
|
||||
Quantity = it.Quantity - it.TakeQuantity,
|
||||
ManuNo = it.ManuNo,
|
||||
EffDate = it.EffDate,
|
||||
Id = it.Id,
|
||||
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
|
||||
|
||||
|
||||
// 更新数据 库存信息
|
||||
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> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
.Where(cs => cs.MachineId.Equals(it.MachineId))
|
||||
.Where(cs => cs.DrugId.Equals(it.DrugId))
|
||||
.Where(cs => cs.DrawerType == 1)
|
||||
.ToList();
|
||||
|
||||
// 保存数据 出库记录
|
||||
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
|
||||
//,StockQuantity = nowChannels.Sum(it => it.Quantity)
|
||||
}).ExecuteCommand();
|
||||
|
||||
|
||||
//保存账册
|
||||
SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
{
|
||||
DrugId = it.DrugId,
|
||||
Type = 2,
|
||||
Department = ConfigurationManager.AppSettings["department"].ToString(),
|
||||
InvoiceNo = InvoiceId,
|
||||
ManuNo = it.ManuNo,
|
||||
EffDate = it.EffDate,
|
||||
OutQuantity = it.TakeQuantity,
|
||||
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
CreateTime = DateTime.Now
|
||||
|
||||
}).ExecuteCommand();
|
||||
//修改凌晨生成的日结存数据
|
||||
AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||
.Where(ab => ab.Type == 3)
|
||||
.Where(ab => ab.DrugId == it.DrugId)
|
||||
.Where(ab => ab.ManuNo == it.ManuNo)
|
||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||
if (accountBookG2Day != null)
|
||||
{
|
||||
accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
||||
SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
//生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||
int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
{
|
||||
DrugId = it.DrugId,
|
||||
Type = 3,
|
||||
ManuNo = it.ManuNo,
|
||||
EffDate = it.EffDate,
|
||||
YQuantity = 0,
|
||||
ManuStock = it.TakeQuantity,
|
||||
TotalStock = it.TakeQuantity,
|
||||
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
InvoiceNo = "日结存"
|
||||
}).ExecuteCommand();
|
||||
if (iDayResult <= 0)
|
||||
{
|
||||
logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||
}
|
||||
}
|
||||
//修改凌晨生成的总结存数据
|
||||
AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||
.Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||
.Where(ab => ab.Type == 4)
|
||||
.Where(ab => ab.DrugId == it.DrugId)
|
||||
.Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||
if (accountBookG2Total != null)
|
||||
{
|
||||
accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
||||
SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
//生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||
int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
{
|
||||
DrugId = it.DrugId,
|
||||
Type = 4,
|
||||
YQuantity = 0,
|
||||
ManuStock = it.TakeQuantity,
|
||||
TotalStock = it.TakeQuantity,
|
||||
UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
InvoiceNo = "总结存"
|
||||
}).ExecuteCommand();
|
||||
if (iTotalResult <= 0)
|
||||
{
|
||||
logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.Info($"抽屉取药保存->库位【{it.DrawerNo}-{it.ColNo}】取出药品【{it.DrugInfo.DrugName}】个数【{it.TakeQuantity}】,取药前库存【{it.Quantity}】");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (f.Data)
|
||||
{
|
||||
RequestData();
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "抽屉取药完成,库存已更新",
|
||||
Type = MsgType.SUCCESS,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
logger.Info($"库存已更新{it.DrugId},{it.Quantity - it.TakeQuantity}");
|
||||
}
|
||||
if (!f.IsSuccess)
|
||||
{
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "抽屉取药完成,库存更新失败!",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
Status = 0;
|
||||
_isFinishClick = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isFinishClick = false;
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = "没有填写取药数量",
|
||||
Type = MsgType.ERROR
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
}
|
||||
|
||||
});
|
||||
RequestData();
|
||||
Status = 0;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
public DelegateCommand CancleTake
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_portUtil.ResetData();
|
||||
Status = 0;
|
||||
});
|
||||
logger.Info($"保存库存异常{ex.Message}");
|
||||
}
|
||||
}
|
||||
//private bool _isFinishClick = false;
|
||||
|
||||
//// 完成按钮
|
||||
//public DelegateCommand TakeFinish
|
||||
//{
|
||||
// get => new DelegateCommand(() =>
|
||||
// {
|
||||
// if (!_isFinishClick)
|
||||
// {
|
||||
// _isFinishClick = true;
|
||||
// List<ChannelStock> record = ChannelStocks.FindAll(it => it.TakeQuantity != 0).ToList();
|
||||
// logger.Info("点击完成按钮,库位数据:" + JsonConvert.SerializeObject(record));
|
||||
// if (record.Count > 0)
|
||||
// {
|
||||
// string InvoiceId = "DRAWER_" + 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> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||
// .Where(cs => cs.MachineId.Equals(it.MachineId))
|
||||
// .Where(cs => cs.DrugId.Equals(it.DrugId))
|
||||
// .Where(cs => cs.DrawerType == 1)
|
||||
// .ToList();
|
||||
|
||||
// // 保存数据 出库记录
|
||||
// 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
|
||||
// //,StockQuantity = nowChannels.Sum(it => it.Quantity)
|
||||
// }).ExecuteCommand();
|
||||
|
||||
|
||||
// //保存账册
|
||||
// SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
// {
|
||||
// DrugId = it.DrugId,
|
||||
// Type = 2,
|
||||
// Department = ConfigurationManager.AppSettings["department"].ToString(),
|
||||
// InvoiceNo = InvoiceId,
|
||||
// ManuNo = it.ManuNo,
|
||||
// EffDate = it.EffDate,
|
||||
// OutQuantity = it.TakeQuantity,
|
||||
// UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
// UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
// MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
// CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// CreateTime = DateTime.Now
|
||||
|
||||
// }).ExecuteCommand();
|
||||
// //修改凌晨生成的日结存数据
|
||||
// AccountBookG2 accountBookG2Day = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||
// .Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||
// .Where(ab => ab.Type == 3)
|
||||
// .Where(ab => ab.DrugId == it.DrugId)
|
||||
// .Where(ab => ab.ManuNo == it.ManuNo)
|
||||
// .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||
// if (accountBookG2Day != null)
|
||||
// {
|
||||
// accountBookG2Day.ManuStock = accountBookG2Day.ManuStock - it.TakeQuantity;
|
||||
// SqlSugarHelper.Db.Updateable(accountBookG2Day).ExecuteCommand();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //生成日结存时可能没有该库位的绑定信息,需要写入日结存
|
||||
// int iDayResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
// {
|
||||
// DrugId = it.DrugId,
|
||||
// Type = 3,
|
||||
// ManuNo = it.ManuNo,
|
||||
// EffDate = it.EffDate,
|
||||
// YQuantity = 0,
|
||||
// ManuStock = it.TakeQuantity,
|
||||
// TotalStock = it.TakeQuantity,
|
||||
// UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
// UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
// MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
// CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// InvoiceNo = "日结存"
|
||||
// }).ExecuteCommand();
|
||||
// if (iDayResult <= 0)
|
||||
// {
|
||||
// logger.Info($"未写入日结存数据{it.DrugId}-{it.ManuNo}-{it.EffDate}-{it.AddQuantity}");
|
||||
// }
|
||||
// }
|
||||
// //修改凌晨生成的总结存数据
|
||||
// AccountBookG2 accountBookG2Total = SqlSugarHelper.Db.Queryable<AccountBookG2>()
|
||||
// .Where(ab => ab.MachineId.Equals(it.MachineId))
|
||||
// .Where(ab => ab.Type == 4)
|
||||
// .Where(ab => ab.DrugId == it.DrugId)
|
||||
// .Where(ab => ab.CreateDate == DateTime.Now.ToString("yyyy-MM-dd")).First();
|
||||
// if (accountBookG2Total != null)
|
||||
// {
|
||||
// accountBookG2Total.TotalStock = accountBookG2Total.TotalStock - it.TakeQuantity;
|
||||
// SqlSugarHelper.Db.Updateable(accountBookG2Total).ExecuteCommand();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //生成总结存时可能没有该库位的绑定信息,需要写入总结存
|
||||
// int iTotalResult = SqlSugarHelper.Db.Insertable(new AccountBookG2()
|
||||
// {
|
||||
// DrugId = it.DrugId,
|
||||
// Type = 4,
|
||||
// YQuantity = 0,
|
||||
// ManuStock = it.TakeQuantity,
|
||||
// TotalStock = it.TakeQuantity,
|
||||
// UserId1 = HomeWindowViewModel.Operator?.Id,
|
||||
// UserId2 = HomeWindowViewModel.Reviewer?.Id,
|
||||
// MachineId = ConfigurationManager.AppSettings["machineId"].ToString(),
|
||||
// CreateDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// InvoiceNo = "总结存"
|
||||
// }).ExecuteCommand();
|
||||
// if (iTotalResult <= 0)
|
||||
// {
|
||||
// logger.Info($"未写入总结存数据{it.DrugId}-{it.AddQuantity}");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// logger.Info($"抽屉取药保存->库位【{it.DrawerNo}-{it.ColNo}】取出药品【{it.DrugInfo.DrugName}】个数【{it.TakeQuantity}】,取药前库存【{it.Quantity}】");
|
||||
// }
|
||||
// return true;
|
||||
// });
|
||||
// if (f.Data)
|
||||
// {
|
||||
// RequestData();
|
||||
// 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;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _isFinishClick = false;
|
||||
// AlertMsg alertMsg = new AlertMsg
|
||||
// {
|
||||
// Message = "没有填写取药数量",
|
||||
// Type = MsgType.ERROR
|
||||
// };
|
||||
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// });
|
||||
//}
|
||||
|
||||
//// 取消按钮
|
||||
//public DelegateCommand CancleTake
|
||||
//{
|
||||
// get => new DelegateCommand(() =>
|
||||
// {
|
||||
// _portUtil.ResetData();
|
||||
// Status = 0;
|
||||
// });
|
||||
//}
|
||||
|
||||
public long CurrentTimeMillis()
|
||||
{
|
||||
|
|
|
@ -536,35 +536,85 @@ namespace DM_Weight.ViewModels
|
|||
SelectedChildMenu = premissions[0].Children[0];
|
||||
_regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
|
||||
FindDrawerCount();
|
||||
|
||||
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
|
||||
int stopRecord = Convert.ToInt32(ConfigurationManager.AppSettings["stopRecord"] ?? "0");
|
||||
if (autoExit > 0)
|
||||
{
|
||||
System.Timers.Timer timer = new System.Timers.Timer();
|
||||
timer.Interval = 1000;
|
||||
timer.Elapsed += (sender, e) =>
|
||||
//int interval = autoExit * 1000;
|
||||
new PromiseUtil<int>().taskAsyncLoop(1000, 0, async (options, next, stop) =>
|
||||
{
|
||||
// 串口无人操作
|
||||
if (!_portUtil.Operate)
|
||||
try
|
||||
{
|
||||
// 30秒内无人操作鼠标键盘
|
||||
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
||||
if (!_portUtil.Operate)
|
||||
{
|
||||
logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
|
||||
//_chkFunction.HIKStopDVRRecord();
|
||||
Operator = null;
|
||||
Reviewer = null;
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
// 无人操作鼠标键盘
|
||||
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
||||
{
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
timer.Stop();
|
||||
});
|
||||
logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录,_portUtil.Operate:{_portUtil.Operate},totalSecond:{(DateTime.Now - _portUtil.dateTime).TotalSeconds},lastInputTime:{CheckComputerFreeState.GetLastInputTime()},autoExit:{autoExit}");
|
||||
|
||||
Operator = null;
|
||||
Reviewer = null;
|
||||
//Application.Current.Dispatcher.Invoke(() =>
|
||||
//{
|
||||
stop();
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
}));
|
||||
//});
|
||||
//timer.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Operator == null)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_portUtil.dateTime = DateTime.Now;
|
||||
next();
|
||||
}
|
||||
}
|
||||
};
|
||||
timer.Start();
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Info($"自动退出异常:{ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
//int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
|
||||
//int stopRecord = Convert.ToInt32(ConfigurationManager.AppSettings["stopRecord"] ?? "0");
|
||||
//if (autoExit > 0)
|
||||
//{
|
||||
// System.Timers.Timer timer = new System.Timers.Timer();
|
||||
// timer.Interval = 1000;
|
||||
// timer.Elapsed += (sender, e) =>
|
||||
// {
|
||||
// // 串口无人操作
|
||||
// if (!_portUtil.Operate)
|
||||
// {
|
||||
// // 30秒内无人操作鼠标键盘
|
||||
// if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
||||
// {
|
||||
// logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录,_portUtil.Operate:{_portUtil.Operate},totalSecond:{(DateTime.Now - _portUtil.dateTime).TotalSeconds},lastInputTime:{CheckComputerFreeState.GetLastInputTime()},autoExit:{autoExit}");
|
||||
// //_chkFunction.HIKStopDVRRecord();
|
||||
// Operator = null;
|
||||
// Reviewer = null;
|
||||
// Application.Current.Dispatcher.Invoke(() =>
|
||||
// {
|
||||
// _regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
// timer.Stop();
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// timer.Start();
|
||||
//}
|
||||
//#region 温度查询定时
|
||||
//int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
|
||||
//if (interval > 0)
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="加药" />
|
||||
<Button
|
||||
<!--<Button
|
||||
Margin="0 0 3 0"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding TakeFinish}"
|
||||
|
@ -173,7 +173,7 @@
|
|||
Command="{Binding CancleTake}"
|
||||
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="取消" />
|
||||
Content="取消" />-->
|
||||
</StackPanel>
|
||||
<DataGrid
|
||||
Padding="0 6 0 0"
|
||||
|
|
|
@ -157,7 +157,7 @@
|
|||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="取药" />
|
||||
<Button
|
||||
<!--<Button
|
||||
Margin="0 0 3 0"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding TakeFinish}"
|
||||
|
@ -171,7 +171,7 @@
|
|||
Command="{Binding CancleTake}"
|
||||
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="取消" />
|
||||
Content="取消" />-->
|
||||
</StackPanel>
|
||||
<DataGrid
|
||||
Padding="0 6 0 0"
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
using SharpPromise;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DM_Weight.util
|
||||
{
|
||||
public class PromiseUtil<T>
|
||||
{
|
||||
|
||||
public int _delay { get; set; }
|
||||
|
||||
public T? _data { get; set; }
|
||||
|
||||
public async Task taskAsyncLoop(int delay, T data, Action<PromiseUtil<T>, Action, Action> action)
|
||||
{
|
||||
_data = data;
|
||||
_delay = 0;
|
||||
while (_delay >= 0)
|
||||
{
|
||||
await new Promise(async (Action onResolve, Action onReject) =>
|
||||
{
|
||||
await Task.Delay(_delay);
|
||||
try
|
||||
{
|
||||
await Task.Run(() => action(this, onResolve, onReject));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
onReject();
|
||||
}
|
||||
}).Then(() =>
|
||||
{
|
||||
_delay = delay;
|
||||
}).Catch((Exception e) =>
|
||||
{
|
||||
_delay = -1;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue