齐套出库,齐套分拣,更新明细条码表,再更新明细,最后更新主表
This commit is contained in:
@@ -202,12 +202,50 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var isOk = await _db.Updateable<WmsKittingoutH>().SetColumns(it => new WmsKittingoutH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
||||
var carryId = input.carryIds[^input.carryIds.Count];
|
||||
var kods = await _db.Queryable<WmsKittingoutD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||
//当前载具对应的所有条码插入
|
||||
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId).ToListAsync();
|
||||
var kittingoutCodes = carryCodes.Adapt<List<WmsKittingoutCode>>();
|
||||
kittingoutCodes.ForEach(x =>
|
||||
{
|
||||
var billDId = kods?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
|
||||
if (billDId.IsNullOrEmpty())
|
||||
{
|
||||
billDId = kods?.Find(xx => xx.material_id == x.material_id)?.id;
|
||||
}
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.bill_id = input.requireId;
|
||||
x.bill_d_id = billDId;
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
});
|
||||
var row = await _db.Insertable(kittingoutCodes).ExecuteCommandAsync();
|
||||
var detailIds = kittingoutCodes.Select(x => x.bill_d_id).ToList();
|
||||
var curKittingoutDetails = kods.FindAll(x => detailIds.Contains(x.id));
|
||||
var dic = kittingoutCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList());
|
||||
foreach (var kod in curKittingoutDetails)
|
||||
{
|
||||
if (dic.ContainsKey(kod.id))
|
||||
{
|
||||
kod.qty += dic[kod.id].Sum(d => d);
|
||||
if (kod.qty >= kod.pr_qty)
|
||||
{
|
||||
kod.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
kod.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
await _db.Updateable(curKittingoutDetails).ExecuteCommandAsync();
|
||||
var isOk = await _db.Updateable<WmsKittingoutH>().SetColumns(it => new WmsKittingoutH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync();
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||
if (carry != null)
|
||||
{
|
||||
var row = await _carryService.UpdateNullCarry(carry);
|
||||
row = await _carryService.UpdateNullCarry(carry);
|
||||
isOk = row > 0;
|
||||
}
|
||||
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
|
||||
|
||||
Reference in New Issue
Block a user