Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -57,44 +57,56 @@ namespace Tnb.WarehouseMgr
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken) => Task.Run(async () =>
|
||||
{
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
var queueTask = Task.Run(async () =>
|
||||
{
|
||||
|
||||
var channelReader = _serviceProvider.GetRequiredService<ITaskMessageNotify>().Reader;
|
||||
var channelReader = _serviceProvider.GetRequiredService<ITaskMessageNotify>().Reader;
|
||||
|
||||
CancellationTokenSource? cts = new();
|
||||
CancellationTokenSource? cts = new();
|
||||
|
||||
while (channelReader != null && await channelReader.WaitToReadAsync())
|
||||
{
|
||||
while (channelReader.TryRead(out var message))
|
||||
{
|
||||
if (_timedFuncMap.ContainsKey(message.TaskName))
|
||||
{
|
||||
await _timedFuncMap[message.TaskName].Invoke(cts);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (channelReader != null && await channelReader.WaitToReadAsync())
|
||||
{
|
||||
while (channelReader.TryRead(out var message))
|
||||
{
|
||||
if (_timedFuncMap.ContainsKey(message.TaskName))
|
||||
{
|
||||
await _timedFuncMap[message.TaskName].Invoke(cts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, stoppingToken);
|
||||
|
||||
var timedTask = Task.Run(() =>
|
||||
{
|
||||
_eventPublisher = App.GetRequiredService<IEventPublisher>();
|
||||
////生成任务执行
|
||||
//CancellationTokenSource genTaskCTS = new();
|
||||
CancellationTokenSource kittingOutAddCts = new();
|
||||
CancellationTokenSource kittingOutShippedCts = new();
|
||||
CancellationTokenSource setSortingCts = new();
|
||||
CancellationTokenSource isMinStorageCts = new();
|
||||
//var wareHouseService = App.GetRequiredService<IWareHouseService>();
|
||||
//TimedTask(cts => wareHouseService.GenTaskExecute(cts), genTaskCTS);
|
||||
//齐套出库
|
||||
var kittingOutService = App.GetRequiredService<IWmskittingOutService>();
|
||||
TimedTask(cts => kittingOutService.KittingOutByAdd(cts), kittingOutAddCts, 1);
|
||||
TimedTask(cts => kittingOutService.KittingOutByIsToBeShipped(cts), kittingOutShippedCts, 1);
|
||||
//齐套分拣
|
||||
var setSortingService = App.GetRequiredService<IWmsSetSortingService>();
|
||||
TimedTask(cts => setSortingService.PackSortingByAdd(cts), setSortingCts, 1);
|
||||
|
||||
var transferSignService = App.GetRequiredService<IWmsPDATransferSignService>();
|
||||
TimedTask(cts => transferSignService.IsMinStorage(cts), isMinStorageCts, 30, TimeSpanUnit.Minutes);
|
||||
|
||||
});
|
||||
|
||||
return Task.WhenAll(queueTask, timedTask);
|
||||
}
|
||||
|
||||
#region 定时
|
||||
//_eventPublisher = App.GetRequiredService<IEventPublisher>();
|
||||
//List<string> toUserIds = new List<string>() { "25398501929509" };
|
||||
////生成任务执行
|
||||
//CancellationTokenSource genTaskCTS = new();
|
||||
//CancellationTokenSource kittingOutAddCts = new();
|
||||
//CancellationTokenSource kittingOutShippedCts = new();
|
||||
//CancellationTokenSource setSortingCts = new();
|
||||
|
||||
//var wareHouseService = App.GetRequiredService<IWareHouseService>();
|
||||
//TimedTask(cts => wareHouseService.GenTaskExecute(cts), genTaskCTS);
|
||||
//齐套出库
|
||||
var kittingOutService = App.GetRequiredService<IWmskittingOutService>();
|
||||
TimedTask(cts => kittingOutService.KittingOutByAdd(cts), kittingOutAddCts, 1);
|
||||
TimedTask(cts => kittingOutService.KittingOutByIsToBeShipped(cts), kittingOutShippedCts, 1);
|
||||
//齐套分拣
|
||||
var setSortingService = App.GetRequiredService<IWmsSetSortingService>();
|
||||
TimedTask(cts => setSortingService.PackSortingByAdd(cts), setSortingCts, 1);
|
||||
#endregion
|
||||
}, stoppingToken);
|
||||
|
||||
private Task TimedTask(Func<CancellationTokenSource, Task> action, CancellationTokenSource cts, int interval, TimeSpanUnit timeType = TimeSpanUnit.Seconds)
|
||||
{
|
||||
@@ -136,6 +148,7 @@ namespace Tnb.WarehouseMgr
|
||||
TimeSpanUnit.Minutes => Task.Delay(TimeSpan.FromMinutes(interval)),
|
||||
TimeSpanUnit.Hours => Task.Delay(TimeSpan.FromHours(interval)),
|
||||
TimeSpanUnit.Days => Task.Delay(TimeSpan.FromDays(interval)),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
return delayTask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user