1
This commit is contained in:
@@ -171,7 +171,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<dynamic> MesEmptyCarryInStock(MESEmptyCarryInStockInput input)
|
public async Task<dynamic> MesEmptyCarryInStock(MESEmptyCarryInStockInput input)
|
||||||
{
|
{
|
||||||
if(input.IsNull())throw new ArgumentNullException("input");
|
if (input.IsNull()) throw new ArgumentNullException("input");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
|
||||||
@@ -186,16 +186,16 @@ namespace Tnb.WarehouseMgr
|
|||||||
var cols = new List<string>();
|
var cols = new List<string>();
|
||||||
var dic = new Dictionary<string, object>();
|
var dic = new Dictionary<string, object>();
|
||||||
dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId();
|
dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId();
|
||||||
dic[nameof(WmsEmptyInstock.org_id)] = input.org_id;
|
dic[nameof(WmsEmptyInstock.org_id)] = input.org_id ?? _userManager.User.OrganizeId;
|
||||||
dic[nameof(WmsEmptyInstock.location_id)] = location.id;
|
dic[nameof(WmsEmptyInstock.location_id)] = location.id;
|
||||||
dic[nameof(WmsEmptyInstock.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYINSTK_ENCODE);
|
dic[nameof(WmsEmptyInstock.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYINSTK_ENCODE);
|
||||||
dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
||||||
dic[nameof(WmsEmptyInstock.carry_id)] = carry.id;
|
dic[nameof(WmsEmptyInstock.carry_id)] = carry.id;
|
||||||
dic[nameof(WmsEmptyInstock.carry_code)] = input.carry_code;
|
dic[nameof(WmsEmptyInstock.carry_code)] = input.carry_code!;
|
||||||
dic[nameof(WmsEmptyInstock.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
|
dic[nameof(WmsEmptyInstock.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID;
|
||||||
dic[nameof(WmsEmptyInstock.create_id)] = input.create_id;
|
dic[nameof(WmsEmptyInstock.create_id)] = input.create_id ?? _userManager.UserId;
|
||||||
dic[nameof(WmsEmptyInstock.create_time)] = DateTime.Now;
|
dic[nameof(WmsEmptyInstock.create_time)] = DateTime.Now;
|
||||||
dic[nameof(WmsEmptyInstock.warehouse_id)] = input.warehouse_id;
|
dic[nameof(WmsEmptyInstock.warehouse_id)] = input.warehouse_id!;
|
||||||
|
|
||||||
VisualDevModelDataCrInput visualDevModelDataCrInput = new()
|
VisualDevModelDataCrInput visualDevModelDataCrInput = new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -293,11 +293,11 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
await _db.Ado.BeginTranAsync();
|
await _db.Ado.BeginTranAsync();
|
||||||
//出库申请主表
|
//出库申请主表
|
||||||
WmsOutstockH outstock = input.outstock!;
|
WmsOutstockH? outstock = input.outstock;
|
||||||
//出库申请明细表
|
//出库申请明细表
|
||||||
List<WmsOutstockD> outstockDs = input.outstockDs!;
|
List<WmsOutstockD>? outstockDs = input.outstockDs;
|
||||||
//如果数据不全,
|
//如果数据不全,
|
||||||
if (outstock.IsNull() || outstock.location_id.IsNullOrWhiteSpace() || outstockDs?.Count < 1)
|
if ((outstock?.location_id.IsNullOrWhiteSpace() ?? true) || outstockDs?.Count < 1)
|
||||||
{
|
{
|
||||||
//报错, 提示数据不全。
|
//报错, 提示数据不全。
|
||||||
throw new AppFriendlyException("数据不全!", 500);
|
throw new AppFriendlyException("数据不全!", 500);
|
||||||
@@ -326,164 +326,164 @@ namespace Tnb.WarehouseMgr
|
|||||||
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == outstock.location_id.ToString());
|
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == outstock.location_id.ToString());
|
||||||
var carryIds = new List<string>();
|
var carryIds = new List<string>();
|
||||||
//tablefield120 出库物料明细
|
//tablefield120 出库物料明细
|
||||||
var outStockDList = outstockDs.ToObject<List<WmsOutstockD>>();
|
var outStockDList = outstockDs.ToObject<List<WmsOutstockD>>();
|
||||||
if (outStockDList?.Count > 0)
|
if (outStockDList?.Count > 0)
|
||||||
|
{
|
||||||
|
List<WmsCarryMat> carryMats = new();
|
||||||
|
List<WmsCarryCode> carryCodes = new();
|
||||||
|
foreach (var os in outStockDList)
|
||||||
{
|
{
|
||||||
List<WmsCarryMat> carryMats = new();
|
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
||||||
List<WmsCarryCode> carryCodes = new();
|
.Where((a, b, c) => b.material_id == os.material_id && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus.占用 && c.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||||
foreach (var os in outStockDList)
|
.WhereIF(!string.IsNullOrEmpty(os.code_batch), (a, b) => b.code_batch == os.code_batch)
|
||||||
|
.Select<WmsCarryCode>()
|
||||||
|
.ToListAsync();
|
||||||
|
if (carryCodesPart?.Count > 0)
|
||||||
{
|
{
|
||||||
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
|
|
||||||
.Where((a, b, c) => b.material_id == os.material_id && a.is_lock == 0 && !string.IsNullOrEmpty(a.location_id) && a.status == (int)EnumCarryStatus.占用 && c.is_type == ((int)EnumLocationType.存储库位).ToString())
|
|
||||||
.WhereIF(!string.IsNullOrEmpty(os.code_batch), (a, b) => b.code_batch == os.code_batch)
|
|
||||||
.Select<WmsCarryCode>()
|
|
||||||
.ToListAsync();
|
|
||||||
if (carryCodesPart?.Count > 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
carryCodes.AddRange(carryCodesPart);
|
carryCodes.AddRange(carryCodesPart);
|
||||||
var codeQty = carryCodes.Sum(x => x.codeqty);
|
var codeQty = carryCodes.Sum(x => x.codeqty);
|
||||||
if (codeQty < os.pr_qty)
|
if (codeQty < os.pr_qty)
|
||||||
{
|
{
|
||||||
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
throw new AppFriendlyException($"需要出库[{os.pr_qty}],实际库存{codeQty},数量不足", 500);
|
||||||
}
|
|
||||||
List<WmsCarryCode> curCarryCodes = new();
|
|
||||||
for (int i = 0; i < carryCodesPart.Count; i++)
|
|
||||||
{
|
|
||||||
if (os.pr_qty > carryCodesPart[i].codeqty)
|
|
||||||
{
|
|
||||||
os.pr_qty -= carryCodesPart[i].codeqty;
|
|
||||||
curCarryCodes.Add(carryCodesPart[i]);
|
|
||||||
}
|
|
||||||
else if (os.pr_qty <= carryCodesPart[i].codeqty)
|
|
||||||
{
|
|
||||||
carryCodesPart[i].codeqty = os.pr_qty;
|
|
||||||
curCarryCodes.Add(carryCodesPart[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var partCarryMats = curCarryCodes.Adapt<List<WmsCarryMat>>();
|
|
||||||
for (int i = 0; i < partCarryMats.Count; i++)
|
|
||||||
{
|
|
||||||
partCarryMats[i].need_qty = carryCodesPart[i].codeqty;
|
|
||||||
}
|
|
||||||
carryMats.AddRange(partCarryMats);
|
|
||||||
}
|
}
|
||||||
|
List<WmsCarryCode> curCarryCodes = new();
|
||||||
|
for (int i = 0; i < carryCodesPart.Count; i++)
|
||||||
|
{
|
||||||
|
if (os.pr_qty > carryCodesPart[i].codeqty)
|
||||||
|
{
|
||||||
|
os.pr_qty -= carryCodesPart[i].codeqty;
|
||||||
|
curCarryCodes.Add(carryCodesPart[i]);
|
||||||
|
}
|
||||||
|
else if (os.pr_qty <= carryCodesPart[i].codeqty)
|
||||||
|
{
|
||||||
|
carryCodesPart[i].codeqty = os.pr_qty;
|
||||||
|
curCarryCodes.Add(carryCodesPart[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var partCarryMats = curCarryCodes.Adapt<List<WmsCarryMat>>();
|
||||||
|
for (int i = 0; i < partCarryMats.Count; i++)
|
||||||
|
{
|
||||||
|
partCarryMats[i].need_qty = carryCodesPart[i].codeqty;
|
||||||
|
}
|
||||||
|
carryMats.AddRange(partCarryMats);
|
||||||
}
|
}
|
||||||
if (carryMats.Count > 0)
|
|
||||||
{
|
|
||||||
carryMats.ForEach(x => x.id = SnowflakeIdHelper.NextId());
|
|
||||||
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
|
||||||
.Select(x =>
|
|
||||||
{
|
|
||||||
WmsCarryMat? carryMat = x.FirstOrDefault()!;
|
|
||||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
|
||||||
return carryMat;
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
|
||||||
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
|
||||||
var allOutIds = new List<string>();
|
|
||||||
var sortingOutIds = new List<string>();
|
|
||||||
foreach (var pair in dic)
|
|
||||||
{
|
|
||||||
var codes = carryCodes.FindAll(x => x.carry_id == pair.Key);
|
|
||||||
if (codes?.Count > 0)
|
|
||||||
{
|
|
||||||
if (pair.Value == codes.Sum(d => d.codeqty))
|
|
||||||
{
|
|
||||||
allOutIds.Add(pair.Key);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sortingOutIds.Add(pair.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
|
||||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
|
||||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
|
||||||
if (carrys?.Count > 0)
|
|
||||||
{
|
|
||||||
List<WmsPretaskH> preTasks = new();
|
|
||||||
List<string> locIds = new();
|
|
||||||
foreach (var carry in carrys)
|
|
||||||
{
|
|
||||||
WmsPointH sPoint = null!;
|
|
||||||
WmsPointH ePoint = null!;
|
|
||||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
|
||||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == outstock.location_id.ToString());
|
|
||||||
|
|
||||||
if (sPoint != null && ePoint != null)
|
|
||||||
{
|
|
||||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
|
||||||
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
|
||||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
|
||||||
if (points?.Count > 0)
|
|
||||||
{
|
|
||||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
|
||||||
var curPreTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
|
||||||
{
|
|
||||||
var sPoint = it.FirstOrDefault();
|
|
||||||
var ePoint = it.LastOrDefault();
|
|
||||||
|
|
||||||
WmsPretaskH preTask = new()
|
|
||||||
{
|
|
||||||
org_id = _userManager.User.OrganizeId,
|
|
||||||
startlocation_id = sPoint?.location_id!,
|
|
||||||
startlocation_code = sPoint?.location_code!,
|
|
||||||
endlocation_id = ePoint?.location_id!,
|
|
||||||
endlocation_code = ePoint?.location_code!,
|
|
||||||
start_floor = sPoint?.floor.ToString(),
|
|
||||||
end_floor = ePoint?.floor.ToString(),
|
|
||||||
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
|
||||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
|
||||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSOUTSTOCK_ID,
|
|
||||||
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
|
|
||||||
carry_id = carry.id,
|
|
||||||
carry_code = carry.carry_code,
|
|
||||||
area_id = sPoint?.area_id!,
|
|
||||||
area_code = it.Key,
|
|
||||||
require_id = outstock.id.ToString()
|
|
||||||
};
|
|
||||||
preTask.require_code = outstock.bill_code?.ToString()!;
|
|
||||||
preTask.create_id = _userManager.UserId;
|
|
||||||
preTask.create_time = DateTime.Now;
|
|
||||||
return preTask;
|
|
||||||
}).ToList();
|
|
||||||
if (loc.is_sign == 0)
|
|
||||||
{
|
|
||||||
curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
|
||||||
}
|
|
||||||
preTasks.AddRange(curPreTasks);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<WmsPretaskCode> pretaskCodes = new();
|
|
||||||
foreach (var pt in preTasks)
|
|
||||||
{
|
|
||||||
var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
|
|
||||||
var curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
|
|
||||||
curPreTaskCodes.ForEach(x =>
|
|
||||||
{
|
|
||||||
x.id = SnowflakeIdHelper.NextId();
|
|
||||||
x.bill_id = pt.id;
|
|
||||||
x.create_time = DateTime.Now;
|
|
||||||
});
|
|
||||||
pretaskCodes.AddRange(curPreTaskCodes);
|
|
||||||
}
|
|
||||||
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
|
||||||
GenPreTaskUpInput genPreTaskAfterUpInput = new();
|
|
||||||
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
|
|
||||||
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
|
|
||||||
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
|
|
||||||
}
|
|
||||||
else throw new AppFriendlyException("库存不足", 500);
|
|
||||||
}
|
}
|
||||||
else throw new AppFriendlyException($"请输入物料明细", 500);
|
if (carryMats.Count > 0)
|
||||||
|
{
|
||||||
|
carryMats.ForEach(x => x.id = SnowflakeIdHelper.NextId());
|
||||||
|
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||||
|
.Select(x =>
|
||||||
|
{
|
||||||
|
WmsCarryMat? carryMat = x.FirstOrDefault()!;
|
||||||
|
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||||
|
return carryMat;
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||||
|
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
||||||
|
var allOutIds = new List<string>();
|
||||||
|
var sortingOutIds = new List<string>();
|
||||||
|
foreach (var pair in dic)
|
||||||
|
{
|
||||||
|
var codes = carryCodes.FindAll(x => x.carry_id == pair.Key);
|
||||||
|
if (codes?.Count > 0)
|
||||||
|
{
|
||||||
|
if (pair.Value == codes.Sum(d => d.codeqty))
|
||||||
|
{
|
||||||
|
allOutIds.Add(pair.Key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sortingOutIds.Add(pair.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
carryIds = allOutIds.Concat(sortingOutIds).ToList();
|
||||||
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
|
||||||
|
if (carrys?.Count > 0)
|
||||||
|
{
|
||||||
|
List<WmsPretaskH> preTasks = new();
|
||||||
|
List<string> locIds = new();
|
||||||
|
foreach (var carry in carrys)
|
||||||
|
{
|
||||||
|
WmsPointH sPoint = null!;
|
||||||
|
WmsPointH ePoint = null!;
|
||||||
|
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
|
||||||
|
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == outstock.location_id.ToString());
|
||||||
|
|
||||||
|
if (sPoint != null && ePoint != null)
|
||||||
|
{
|
||||||
|
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||||
|
locIds.AddRange(points.Select(x => x.location_id).ToList()!);
|
||||||
|
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||||
|
if (points?.Count > 0)
|
||||||
|
{
|
||||||
|
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||||
|
var curPreTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||||
|
{
|
||||||
|
var sPoint = it.FirstOrDefault();
|
||||||
|
var ePoint = it.LastOrDefault();
|
||||||
|
|
||||||
|
WmsPretaskH preTask = new()
|
||||||
|
{
|
||||||
|
org_id = _userManager.User.OrganizeId,
|
||||||
|
startlocation_id = sPoint?.location_id!,
|
||||||
|
startlocation_code = sPoint?.location_code!,
|
||||||
|
endlocation_id = ePoint?.location_id!,
|
||||||
|
endlocation_code = ePoint?.location_code!,
|
||||||
|
start_floor = sPoint?.floor.ToString(),
|
||||||
|
end_floor = ePoint?.floor.ToString(),
|
||||||
|
bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||||
|
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||||
|
biz_type = WmsWareHouseConst.BIZTYPE_WMSOUTSTOCK_ID,
|
||||||
|
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
|
||||||
|
carry_id = carry.id,
|
||||||
|
carry_code = carry.carry_code,
|
||||||
|
area_id = sPoint?.area_id!,
|
||||||
|
area_code = it.Key,
|
||||||
|
require_id = outstock.id.ToString()
|
||||||
|
};
|
||||||
|
preTask.require_code = outstock.bill_code?.ToString()!;
|
||||||
|
preTask.create_id = _userManager.UserId;
|
||||||
|
preTask.create_time = DateTime.Now;
|
||||||
|
return preTask;
|
||||||
|
}).ToList();
|
||||||
|
if (loc.is_sign == 0)
|
||||||
|
{
|
||||||
|
curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||||
|
}
|
||||||
|
preTasks.AddRange(curPreTasks);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<WmsPretaskCode> pretaskCodes = new();
|
||||||
|
foreach (var pt in preTasks)
|
||||||
|
{
|
||||||
|
var partCodes = carryCodes.FindAll(x => x.carry_id == pt.carry_id).Distinct().ToList();
|
||||||
|
var curPreTaskCodes = partCodes.Adapt<List<WmsPretaskCode>>();
|
||||||
|
curPreTaskCodes.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.id = SnowflakeIdHelper.NextId();
|
||||||
|
x.bill_id = pt.id;
|
||||||
|
x.create_time = DateTime.Now;
|
||||||
|
});
|
||||||
|
pretaskCodes.AddRange(curPreTaskCodes);
|
||||||
|
}
|
||||||
|
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||||
|
GenPreTaskUpInput genPreTaskAfterUpInput = new();
|
||||||
|
genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList();
|
||||||
|
genPreTaskAfterUpInput.LocationIds = new HashSet<string>(locIds).ToList();
|
||||||
|
await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 });
|
||||||
|
}
|
||||||
|
else throw new AppFriendlyException("库存不足", 500);
|
||||||
|
}
|
||||||
|
else throw new AppFriendlyException($"请输入物料明细", 500);
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
await _db.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
@@ -498,9 +498,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
|
|
||||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||||
{
|
{
|
||||||
if (input == null) throw new ArgumentNullException("input");
|
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -113,13 +113,12 @@ namespace Tnb.WarehouseMgr
|
|||||||
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch })
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
WmsCarryMat? carryMat = x.FirstOrDefault()!;
|
WmsCarryMat? carryMat = x.FirstOrDefault();
|
||||||
carryMat.need_qty = x.Sum(d => d.need_qty);
|
carryMat.need_qty = x.Sum(d => d.need_qty);
|
||||||
return carryMat;
|
return carryMat;
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
await _db.Insertable(carryMats).ExecuteCommandAsync();
|
||||||
var dic = carryMats.DistinctBy(x => x.carry_id).ToDictionary(x => x.carry_id, x => x.need_qty);
|
|
||||||
|
|
||||||
carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList();
|
carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList();
|
||||||
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString(), collocation_scheme_id = singleSorting.collocation_scheme_id, collocation_scheme_code = singleSorting.collocation_scheme_code }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync();
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString(), collocation_scheme_id = singleSorting.collocation_scheme_id, collocation_scheme_code = singleSorting.collocation_scheme_code }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync();
|
||||||
@@ -280,10 +279,10 @@ namespace Tnb.WarehouseMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await _db.Updateable(curSortingDetails).ExecuteCommandAsync();
|
await _db.Updateable(curSortingDetails).ExecuteCommandAsync();
|
||||||
if(curSortingDetails.All(it=>it.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
if (curSortingDetails.All(it => it.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
||||||
{
|
{
|
||||||
|
|
||||||
await _db.Updateable<WmsSetsortingH>().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
await _db.Updateable<WmsSetsortingH>().SetColumns(it => new WmsSetsortingH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
||||||
if (carry != null)
|
if (carry != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user