写标签添加线程休息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 /// 默认值: NULL
///</summary> ///</summary>
//[SugarColumn(ColumnName = "order_id")] [SugarColumn(ColumnName = "order_id")]
//public int? OrderId { get; set; } public int? OrderId { get; set; }
/// <summary> /// <summary>
/// ///
///</summary> ///</summary>

View File

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

View File

@ -577,6 +577,7 @@ namespace DM_Weight.ViewModels
_portUtil.ShowContent(item.DrawerNo, item.ColNo); _portUtil.ShowContent(item.DrawerNo, item.ColNo);
Thread.Sleep(200); Thread.Sleep(200);
_portUtil.WriteQuantity(item.DrawerNo, item.ColNo, item.totalCount); _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); _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); _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.msg;
using DM_Weight.Port; using DM_Weight.Port;
using DM_Weight.util; using DM_Weight.util;
using System.Threading;
namespace DM_Weight.ViewModels namespace DM_Weight.ViewModels
{ {
@ -257,6 +258,7 @@ namespace DM_Weight.ViewModels
singleChannels.ForEach(it => singleChannels.ForEach(it =>
{ {
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity); _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.Port;
using DM_Weight.util; using DM_Weight.util;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Threading;
namespace DM_Weight.ViewModels namespace DM_Weight.ViewModels
{ {
@ -332,6 +333,7 @@ namespace DM_Weight.ViewModels
singleChannels.ForEach(it => singleChannels.ForEach(it =>
{ {
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
Thread.Sleep(200);
}); });
} }
RequestData(); 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)); _portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) + singleChannels.Sum(it => it.AddQuantity));
Thread.Sleep(200);
//singleChannels.ForEach(it => //singleChannels.ForEach(it =>
//{ //{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity); // _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)); _portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.AddQuantity));
Thread.Sleep(200);
//singleChannels.ForEach(it => //singleChannels.ForEach(it =>
//{ //{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity); // _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);

View File

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

View File

@ -440,6 +440,7 @@ namespace DM_Weight.ViewModels
.Sum(it => it.Quantity); .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

@ -460,6 +460,7 @@ namespace DM_Weight.ViewModels
.Sum(it => it.Quantity); .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

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

View File

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

View File

@ -421,6 +421,7 @@ namespace DM_Weight.ViewModels
.Sum(it => it.Quantity); .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); .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);
} }
} }
} }