去除Modify

This commit is contained in:
FanLian
2023-09-06 11:30:45 +08:00
parent 681c4866c6
commit 1077114c34

View File

@@ -238,70 +238,5 @@ namespace Tnb.WarehouseMgr
}
return Task.FromResult(true);
}
public override async Task ModifyAsync(WareHouseUpInput input)
{
if (input == null) throw new ArgumentNullException(nameof(input));
//更具distaskCode的barcode 更新 instockcode 的 is_end 为 1
try
{
await _db.Ado.BeginTranAsync();
if (input.distaskCodes?.Count > 0)
{
var barCodes = input.distaskCodes.Select(x => x.barcode);
await _db.Updateable<WmsInstockCode>().SetColumns(it => new WmsInstockCode { is_end = 1 }).Where(it => barCodes.Contains(it.barcode)).ExecuteCommandAsync();
var instockCodes = await _db.Queryable<WmsInstockCode>().Where(it => barCodes.Contains(it.barcode)).Select(it => new
{
id = it.bill_d_id,
barcode_qty = it.codeqty,
}).ToListAsync();
var dic = instockCodes.GroupBy(g => g.id).ToDictionary(x => x.Key, x => x.Select(d => d.barcode_qty).ToList());
var ids = instockCodes.Select(it => it.id).ToList();
var instockDetails = await _db.Queryable<WmsInstockD>().Where(it => ids.Contains(it.id)).ToListAsync();
foreach (var item in instockDetails)
{
if (dic.ContainsKey(item.id))
{
item.qty += dic[item.id].Sum(x => x);
if (item.qty >= item.pr_qty)
{
item.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
}
}
}
await _db.Updateable(instockDetails).ExecuteCommandAsync();
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
{
//如果是自动单据,需要回更上层系统
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } };
var callBackRes = await _prdInstockService.SyncInstock(pars);
instock!.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
}
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
{
instock.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
}
else
{
//任务没有结束,更新状态为工作中
instock.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
}
await _db.Updateable(instock).UpdateColumns(it => it.status).ExecuteCommandAsync();
}
await _db.Ado.CommitTranAsync();
}
catch (Exception)
{
await _db.Ado.RollbackTranAsync();
throw;
}
}
}
}