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

@@ -59,7 +59,7 @@ namespace Tnb.WarehouseMgr
var channelReader = _serviceProvider.GetRequiredService<ITaskMessageNotify>().Reader;
CancellationTokenSource? cts = new();
while (channelReader != null && await channelReader.WaitToReadAsync())
{
while (channelReader.TryRead(out var message))

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,10 +125,11 @@ 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!);
var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
if (isOk)
{
var preTaskUpInput = new GenPreTaskUpInput();
@@ -142,7 +144,7 @@ namespace Tnb.WarehouseMgr
await _db.Updateable<WmsMoveOutstock>().SetColumns(it => new WmsMoveOutstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
it => new WmsCarryH { is_lock = 1},
it => new WmsCarryH { is_lock = 1 },
it => new BasLocation { is_lock = 1 });
}
@@ -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)
@@ -165,5 +171,5 @@ namespace Tnb.WarehouseMgr
var isOk = await _db.Updateable<WmsMoveOutstock>().SetColumns(it => new WmsMoveOutstock { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
}
}
}
}

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;
@@ -70,11 +71,11 @@ namespace Tnb.WarehouseMgr
public async Task<dynamic> GetInStockDetailsListById([FromRoute] string billId)
{
var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID);
var items = await _db.Queryable<WmsInstockD>().LeftJoin<BasWarehouse>((a,b)=>a.warehouse_id == b.id)
var items = await _db.Queryable<WmsInstockD>().LeftJoin<BasWarehouse>((a, b) => a.warehouse_id == b.id)
.Select((a, b) => new WmsInstockD
{
warehouse_name = b.whname
},true)
}, true)
.Where(a => a.bill_id == billId).ToListAsync();
_db.ThenMapper(items,
it => it.line_status = dic.ContainsKey(it.line_status) ? dic[it.line_status]?.ToString()! : "");
@@ -287,7 +288,7 @@ namespace Tnb.WarehouseMgr
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType..ToString());
//如果数据不全或有误,
if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1)
{
@@ -343,7 +344,7 @@ namespace Tnb.WarehouseMgr
await _db.Insertable(instockCOdes).CallEntityMethod(it => it.Create(orgId)).ExecuteCommandAsync();
//生成预任务申请
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
@@ -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);
}
@@ -228,7 +234,7 @@ namespace Tnb.WarehouseMgr
if (kittingOut != null)
{
var locaion = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == kittingOut.location_id);
if (locaion !=null && locaion.is_type.ToEnum<EnumLocationType>() != EnumLocationType.)
if (locaion != null && locaion.is_type.ToEnum<EnumLocationType>() != EnumLocationType.)
{
kittingOut.status = WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID;