写标签添加线程休息200

This commit is contained in:
maqiao 2025-03-27 14:02:17 +08:00
parent 4ebdcc4ac7
commit dd4e0a6695
16 changed files with 109 additions and 84 deletions

View File

@ -19,8 +19,8 @@ namespace DM_Weight.Models
///
/// 默认值: NULL
///</summary>
//[SugarColumn(ColumnName = "order_id")]
//public int? OrderId { get; set; }
[SugarColumn(ColumnName = "order_id")]
public int? OrderId { get; set; }
/// <summary>
///
///</summary>

View File

@ -426,11 +426,11 @@ namespace DM_Weight.ViewModels
Thread.Sleep(200);
_portUtil.ShowContent(it.DrawerNo, it.ColNo);
Thread.Sleep(500);
Thread.Sleep(200);
//写库存数量
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
Thread.Sleep(200);
});
}
RequestData();

View File

@ -577,6 +577,7 @@ namespace DM_Weight.ViewModels
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
Thread.Sleep(200);
_portUtil.WriteQuantity(item.DrawerNo, item.ColNo, item.totalCount);
Thread.Sleep(200);
}
});
}

View File

@ -459,7 +459,7 @@ namespace DM_Weight.ViewModels
{
// 将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
Thread.Sleep(200);
});
}

View File

@ -549,6 +549,7 @@ namespace DM_Weight.ViewModels
{
// 将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
Thread.Sleep(200);
});
}

View File

@ -15,6 +15,7 @@ using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using System.Threading;
namespace DM_Weight.ViewModels
{
@ -257,6 +258,7 @@ namespace DM_Weight.ViewModels
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
Thread.Sleep(200);
});
}

View File

@ -17,6 +17,7 @@ using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using System.Collections.ObjectModel;
using System.Threading;
namespace DM_Weight.ViewModels
{
@ -332,6 +333,7 @@ namespace DM_Weight.ViewModels
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
Thread.Sleep(200);
});
}
RequestData();

View File

@ -415,7 +415,7 @@ namespace DM_Weight.ViewModels
{
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) + singleChannels.Sum(it => it.AddQuantity));
Thread.Sleep(200);
//singleChannels.ForEach(it =>
//{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);

View File

@ -413,7 +413,7 @@ namespace DM_Weight.ViewModels
{
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.AddQuantity));
Thread.Sleep(200);
//singleChannels.ForEach(it =>
//{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);

View File

