比对接口

This commit is contained in:
tongfei
2023-11-07 11:10:14 +08:00
parent 85625b5a80
commit 131ab07de2
9 changed files with 162 additions and 0 deletions

View File

@@ -222,5 +222,33 @@ namespace WMS.Web.Domain.Services
else
return Result.ReFailure(ResultCodes.DateWriteError);
}
/// <summary>
/// 采购订单物料明细和箱物料明细-对比
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<Result<ContrastMaterialsResponse>> Contrast(ContrastMaterialsRequest dto)
{
//1.找到任务单的明细信息
var task = await _inStockTaskRepositories.Get(dto.TaskId);
if (task == null)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.OrderNoData);
//2.找到箱对应的物料信息
var box = await _boxRepositories.GetByNo(dto.BoxBillNo);
if (box == null)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.BoxNoData);
//3.比对
bool isRight = box.Details.All(x => task.Details.Any(t => t.MaterialId == x.MaterialId && t.AccruedQty == x.Qty)) && box.Details.Count == task.Details.Count;
//4.返回对比结果true为比对成功false为比对失败;并把箱ID和箱号返回
var response = new ContrastMaterialsResponse();
response.BoxBillNo = box.BoxBillNo;
response.BoxId = box.Id;
response.IsRight = isRight;
return Result<ContrastMaterialsResponse>.ReSuccess(response);
}
}
}