接口优化

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

@@ -139,11 +139,11 @@ namespace WMS.Web.Api.Controllers
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
[Route("GetTaskByBox/{boxBillNo}")] [Route("GetTaskByBox/{boxBillNo}")]
public async Task<Result<InStockTaskInfoDto>> GetTaskByBox([FromRoute] string boxBillNo) public async Task<Result<BoxInStockTaskDto>> GetTaskByBox([FromRoute] string boxBillNo)
{ {
var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
if (loginInfo == null || loginInfo.UserInfo == null) if (loginInfo == null || loginInfo.UserInfo == null)
return Result<InStockTaskInfoDto>.ReFailure(ResultCodes.Token_Invalid_Error); return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.Token_Invalid_Error);
return await _inStockService.GetInfoByBox(boxBillNo); return await _inStockService.GetInfoByBox(boxBillNo);
} }

View File

@@ -1225,6 +1225,81 @@
状态 状态
</summary> </summary>
</member> </member>
<member name="T:WMS.Web.Core.Dto.InStockTask.BoxInStockTaskDto">
<summary>
扫箱-对应的任务单信息和箱的信息
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxInStockTaskDto.SourceBillNo">
<summary>
来源单号
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxInStockTaskDto.BoxId">
<summary>
箱ID
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxInStockTaskDto.TaskId">
<summary>
单据ID(等同-入库任务单ID)
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxInStockTaskDto.Details">
<summary>
明细
</summary>
</member>
<member name="T:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto">
<summary>
箱明细和任务单明细结合
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.SupplierId">
<summary>
供应商Id
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.OrgId">
<summary>
组织ID
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.MaterialId">
<summary>
物料ID
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.MaterialName">
<summary>
物料名称
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.MaterialNumber">
<summary>
物料编码
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.Specifications">
<summary>
物料规格型号
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.AccruedQty">
<summary>
应入数量
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.ReceiveQty">
<summary>
收货数量
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStockTask.BoxDetailsInStockTaskDto.BoxMaterialQty">
<summary>
箱对应物料的数量
</summary>
</member>
<member name="T:WMS.Web.Core.Dto.InStockTask.ContrastMaterialsRequest"> <member name="T:WMS.Web.Core.Dto.InStockTask.ContrastMaterialsRequest">
<summary> <summary>
采购订单物料明细和箱物料明细-对比请求对象 采购订单物料明细和箱物料明细-对比请求对象

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WMS.Web.Core.Dto.InStockTask
{
/// <summary>
/// 扫箱-对应的任务单信息和箱的信息
/// </summary>
public class BoxInStockTaskDto
{
/// <summary>
/// 来源单号
/// </summary>
public string SourceBillNo { get; set; }
/// <summary>
/// 箱ID
/// </summary>
public int BoxId { get; set; }
/// <summary>
/// 单据ID(等同-入库任务单ID)
/// </summary>
public int TaskId { get; set; }
/// <summary>
/// 明细
/// </summary>
public List<BoxDetailsInStockTaskDto> Details { get; set; } = new List<BoxDetailsInStockTaskDto>();
}
/// <summary>
/// 箱明细和任务单明细结合
/// </summary>
public class BoxDetailsInStockTaskDto
{
/// <summary>
/// 供应商Id
/// </summary>
public int SupplierId { get; set; }
/// <summary>
/// 组织ID
/// </summary>
public int OrgId { get; set; }
/// <summary>
/// 物料ID
/// </summary>
public int MaterialId { get; set; }
/// <summary>
/// 物料名称
/// </summary>
public string MaterialName { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string MaterialNumber { get; set; }
/// <summary>
/// 物料规格型号
/// </summary>
public string Specifications { get; set; }
/// <summary>
/// 应入数量
/// </summary>
public decimal AccruedQty { get; set; }
/// <summary>
/// 收货数量
/// </summary>
public decimal ReceiveQty { get; set; }
/// <summary>
/// 箱对应物料的数量
/// </summary>
public decimal BoxMaterialQty { get; set; }
}
}

View File

@@ -54,7 +54,7 @@ namespace WMS.Web.Domain.IService
/// </summary> /// </summary>
/// <param name="boxBillNo"></param> /// <param name="boxBillNo"></param>
/// <returns></returns> /// <returns></returns>
Task<Result<InStockTaskInfoDto>> GetInfoByBox(string boxBillNo); Task<Result<BoxInStockTaskDto>> GetInfoByBox(string boxBillNo);
/// <summary> /// <summary>
/// 修改-入库任务信息 /// 修改-入库任务信息

View File

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