接口优化

This commit is contained in:
tongfei
2023-11-25 14:29:28 +08:00
parent 11444e7592
commit b9409ce552
5 changed files with 182 additions and 20 deletions

View File

@@ -137,7 +137,7 @@ namespace WMS.Web.Domain.Services
/// </summary>
/// <param name="boxBillNo"></param>
/// <returns></returns>
public async Task<Result<InStockTaskInfoDto>> GetInfoByBox(string boxBillNo)
public async Task<Result<BoxInStockTaskDto>> GetInfoByBox(string boxBillNo)
{
//1.获取物料集合
var materials_result = await _erpService.BillQueryForMaterial();
@@ -148,36 +148,42 @@ namespace WMS.Web.Domain.Services
//1.先判断:箱号已经绑定了入库任务单中;备注:业务说法就是箱是否收货了
var tast = await _inStockTaskRepositories.GetBy(boxBillNo);
if (tast == null)
return Result<InStockTaskInfoDto>.ReFailure(ResultCodes.Box_NoBind_Task_Data);
return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.Box_NoBind_Task_Data);
//2.找到箱对应的物料信息
var box = await _boxRepositories.GetByNo(boxBillNo);
if (box == null)
return Result<InStockTaskInfoDto>.ReFailure(ResultCodes.BoxNoData);
return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.BoxNoData);
//2.1判断箱是否上架过了
var isExist = await _inStockRepositories.IsExistBy(box.Id);
if(isExist)
return Result<InStockTaskInfoDto>.ReFailure(ResultCodes.BoxIsTrueShelf);
return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.BoxIsTrueShelf);
//3.组装返回数据
var result = _mapper.Map<InStockTaskInfoDto>(tast);
var result = new BoxInStockTaskDto();
result.SourceBillNo = tast.SourceBillNo;
result.TaskId = tast.Id;
result.BoxId = box.Id;
foreach (var item in tast.Details)
foreach (var item in box.Details)
{
//3.1判断当前物料是否相同
var current_box_det = box.Details.Where(x => x.MaterialId == item.MaterialId).FirstOrDefault();
if (current_box_det==null)
continue;
var current_task_Det= tast.Details.Where(x => x.MaterialId == item.MaterialId && x.AccruedQty>x.ReceiveQty).FirstOrDefault();
//3.2映射返回明细对象
var task_detail = _mapper.Map<InStockTaskDetailsInfoDto>(item);
task_detail.BoxMaterialQty = current_box_det.Qty;
task_detail.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, task_detail.MaterialId);
task_detail.MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, task_detail.MaterialId);
task_detail.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, task_detail.MaterialId);
result.Details.Add(task_detail);
var box_task_detail = new BoxDetailsInStockTaskDto();
box_task_detail.SupplierId = current_task_Det == null ? 0 : current_task_Det.SupplierId;
box_task_detail.OrgId = current_task_Det == null ? 0 : current_task_Det.OrgId;
box_task_detail.ReceiveQty = current_task_Det == null ? 0 : current_task_Det.ReceiveQty;
box_task_detail.AccruedQty = current_task_Det == null ? 0 : current_task_Det.AccruedQty;
box_task_detail.MaterialId = item.MaterialId;
box_task_detail.BoxMaterialQty = item.Qty;
box_task_detail.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, item.MaterialId);
box_task_detail.MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, item.MaterialId);
box_task_detail.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, item.MaterialId);
result.Details.Add(box_task_detail);
}
return Result<InStockTaskInfoDto>.ReSuccess(result);
return Result<BoxInStockTaskDto>.ReSuccess(result);
}
/// <summary>