修复bug
This commit is contained in:
@@ -47,24 +47,19 @@ namespace WMS.Web.Domain.Services
|
|||||||
public async Task<Result> Save(SaveOutStockRequest dto, LoginInDto loginInfo)
|
public async Task<Result> Save(SaveOutStockRequest dto, LoginInDto loginInfo)
|
||||||
{
|
{
|
||||||
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
|
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
|
||||||
OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId);
|
//OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId);
|
||||||
|
|
||||||
if (entity == null)
|
OutStock entity = new OutStock();
|
||||||
entity = new OutStock();
|
|
||||||
entity.Create(loginInfo.UserInfo.StaffId, outStockTask.Id, outStockTask.Type);
|
entity.Create(loginInfo.UserInfo.StaffId, outStockTask.Id, outStockTask.Type);
|
||||||
foreach (var d in dto.Details)
|
foreach (var d in dto.Details)
|
||||||
{
|
{
|
||||||
//任务单明细
|
//任务单明细
|
||||||
var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
|
var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
|
||||||
if (tDetail == null) continue;
|
if (tDetail == null) continue;
|
||||||
//出库单明细
|
var outd = _mapper.Map<OutStockDetails>(tDetail);
|
||||||
OutStockDetails outd = entity.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
|
|
||||||
if (outd == null)
|
|
||||||
{
|
|
||||||
outd = _mapper.Map<OutStockDetails>(tDetail);
|
|
||||||
entity.Details.Add(outd);
|
|
||||||
}
|
|
||||||
outd.Qty = outd.Qty + d.Qty;
|
outd.Qty = outd.Qty + d.Qty;
|
||||||
|
entity.Details.Add(outd);
|
||||||
}
|
}
|
||||||
|
|
||||||
//需要填写序列号
|
//需要填写序列号
|
||||||
@@ -74,10 +69,7 @@ namespace WMS.Web.Domain.Services
|
|||||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||||
bool isRollback = false;
|
bool isRollback = false;
|
||||||
bool isSuccess = true;
|
bool isSuccess = true;
|
||||||
if (entity.Id > 0)
|
entity = await _outStockRepositories.Add(entity, false);
|
||||||
entity = await _outStockRepositories.Edit(entity, false);
|
|
||||||
else
|
|
||||||
entity = await _outStockRepositories.Add(entity, false);
|
|
||||||
|
|
||||||
if (entity == null) isRollback = true;
|
if (entity == null) isRollback = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user