调整出库操作
This commit is contained in:
@@ -44,11 +44,28 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Save(List<SaveOutStockRequest> dto, LoginInDto loginInfo)
|
||||
public async Task<Result> Save(SaveOutStockRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
OutStock entity = new OutStock();
|
||||
entity.Details = _mapper.Map<List<OutStockDetails>>(dto);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
|
||||
OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId);
|
||||
|
||||
if (entity == null)
|
||||
entity = new OutStock();
|
||||
entity.Create(loginInfo.UserInfo.StaffId, outStockTask.Id, outStockTask.Type);
|
||||
foreach (var d in dto.Details)
|
||||
{
|
||||
//任务单明细
|
||||
var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
|
||||
if (tDetail == null) continue;
|
||||
//出库单明细
|
||||
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;
|
||||
}
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
@@ -57,7 +74,11 @@ namespace WMS.Web.Domain.Services
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isSuccess = true;
|
||||
entity = await _outStockRepositories.Add(entity, false);
|
||||
if (entity.Id > 0)
|
||||
entity = await _outStockRepositories.Edit(entity, false);
|
||||
else
|
||||
entity = await _outStockRepositories.Add(entity, false);
|
||||
|
||||
if (entity == null) isRollback = true;
|
||||
|
||||
//提交事务
|
||||
|
||||
Reference in New Issue
Block a user