将定时任务改为,发布、订阅模式的消息队列执行任务
This commit is contained in:
@@ -42,6 +42,7 @@ using Tnb.BasicData.Entities.Enums;
|
||||
using Tnb.Common.Extension;
|
||||
using Tnb.Common.Utils;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Configs;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
@@ -222,16 +223,16 @@ namespace Tnb.WarehouseMgr
|
||||
/// 生成任务执行
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[HttpPost, Timed(Name = nameof(IWareHouseService.GenTaskExecute))]
|
||||
public async Task GenTaskExecute(CancellationTokenSource? cts = default)
|
||||
{
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
CancellationTokenSource agvCts = new();
|
||||
|
||||
//获取用户登录令牌
|
||||
var aToken = await _cacheManager.GetAsync("AsscessToken");
|
||||
if (aToken.IsNullOrWhiteSpace()) return;
|
||||
var curUser = await GetUserIdentity(aToken);
|
||||
//var aToken = await _cacheManager.GetAsync("AsscessToken");
|
||||
//if (aToken.IsNullOrWhiteSpace()) return;
|
||||
//var curUser = await GetUserIdentity(aToken);
|
||||
|
||||
var db = _db.CopyNew();
|
||||
try
|
||||
@@ -239,7 +240,7 @@ namespace Tnb.WarehouseMgr
|
||||
//获取所有未下发的预任务申请
|
||||
var preTasks = await db.Queryable<WmsPretaskH>().InnerJoin<WmsCarryH>((a, b) => a.startlocation_id == b.location_id && a.carry_id == b.id)
|
||||
.InnerJoin<WmsAreaH>((a, b, c) => a.area_id == c.id)
|
||||
.Where(a => a.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID)
|
||||
.Where(a => a.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID && !string.IsNullOrWhiteSpace(a.startlocation_id))
|
||||
.OrderBy(a => new { priority = SqlFunc.Desc(a.priority), a.bill_code })
|
||||
.Select((a, b, c) => new WmsPretaskH
|
||||
{
|
||||
@@ -379,18 +380,9 @@ namespace Tnb.WarehouseMgr
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("生成预任务执行时出现错误", ex);
|
||||
var opts = curUser.FindFirst(ClaimConst.CONNECTIONCONFIG)?.Value;
|
||||
|
||||
TimedTaskErrorInfo ei = new()
|
||||
{
|
||||
RequestURL = App.HttpContext?.Request?.Path,
|
||||
RequestMethod = App.HttpContext?.Request?.Method,
|
||||
userIdentity = curUser,
|
||||
};
|
||||
var timedTaskEx = ex.ToTimedTaskException(ei);
|
||||
await db.Ado.RollbackTranAsync();
|
||||
cts?.Cancel();
|
||||
throw timedTaskEx;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -531,11 +523,15 @@ namespace Tnb.WarehouseMgr
|
||||
locIts.Add(loc);
|
||||
|
||||
}
|
||||
|
||||
await _db.Updateable(carryIts).UpdateColumns(it => new { it.is_lock, it.location_id, it.location_code }).ExecuteCommandAsync();
|
||||
|
||||
//更新条码的库位和仓库信息
|
||||
await _db.Updateable(carryCodeIts).UpdateColumns(it => new { it.warehouse_id, it.location_id, it.location_code }).Where(it => multiList.Select(x => x.carry_id).Contains(it.carry_id)).ExecuteCommandAsync();
|
||||
var carryIdItor = multiList.Select(x => x.carry_id);
|
||||
await _db.Updateable(carryCodeIts).UpdateColumns(it => new { it.warehouse_id, it.location_id, it.location_code }).Where(it => it.carry_id.In(carryIdItor)).ExecuteCommandAsync();
|
||||
//更新库位信息,使用状态为 使用,锁定状态为未锁定
|
||||
await _db.Updateable(locIts).UpdateColumns(it => new { it.is_use, it.is_lock }).Where(it => multiList.Select(x => x.endlocation_id).Contains(it.id)).ExecuteCommandAsync();
|
||||
var locIdItor = multiList.Select(x => x.endlocation_id);
|
||||
await _db.Updateable(locIts).UpdateColumns(it => new { it.is_use, it.is_lock }).Where(it => it.id.In(locIdItor)).ExecuteCommandAsync();
|
||||
//更新业务主表的单据状态
|
||||
foreach (var dt in disTasks)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user