@ -9,6 +9,7 @@ using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -382,89 +383,98 @@ namespace DM_Weight.ViewModels
// State = 1,
// Operator = HomeWindowViewModel.Operator?.Nickname,
//});
//已取药数量
int hasTake = 0;
for (int i = 0; i < record.Count; i++)
{
int ordinalNum = SqlSugarHelper.Db.Queryable<MachineRecord>()
.Where(mr => mr.OperationTime.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
.Max(mr => mr.OrdinalNum);
int orderTakeQuantity = SqlSugarHelper.Db.Queryable<OrderDetail>()
//处方中该药品明细
OrderDetail orderDetail = SqlSugarHelper.Db.Queryable<OrderDetail>()
.Where(od => od.OrderNo == OrderInfo[j].OrderNo && od.DrugId == record[i].DrugId && od.DetailStatus == 0)
.GroupBy(od => new { od.DrugId, od.SetManuNo }).Sum(od => od.Quantity);
if (hasTake > 0)
.GroupBy(od => new { od.DrugId, od.OrderId, od.SetManuNo }).Select(od => new OrderDetail
{
OrderId = od.OrderId,
DrugId = od.DrugId,
Quantity = SqlFunc.AggregateSum(od.Quantity)
}).First();
if (orderDetail != null)
{
orderTakeQuantity = orderTakeQuantity - hasTake;
}
//该处方没有这个药,跳出循环
if (orderTakeQuantity <= 0 || record[i].Quantity <= 0)
continue;
if (!(record[i].Quantity == orderTakeQuantity))
{
if (record[i].Quantity > orderTakeQuantity)
{
//record[i].TakeQuantity = record[i].TakeQuantity - orderTakeQuantity;
record[i].TakeQuantity = orderTakeQuantity;
hasTake += orderTakeQuantity;
record[i].Quantity = record[i].Quantity - orderTakeQuantity;
}
else if (record[i].Quantity < orderTakeQuantity)
{
hasTake += record[i].Quantity;
record[i].TakeQuantity = record[i].Quantity;
record[i].Quantity = 0;
}
}
else
{
record[i].TakeQuantity = orderTakeQuantity;
record[i].Quantity = record[i].Quantity - record[i].TakeQuantity;
hasTake += record[i].TakeQuantity;
}
ChannelStock it = record[i];
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = record[i].Quantity,
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();
//已取药数量
int hasTakeQuantity = SqlSugarHelper.Db.Queryable<MachineRecord>()
.Where(mr => mr.InvoiceId == InvoiceId && mr.DrugId == record[i].DrugId && mr.GetId == orderDetail.OrderId)
.Sum(mr => mr.Quantity);
//处方中该药品取药数量
int orderTakeQuantity = orderDetail.Quantity - hasTakeQuantity;
// 保存数据 出库记录
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 = record[i].TakeQuantity,
Type = 2,
InvoiceId = InvoiceId,
OrdinalNum = ordinalNum + 1,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = ConfigurationManager.AppSettings["receiveDept"].ToString(),
ReceiveDept = OrderInfo[j].DeptName
}).ExecuteCommand();
if (0 == record[i].Quantity)
{
record[i].TakeQuantity = 0;
}
if (record[i].TakeQuantity == orderTakeQuantity)
{
break;
//当前药品库存
int stockQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == (record[i].MachineId)
&& cs.DrugId == record[i].DrugId
&& cs.ManuNo == record[i].ManuNo && cs.DrawerNo == record[i].DrawerNo
&& cs.ColNo == record[i].ColNo).Select(cs => cs.Quantity).First();
//该处方没有这个药,跳出循环
if (stockQuantity <= 0)
continue;
if (!(stockQuantity == orderTakeQuantity))
{
if (stockQuantity > orderTakeQuantity)
{
//record[i].TakeQuantity = record[i].TakeQuantity - orderTakeQuantity;
record[i].TakeQuantity = orderTakeQuantity;
record[i].Quantity = stockQuantity - orderTakeQuantity;
}
else if (stockQuantity < orderTakeQuantity)
{
record[i].TakeQuantity = stockQuantity;
record[i].Quantity = 0;
}
}
else
{
record[i].TakeQuantity = orderTakeQuantity;
record[i].Quantity = stockQuantity - record[i].TakeQuantity;
}
ChannelStock it = record[i];
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = record[i].Quantity,
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 = record[i].TakeQuantity,
Type = 2,
InvoiceId = InvoiceId,
OrdinalNum = ordinalNum + 1,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = ConfigurationManager.AppSettings["receiveDept"].ToString(),
ReceiveDept = OrderInfo[j].DeptName,
GetId = orderDetail.OrderId
}).ExecuteCommand();
}
}
//更新处方状态
@ -498,6 +508,7 @@ namespace DM_Weight.ViewModels
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
Thread.Sleep(200);
});
}
AlertMsg alertMsg = new AlertMsg

View File

@ -440,6 +440,7 @@ namespace DM_Weight.ViewModels
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
Thread.Sleep(200);
}
}
}

View File

@ -460,6 +460,7 @@ namespace DM_Weight.ViewModels
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
Thread.Sleep(200);
}
}
}

View File

@ -17,6 +17,7 @@ using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using SqlSugar;
using System.Threading;
namespace DM_Weight.ViewModels
{
@ -334,6 +335,7 @@ namespace DM_Weight.ViewModels
.Sum(it => it.Quantity);
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, totalQuantity);
Thread.Sleep(200);
}
AlertMsg alertMsg = new AlertMsg

View File

@ -21,6 +21,7 @@ using DM_Weight.Views;
using SqlSugar;
using System.Threading.Channels;
using DM_Weight.Report;
using System.Threading;
namespace DM_Weight.ViewModels
{
@ -50,7 +51,7 @@ namespace DM_Weight.ViewModels
void DoMyPrismEvent(DeviceMsg msg)
{
logger.Info($"msg.WindowName【{msg.WindowName}】WindowName【{WindowName}】Status【{Status}】EventType【{msg.EventType}】");
if (msg.WindowName.Equals(WindowName))
{
@ -413,6 +414,7 @@ namespace DM_Weight.ViewModels
if (ChannelStock.BoardType == 5)
{
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
Thread.Sleep(200);
}
AlertMsg alertMsg = new AlertMsg

View File

@ -420,7 +420,8 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
Thread.Sleep(200);
}
}
}

View File

@ -382,6 +382,7 @@ namespace DM_Weight.ViewModels
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
Thread.Sleep(200);
}
}
}