This commit is contained in:
FanLian
2023-08-14 09:08:05 +08:00
18 changed files with 390 additions and 14 deletions

View File

@@ -32,7 +32,7 @@ namespace Tnb.WarehouseMgr
/// </summary>
public class TimedTaskBackgroundService : BackgroundService
{
private IEventPublisher _eventPublisher;
private IEventPublisher _eventPublisher = default!;
protected override Task ExecuteAsync(CancellationToken stoppingToken) => Task.Run(() =>
{

View File

@@ -500,18 +500,37 @@ namespace Tnb.WarehouseMgr
//更新载具,锁定状态为未锁定,更新载具的库位当前任务的目标库位
var multiList = disTasks.Select(it => (it.carry_id, it.endlocation_id, it.endlocation_code)).ToList();
var locWhIdMap = await _db.Queryable<BasLocation>().Where(it => multiList.Select(x => x.endlocation_id).Contains(it.id)).ToDictionaryAsync(it => it.id, it => it.wh_id);
List<WmsCarryH> carryIts = new();
List<WmsCarryCode> carryCodeIts = new();
for (int i = 0; i < multiList.Count; i++)
{
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { is_lock = 0, location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync();
//更新条码的库位和仓库信息
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.id == multiList[i].carry_id).ToListAsync();
if (carryCodes?.Count > 0)
WmsCarryH carry = new()
{
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == multiList[i].endlocation_id);
await _db.Updateable<WmsCarryCode>().SetColumns(it => new WmsCarryCode { warehouse_id = loc.wh_id, location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync();
}
}
id = multiList[i].carry_id,
is_lock = 0,
location_id = multiList[i].endlocation_id,
location_code = multiList[i].endlocation_code
};
WmsCarryCode carryCode = new()
{
warehouse_id = locWhIdMap[multiList[i].endlocation_id].ToString(),
location_id = multiList[i].endlocation_id,
location_code = multiList[i].endlocation_code
};
carryIts.Add(carry);
carryCodeIts.Add(carryCode);
//await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { is_lock = 0, location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync();
////更新条码的库位和仓库信息
//var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.id == multiList[i].carry_id).ToListAsync();
//if (carryCodes?.Count > 0)
//{
// await _db.Updateable<WmsCarryCode>().SetColumns(it => new WmsCarryCode { warehouse_id = locWhIdMap[multiList[i].endlocation_id].ToString(), location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync();
//}
}
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 multis = disTasks.Select(it => (it.endlocation_id, it.carry_status)).ToList();
for (int i = 0; i < multis.Count; i++)