优化采购入库代码
This commit is contained in:
@@ -651,7 +651,7 @@
|
||||
自动生成箱信息
|
||||
</summary>
|
||||
<param name="str">箱前缀</param>
|
||||
<param name="number">数量</param>
|
||||
<param name="number">数量(明细条数)</param>
|
||||
<param name="materialNumbers">物料编码</param>
|
||||
<param name="orgCode">组织编码</param>
|
||||
<returns></returns>
|
||||
|
||||
@@ -256,6 +256,23 @@ namespace WMS.Web.Domain.Services
|
||||
/// <returns></returns>
|
||||
private async Task<Result<InStock>> ShelfSave(PurchaseShelfRequest dto, InstockType type, LoginInDto loginInfo, bool isTransaction = true)
|
||||
{
|
||||
|
||||
//1.获取来源单
|
||||
var taskIds = dto.Details.GroupBy(x => x.TaskId).Select(x => x.Key).ToList();
|
||||
var tasks = await _inStockTaskRepositories.GetList(taskIds);
|
||||
|
||||
if (tasks == null || tasks.Count==0)
|
||||
return Result<InStock>.ReFailure(ResultCodes.SourceBillNoDateError);
|
||||
|
||||
//1.1.2判断上架数量不能超过应入库数量
|
||||
var dtoTotalDetails = dto.Details.GroupBy(x => new { x.ErpDetailId }).Select(x => new { ErpDetailId = x.Key.ErpDetailId, Qty = x.Sum(t => t.Qty) }).ToList();
|
||||
foreach (var item in tasks.SelectMany(x => x.Details).ToList())
|
||||
{
|
||||
var current_det = dtoTotalDetails.Where(x => x.ErpDetailId == item.ErpDetailId).FirstOrDefault();
|
||||
if (current_det != null && current_det.ErpDetailId == item.ErpDetailId && (item.AccruedQty - item.RealityQty) < current_det.Qty)
|
||||
return Result<InStock>.ReFailure(ResultCodes.ShelfNoPurchaseSave_Qty_Error);
|
||||
}
|
||||
|
||||
// 组织集合
|
||||
var orgs = new List<ErpOrgDto>();
|
||||
var orgs_result = await _erpService.BillQueryForOrg();
|
||||
@@ -317,9 +334,7 @@ namespace WMS.Web.Domain.Services
|
||||
var isSuccess = await _inStockRepositories.AddRangeTotalDetails(totalDetails, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result<InStock>.ReFailure(ResultCodes.DateWriteError);
|
||||
//反写任务单的已交数量
|
||||
var taskIds = dto.Details.GroupBy(x => x.TaskId).Select(x => x.Key).ToList();
|
||||
var tasks = await _inStockTaskRepositories.GetList(taskIds);
|
||||
//反写任务单的已交数量
|
||||
if (tasks != null && tasks.Count != 0)
|
||||
{
|
||||
foreach (var task in tasks)
|
||||
|
||||
Reference in New Issue
Block a user