出库修改箱
This commit is contained in:
@@ -146,5 +146,19 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
|
|
||||||
return Result.ReSuccess();
|
return Result.ReSuccess();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 出库
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="materialId"></param>
|
||||||
|
/// <param name="qty"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Result OutStock(int materialId, decimal qty)
|
||||||
|
{
|
||||||
|
var d = this.Details.FirstOrDefault(f => f.MaterialId == materialId);
|
||||||
|
if (d != null)
|
||||||
|
d.Qty = (d.Qty - qty) > 0 ? (d.Qty - qty) : 0;
|
||||||
|
|
||||||
|
return Result.ReSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace WMS.Web.Domain.IService
|
|||||||
Task<Result> ChangeBox_BackRecord(BackRecord BackRecord, LoginInDto loginInfo, bool isTransaction = true);
|
Task<Result> ChangeBox_BackRecord(BackRecord BackRecord, LoginInDto loginInfo, bool isTransaction = true);
|
||||||
//非采购入库
|
//非采购入库
|
||||||
Task<Result> ChangeBox_InStock(InStock InStocks, LoginInDto loginInfo, bool isTransaction = true);
|
Task<Result> ChangeBox_InStock(InStock InStocks, LoginInDto loginInfo, bool isTransaction = true);
|
||||||
|
//出库
|
||||||
|
Task<Result> ChangeBox_OutStock(OutStock outStock, bool isTransaction = true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,5 +427,47 @@ namespace WMS.Web.Domain.Services
|
|||||||
|
|
||||||
return await ChangeBoxSave(dtoList, loginInfo, isTransaction, false);
|
return await ChangeBoxSave(dtoList, loginInfo, isTransaction, false);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 出库
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="outStock"></param>
|
||||||
|
/// <param name="isTransaction"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<Result> ChangeBox_OutStock(OutStock outStock, bool isTransaction = true)
|
||||||
|
{
|
||||||
|
if (outStock.Method == InventoryInOutMethod.Box) return Result.ReSuccess();
|
||||||
|
List<SaveChangeBoxRecordRequest> dtoList = new List<SaveChangeBoxRecordRequest>();
|
||||||
|
var boxDetails = outStock.Details.SelectMany(s => s.BoxsDetails);
|
||||||
|
var boxIds = boxDetails.Select(s => s.BoxId).Distinct().ToList();
|
||||||
|
var boxs = await _boxRepositories.GetEntityList(boxIds);
|
||||||
|
foreach (var d in outStock.Details)
|
||||||
|
{
|
||||||
|
foreach (var db in d.BoxsDetails)
|
||||||
|
{
|
||||||
|
var box = boxs.FirstOrDefault(f => f.Id == db.BoxId);
|
||||||
|
if (box == null) continue;
|
||||||
|
box.OutStock(d.MaterialId, db.Qty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IDbContextTransaction _transaction = null;
|
||||||
|
if (isTransaction)
|
||||||
|
_transaction = _basbicsRepositories.GetTransaction();
|
||||||
|
Result res_Rollback = Result.ReSuccess();
|
||||||
|
bool isSuccess = true;
|
||||||
|
if (res_Rollback.IsSuccess)
|
||||||
|
{
|
||||||
|
isSuccess = await _boxRepositories.EditEntityList(boxs, false);
|
||||||
|
if (!isSuccess) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
|
||||||
|
}
|
||||||
|
//提交事务
|
||||||
|
if (isTransaction)
|
||||||
|
{
|
||||||
|
isSuccess = _basbicsRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);
|
||||||
|
if (!res_Rollback.IsSuccess) return res_Rollback;
|
||||||
|
if (!isSuccess)
|
||||||
|
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||||
|
}
|
||||||
|
return Result.ReSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,13 +48,15 @@ namespace WMS.Web.Domain.Services
|
|||||||
private readonly ISingleDataService _singleDataService;
|
private readonly ISingleDataService _singleDataService;
|
||||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||||
private readonly IInStockTaskBoxService _inStockTaskService;
|
private readonly IInStockTaskBoxService _inStockTaskService;
|
||||||
|
private readonly IChangeMoveBoxService _changeMoveBoxService;
|
||||||
public OutStockService(IMapper mapper, ILoginService loginService,
|
public OutStockService(IMapper mapper, ILoginService loginService,
|
||||||
IBasicsRepositories transactionRepositories,
|
IBasicsRepositories transactionRepositories,
|
||||||
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories,
|
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories,
|
||||||
IOutStockTaskService outStockTaskService, IErpService erpService, ISerialNumberService serialNumberService,
|
IOutStockTaskService outStockTaskService, IErpService erpService, ISerialNumberService serialNumberService,
|
||||||
IBoxInventoryService boxInventoryService, IInventoryInOutDetailsService inventoryInOutDetailsService,
|
IBoxInventoryService boxInventoryService, IInventoryInOutDetailsService inventoryInOutDetailsService,
|
||||||
IBoxInventoryRepositories boxInventoryRepositories, ILogger<OutStockService> logger, IBoxRepositories boxRepositories,
|
IBoxInventoryRepositories boxInventoryRepositories, ILogger<OutStockService> logger, IBoxRepositories boxRepositories,
|
||||||
ISingleDataService singleDataService, IServiceScopeFactory serviceScopeFactory, IInStockTaskBoxService inStockTaskService)
|
ISingleDataService singleDataService, IServiceScopeFactory serviceScopeFactory, IInStockTaskBoxService inStockTaskService,
|
||||||
|
IChangeMoveBoxService changeMoveBoxService)
|
||||||
{
|
{
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_loginService = loginService;
|
_loginService = loginService;
|
||||||
@@ -72,6 +74,7 @@ namespace WMS.Web.Domain.Services
|
|||||||
_singleDataService = singleDataService;
|
_singleDataService = singleDataService;
|
||||||
_serviceScopeFactory = serviceScopeFactory;
|
_serviceScopeFactory = serviceScopeFactory;
|
||||||
_inStockTaskService = inStockTaskService;
|
_inStockTaskService = inStockTaskService;
|
||||||
|
_changeMoveBoxService = changeMoveBoxService;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 出库单
|
/// 出库单
|
||||||
@@ -195,6 +198,11 @@ namespace WMS.Web.Domain.Services
|
|||||||
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
||||||
}
|
}
|
||||||
if (res_Rollback.IsSuccess)
|
if (res_Rollback.IsSuccess)
|
||||||
|
{
|
||||||
|
var res_changeMoveBox = await _changeMoveBoxService.ChangeBox_OutStock(entity, false);
|
||||||
|
if (!res_changeMoveBox.IsSuccess) res_Rollback = res_changeMoveBox;
|
||||||
|
}
|
||||||
|
if (res_Rollback.IsSuccess)
|
||||||
{
|
{
|
||||||
boxIds = entity.Details.SelectMany(s => s.BoxsDetails).Select(s => s.BoxId).ToList();
|
boxIds = entity.Details.SelectMany(s => s.BoxsDetails).Select(s => s.BoxId).ToList();
|
||||||
var res_InStockTask = await _inStockTaskService.UnBind(boxIds, false);
|
var res_InStockTask = await _inStockTaskService.UnBind(boxIds, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user