齐套出库,齐套分拣,更新明细条码表,再更新明细,最后更新主表
This commit is contained in:
@@ -240,6 +240,44 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var carryId = input.carryIds[^input.carryIds.Count];
|
||||
var ssds = await _db.Queryable<WmsSetsortingD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId).ToListAsync();
|
||||
|
||||
var sortingCoees = carryCodes.Adapt<List<WmsSetsortingCode>>();
|
||||
sortingCoees.ForEach(x =>
|
||||
{
|
||||
var billDId = ssds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id;
|
||||
if (billDId.IsNullOrEmpty())
|
||||
{
|
||||
billDId = ssds?.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;
|
||||
});
|
||||
await _db.Insertable(sortingCoees).ExecuteCommandAsync();
|
||||
var detailIds = sortingCoees.Select(x => x.bill_d_id).ToList();
|
||||
var curSortingDetails = ssds.FindAll(x => detailIds.Contains(x.id));
|
||||
var dic = sortingCoees.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList());
|
||||
foreach (var osd in curSortingDetails)
|
||||
{
|
||||
if (dic.ContainsKey(osd.id))
|
||||
{
|
||||
osd.qty += dic[osd.id].Sum(d => d);
|
||||
if (osd.qty >= osd.pr_qty)
|
||||
{
|
||||
osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
osd.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
await _db.Updateable(curSortingDetails).ExecuteCommandAsync();
|
||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||
if (carry != null)
|
||||
{
|
||||
@@ -251,7 +289,7 @@ namespace Tnb.WarehouseMgr
|
||||
carry.carry_status = ((int)EnumCarryStatus.齐套).ToString();
|
||||
carry.location_id = null;
|
||||
carry.location_code = null;
|
||||
await _db.Updateable(carry).UpdateColumns(it => new { it.out_status,it.carry_status, it.location_id, it.location_code }).ExecuteCommandAsync();
|
||||
await _db.Updateable(carry).UpdateColumns(it => new { it.out_status, it.carry_status, it.location_id, it.location_code }).ExecuteCommandAsync();
|
||||
await _db.Deleteable<WmsCarryMat>().Where(it => it.carry_id == carryId).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user