还原代码解决系统崩溃问题
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
|
namespace Tnb.WarehouseMgr
|
||||||
|
{
|
||||||
|
public class ConditionalBackgroundService : IHostedService
|
||||||
|
{
|
||||||
|
private readonly IHostedService _backgroundService;
|
||||||
|
//private readonly Func<bool> _condition;
|
||||||
|
|
||||||
|
public ConditionalBackgroundService(IHostedService backgroundService)
|
||||||
|
{
|
||||||
|
_backgroundService = backgroundService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await _backgroundService.StartAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
public async Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await _backgroundService.StopAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,32 +25,33 @@ namespace Tnb.WarehouseMgr
|
|||||||
public class TimedTaskBackgroundService : BackgroundService
|
public class TimedTaskBackgroundService : BackgroundService
|
||||||
{
|
{
|
||||||
private ISendMessageService? _sendService;
|
private ISendMessageService? _sendService;
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
||||||
|
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
await Task.Run(() =>
|
{
|
||||||
{
|
//_sendService = App.GetRequiredService<ISendMessageService>();
|
||||||
_sendService = App.GetRequiredService<ISendMessageService>();
|
List<string> toUserIds = new List<string>() { "25398501929509" };
|
||||||
var userManager = App.GetRequiredService<IUserManager>();
|
//生成任务执行
|
||||||
List<string> toUserIds = new List<string>() { "25398501929509" };
|
CancellationTokenSource genTaskCTS = new();
|
||||||
//生成任务执行
|
CancellationTokenSource kittingOutAddCts = new();
|
||||||
CancellationTokenSource genTaskCTS = new();
|
CancellationTokenSource kittingOutShippedCts = new();
|
||||||
CancellationTokenSource kittingOutAddCts = new();
|
CancellationTokenSource setSortingCts = new();
|
||||||
CancellationTokenSource kittingOutShippedCts = new();
|
|
||||||
CancellationTokenSource setSortingCts = new();
|
|
||||||
|
|
||||||
var wareHouseService = App.GetRequiredService<IWareHouseService>();
|
var wareHouseService = App.GetRequiredService<IWareHouseService>();
|
||||||
TimedTask(cts => wareHouseService.GenTaskExecute(cts), genTaskCTS, toUserIds);
|
TimedTask(cts => wareHouseService.GenTaskExecute(cts), genTaskCTS, toUserIds);
|
||||||
//齐套出库
|
//齐套出库
|
||||||
|
|
||||||
var kittingOutService = App.GetRequiredService<IWmskittingOutService>();
|
var kittingOutService = App.GetRequiredService<IWmskittingOutService>();
|
||||||
TimedTask(cts => kittingOutService.KittingOutByAdd(cts), kittingOutAddCts, toUserIds);
|
TimedTask(cts => kittingOutService.KittingOutByAdd(cts), kittingOutAddCts, toUserIds);
|
||||||
TimedTask(cts => kittingOutService.KittingOutByIsToBeShipped(cts), kittingOutShippedCts, toUserIds);
|
TimedTask(cts => kittingOutService.KittingOutByIsToBeShipped(cts), kittingOutShippedCts, toUserIds);
|
||||||
//齐套分拣
|
//齐套分拣
|
||||||
var setSortingService = App.GetRequiredService<IWmsSetSortingService>();
|
var setSortingService = App.GetRequiredService<IWmsSetSortingService>();
|
||||||
TimedTask(cts => setSortingService.PackSortingByAdd(cts), setSortingCts, toUserIds);
|
TimedTask(cts => setSortingService.PackSortingByAdd(cts), setSortingCts, toUserIds);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Task TimedTask(Func<CancellationTokenSource, Task> action, CancellationTokenSource cts, List<string>? toUserIds = default)
|
private Task TimedTask(Func<CancellationTokenSource, Task> action, CancellationTokenSource cts, List<string>? toUserIds = default)
|
||||||
{
|
{
|
||||||
var token = cts.Token;
|
var token = cts.Token;
|
||||||
@@ -60,9 +61,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await action(cts).Catch(ex =>
|
await action(cts).Catch(ex =>
|
||||||
{
|
{
|
||||||
//MessageSendModel messageSendModel = new();
|
//notify operator
|
||||||
//_sendService?.SendMessage();
|
|
||||||
//messageService.SentMessage(toUserIds!, ex.Message, ex.ToString());
|
|
||||||
});
|
});
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,7 +283,6 @@ namespace Tnb.WarehouseMgr
|
|||||||
start = end;
|
start = end;
|
||||||
end = Math.Min((end + moveNum), arrary.Length);
|
end = Math.Min((end + moveNum), arrary.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var arr in arrList)
|
foreach (var arr in arrList)
|
||||||
{
|
{
|
||||||
for (int j = 1, len = arr.Length; j <= len; j++)
|
for (int j = 1, len = arr.Length; j <= len; j++)
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
visualDevModelCrInput.data[nameof(WmsKittingInstock.create_time)] = DateTime.Now;
|
visualDevModelCrInput.data[nameof(WmsKittingInstock.create_time)] = DateTime.Now;
|
||||||
visualDevModelCrInput.data[nameof(WmsKittingInstock.location_id)] = carry!.location_id!;
|
visualDevModelCrInput.data[nameof(WmsKittingInstock.location_id)] = carry!.location_id!;
|
||||||
visualDevModelCrInput.data[nameof(WmsKittingInstock.bill_code)] = _billRullService.GetBillNumber("WmsKittingInStk").GetAwaiter().GetResult();
|
visualDevModelCrInput.data[nameof(WmsKittingInstock.bill_code)] = _billRullService.GetBillNumber("WmsKittingInStk").GetAwaiter().GetResult();
|
||||||
visualDevModelCrInput.data[nameof(WmsKittingInstock.source_id)] = kittingout.source_id;
|
visualDevModelCrInput.data[nameof(WmsKittingInstock.source_id)] = kittingout.id;
|
||||||
visualDevModelCrInput.data[nameof(WmsKittingInstock.source_code)] = kittingout.source_code;
|
visualDevModelCrInput.data[nameof(WmsKittingInstock.source_code)] = kittingout.bill_code;
|
||||||
|
|
||||||
|
|
||||||
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == kittingout.location_id);
|
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == kittingout.location_id);
|
||||||
|
|||||||
@@ -155,6 +155,8 @@ namespace Tnb.WarehouseMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task KittingOutByIsToBeShipped(CancellationTokenSource? cts = default)
|
public async Task KittingOutByIsToBeShipped(CancellationTokenSource? cts = default)
|
||||||
{
|
{
|
||||||
|
if (_userManager.User == null) return;
|
||||||
|
|
||||||
var curDb = _db.CopyNew();
|
var curDb = _db.CopyNew();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
|
|||||||
// 非多租户模式启动自启任务
|
// 非多租户模式启动自启任务
|
||||||
if (!KeyVariable.MultiTenancy)
|
if (!KeyVariable.MultiTenancy)
|
||||||
{
|
{
|
||||||
_repository.AsQueryable().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(x=>AddTimerJob(x,false));//modifyby zhoukeda 20230607
|
_repository.AsSugarClient().CopyNew().Queryable<TimeTaskEntity>().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(x=>AddTimerJob(x,false));//modifyby zhoukeda 20230607
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user