优化3
This commit is contained in:
@@ -120,11 +120,18 @@ namespace WMS.Web.Domain.Services
|
|||||||
//1.添加入库单:(同步金蝶在save方法里面进行)
|
//1.添加入库单:(同步金蝶在save方法里面进行)
|
||||||
var save_result = await this.ShelfSave(instock, InstockType.Purchase, loginInfo, isTransaction);
|
var save_result = await this.ShelfSave(instock, InstockType.Purchase, loginInfo, isTransaction);
|
||||||
if (!save_result.IsSuccess) isRollback = true;
|
if (!save_result.IsSuccess) isRollback = true;
|
||||||
|
|
||||||
|
//实体
|
||||||
|
var entity = save_result.Data;
|
||||||
|
|
||||||
//提交事务
|
//提交事务
|
||||||
var isSuccess = _basicsRepositories.CommitTransaction(isRollback, _transaction);
|
var isSuccess = _basicsRepositories.CommitTransaction(isRollback, _transaction);
|
||||||
if (!isSuccess)
|
if (!isSuccess)
|
||||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||||
|
|
||||||
|
//同步金蝶
|
||||||
|
if (entity.Type == InstockType.Purchase)
|
||||||
|
await this.PurchaseInStock(entity, loginInfo);
|
||||||
return Result.ReSuccess();
|
return Result.ReSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +234,7 @@ namespace WMS.Web.Domain.Services
|
|||||||
/// <param name="staffId"></param>
|
/// <param name="staffId"></param>
|
||||||
/// <param name="isTransaction"></param>
|
/// <param name="isTransaction"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<Result> ShelfSave(PurchaseShelfRequest dto, InstockType type, LoginInDto loginInfo, bool isTransaction = true)
|
private async Task<Result<InStock>> ShelfSave(PurchaseShelfRequest dto, InstockType type, LoginInDto loginInfo, bool isTransaction = true)
|
||||||
{
|
{
|
||||||
// 组织集合
|
// 组织集合
|
||||||
var orgs = new List<ErpOrgDto>();
|
var orgs = new List<ErpOrgDto>();
|
||||||
@@ -272,7 +279,7 @@ namespace WMS.Web.Domain.Services
|
|||||||
|
|
||||||
entity = await _inStockRepositories.Add(entity, isTransaction);
|
entity = await _inStockRepositories.Add(entity, isTransaction);
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
return Result<InStock>.ReFailure(ResultCodes.DateWriteError);
|
||||||
|
|
||||||
//处理添加入库汇总明细
|
//处理添加入库汇总明细
|
||||||
var totalDetails = dto.Details.GroupBy(x => new { x.TaskId, x.SourceBillNo, x.SupplierId, x.MaterialId })
|
var totalDetails = dto.Details.GroupBy(x => new { x.TaskId, x.SourceBillNo, x.SupplierId, x.MaterialId })
|
||||||
@@ -289,7 +296,7 @@ namespace WMS.Web.Domain.Services
|
|||||||
|
|
||||||
var isSuccess = await _inStockRepositories.AddRangeTotalDetails(totalDetails, isTransaction);
|
var isSuccess = await _inStockRepositories.AddRangeTotalDetails(totalDetails, isTransaction);
|
||||||
if (!isSuccess)
|
if (!isSuccess)
|
||||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
return Result<InStock>.ReFailure(ResultCodes.DateWriteError);
|
||||||
//反写任务单的已交数量
|
//反写任务单的已交数量
|
||||||
var taskIds = dto.Details.GroupBy(x => x.TaskId).Select(x => x.Key).ToList();
|
var taskIds = dto.Details.GroupBy(x => x.TaskId).Select(x => x.Key).ToList();
|
||||||
var tasks = await _inStockTaskRepositories.GetList(taskIds);
|
var tasks = await _inStockTaskRepositories.GetList(taskIds);
|
||||||
@@ -312,24 +319,20 @@ namespace WMS.Web.Domain.Services
|
|||||||
|
|
||||||
isSuccess = await _inStockTaskRepositories.UpdateRange(tasks, isTransaction);
|
isSuccess = await _inStockTaskRepositories.UpdateRange(tasks, isTransaction);
|
||||||
if (!isSuccess)
|
if (!isSuccess)
|
||||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
return Result<InStock>.ReFailure(ResultCodes.DateWriteError);
|
||||||
}
|
}
|
||||||
|
|
||||||
//保存成功后:序列号跟踪流程添加
|
//保存成功后:序列号跟踪流程添加
|
||||||
var serialNumber_result = await _serialNumberService.InStock(entity, loginInfo, isTransaction);
|
var serialNumber_result = await _serialNumberService.InStock(entity, loginInfo, isTransaction);
|
||||||
if (!serialNumber_result.IsSuccess)
|
if (!serialNumber_result.IsSuccess)
|
||||||
return serialNumber_result;
|
return Result<InStock >.ReFailure(serialNumber_result);
|
||||||
|
|
||||||
//箱库存变动
|
//箱库存变动
|
||||||
var boxInventoryResult = await _boxInventoryService.GenerateInStockBox(entity, isTransaction);
|
var boxInventoryResult = await _boxInventoryService.GenerateInStockBox(entity, isTransaction);
|
||||||
if (!boxInventoryResult.IsSuccess)
|
if (!boxInventoryResult.IsSuccess)
|
||||||
return boxInventoryResult;
|
return Result<InStock>.ReFailure(boxInventoryResult);
|
||||||
|
|
||||||
//同步金蝶
|
return Result<InStock>.ReSuccess(entity);
|
||||||
if (entity.Type == InstockType.Purchase)
|
|
||||||
await this.PurchaseInStock(entity, loginInfo);
|
|
||||||
|
|
||||||
return Result.ReSuccess();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user