优化采购入库代码

This commit is contained in:
tongfei
2024-03-08 16:55:39 +08:00
parent a8426e1d56
commit 0c6d97db30
2 changed files with 19 additions and 4 deletions

View File

@@ -651,7 +651,7 @@
自动生成箱信息 自动生成箱信息
</summary> </summary>
<param name="str">箱前缀</param> <param name="str">箱前缀</param>
<param name="number">数量</param> <param name="number">数量(明细条数)</param>
<param name="materialNumbers">物料编码</param> <param name="materialNumbers">物料编码</param>
<param name="orgCode">组织编码</param> <param name="orgCode">组织编码</param>
<returns></returns> <returns></returns>

View File

@@ -256,6 +256,23 @@ namespace WMS.Web.Domain.Services
/// <returns></returns> /// <returns></returns>
private async Task<Result<InStock>> 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)
{ {
//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 = new List<ErpOrgDto>();
var orgs_result = await _erpService.BillQueryForOrg(); var orgs_result = await _erpService.BillQueryForOrg();
@@ -318,8 +335,6 @@ namespace WMS.Web.Domain.Services
if (!isSuccess) if (!isSuccess)
return Result<InStock>.ReFailure(ResultCodes.DateWriteError); 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) if (tasks != null && tasks.Count != 0)
{ {
foreach (var task in tasks) foreach (var task in tasks)