入库申请模块代码提交

This commit is contained in:
alex
2023-06-16 17:11:50 +08:00
parent 6c57264782
commit 168d2220ca
7 changed files with 52 additions and 6 deletions

View File

@@ -213,7 +213,7 @@ namespace Tnb.WarehouseMgr
var b = items.Find(x => x.material_code == materialCode && x.code_batch == codeBatch);
if (b != null)
{
b.barcode = jo.Value<string>(nameof(WmsInstockCode.barcode));
b.barcode = jo.Value<string>(nameof(WmsInstockCode.barcode))!;
b.barcode_qty = jo.Value<int>(nameof(WmsInstockCode.barcode_qty));
instockCOdes.Add(b);
}
@@ -245,7 +245,39 @@ namespace Tnb.WarehouseMgr
public override async Task ModifyAsync(WareHouseUpInput input)
{
if (input == null) throw new ArgumentNullException("input");
//更具distaskCode的barcode 更新 instockcode 的 is_end 为 1
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.barcode_qty,
}).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();
if (instockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
{
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
//如果是自动单据,需要回更上层系统
}
}
}
}
}