This commit is contained in:
alex
2023-08-15 14:27:10 +08:00
parent e09251ef76
commit 2f3cf868d7
10 changed files with 88 additions and 24 deletions

View File

@@ -6,6 +6,7 @@ using System.Reflection;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
using Aspose.Cells.Drawing;
using JNPF;
@@ -32,6 +33,7 @@ using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Interfaces;
@@ -44,6 +46,12 @@ namespace Tnb.WarehouseMgr
{
private static Dictionary<string, IWHStorageService> _stroageMap = new(StringComparer.OrdinalIgnoreCase);
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
private readonly ChannelWriter<NotifyMessage> _channelWriter;
public BaseWareHouseService(ChannelWriter<NotifyMessage>? channelWriter = default)
{
_channelWriter = channelWriter;
}
static BaseWareHouseService()
{
@@ -93,7 +101,18 @@ namespace Tnb.WarehouseMgr
}
return Task.FromResult(isMatch);
}
/// <summary>
/// 发布消息
/// </summary>
/// <param name="taskName"></param>
/// <returns></returns>
[NonAction]
protected async Task Publish(string taskName)
{
NotifyMessage message = new() { TaskName = taskName };
if (_channelWriter != null)
await _channelWriter.WriteAsync(message);
}
[NonAction]
protected async Task DoUpdate(WareHouseUpInput input)

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
@@ -21,6 +22,7 @@ using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
@@ -39,6 +41,7 @@ namespace Tnb.WarehouseMgr
private readonly IWareHouseService _wareHouseService;
private readonly IBillRullService _billRullService;
private readonly IUserManager _userManager;
private readonly ChannelWriter<NotifyMessage> _channelWriter;
public WmsCarryMoveInStockService(
@@ -47,7 +50,9 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService,
IWareHouseService wareHouseService,
IUserManager userManager,
IBillRullService billRullService)
IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{
_db = repository.AsSugarClient();
_runService = runService;
@@ -55,6 +60,7 @@ namespace Tnb.WarehouseMgr
_wareHouseService = wareHouseService;
_userManager = userManager;
_billRullService = billRullService;
OverideFuncs.CreateAsync = CarryMoveIn;
}
@@ -167,6 +173,11 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
throw;
}
finally
{
//向队列写入消息
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true);
}

View File

@@ -45,7 +45,8 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService,
IWareHouseService wareHouseService,
IUserManager userManager,
IBillRullService billRullService)
IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify) : base(taskMessageNotify.Writer)
{
_db = repository.AsSugarClient();
_runService = runService;
@@ -124,7 +125,8 @@ namespace Tnb.WarehouseMgr
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
if (loc.is_sign ==0 ) {
if (loc.is_sign == 0)
{
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
}
var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
@@ -157,6 +159,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
throw;
}
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true);
}
public override async Task ModifyAsync(WareHouseUpInput input)

View File

@@ -43,7 +43,9 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService,
IRunService runService,
IBillRullService billRullService,
IUserManager userManager)
IUserManager userManager,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{
_db = repository.AsSugarClient();
_warehouseService = wareHouseService;
@@ -218,6 +220,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
throw;
}
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(row);
}

View File

@@ -54,8 +54,9 @@ namespace Tnb.WarehouseMgr
IBasLocationService basLocationService,
IWareHouseService wareHouseService,
IUserManager userManager,
IBillRullService billRullService
)
IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{
_db = repository.AsSugarClient();
_runService = runService;
@@ -191,6 +192,10 @@ namespace Tnb.WarehouseMgr
{
throw;
}
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return await Task.FromResult(true);
}
public override async Task ModifyAsync(WareHouseUpInput input)

View File

@@ -55,7 +55,7 @@ namespace Tnb.WarehouseMgr
IUserManager userManager,
IBillRullService billRullService,
ITaskMessageNotify taskMesageNotify
)
) : base(taskMesageNotify.Writer)
{
_db = repository.AsSugarClient();
_runService = runService;
@@ -188,8 +188,7 @@ namespace Tnb.WarehouseMgr
finally
{
//向队列写入消息
NotifyMessage message = new() { TaskName = nameof(IWareHouseService.GenTaskExecute) };
await _channelWriter.WriteAsync(message);
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true);
}

View File

@@ -51,7 +51,9 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService,
IWareHouseService wareHouseService,
IUserManager userManager,
IBillRullService billRullService)
IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{
_db = repository.AsSugarClient();
_runService = runService;
@@ -77,7 +79,8 @@ namespace Tnb.WarehouseMgr
//判断目标库位是否自动签收
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
//出库取起点,获取所有符合输入的载具规格的载具
var OutStockStrategyInput = new OutStockStrategyQuery {
var OutStockStrategyInput = new OutStockStrategyQuery
{
carrystd_id = input.data[nameof(OutStockStrategyQuery.carrystd_id)].ToString(),
warehouse_id = input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString(),
@@ -211,6 +214,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
throw;
}
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true);
}

View File

@@ -51,8 +51,9 @@ namespace Tnb.WarehouseMgr
IUserManager userManager,
IBillRullService billRullService,
IWareHouseService wareHouseService,
IPrdInstockService prdInstockService
)
IPrdInstockService prdInstockService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{
_db = repository.AsSugarClient();
_dictionaryDataService = dictionaryDataService;
@@ -474,6 +475,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
//return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message);
}
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return isSuccessFul;
}
}

View File

@@ -48,7 +48,9 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService,
IWareHouseService wareHouseService,
IUserManager userManager,
IBillRullService billRullService)
IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{
_db = repository.AsSugarClient();
_runService = runService;
@@ -214,6 +216,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync();
throw;
}
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true);
}