feat(工单物料): 重构工单物料查询接口并支持分页

- 新增WorkorderMaterialQueryDto作为统一查询参数模型
- 修改物料库存、可领料工单、成品库存和可出货订单查询接口,支持分页返回
- 优化RouteCode为10的工单编号生成逻辑,从101开始编号
- 调整采购订单出货数量计算方式,直接减扣出库数量
This commit is contained in:
2026-03-02 19:19:23 +08:00
parent dc8cb4053d
commit 6418bb67b9
7 changed files with 235 additions and 100 deletions

View File

@@ -1,16 +1,17 @@
using System.Collections.Generic;
using DOAN.Model.BZFM;
using DOAN.Model.MES.order;
using DOAN.Model.MES.order.Dto;
using DOAN.Model.MES.product;
using DOAN.Model.MES.product.Dto;
using DOAN.Model.Mobile.Dto;
using DOAN.Repository;
using DOAN.Service.MES.product.IService;
using DOAN.Service.Mobile;
using Infrastructure.Attribute;
using MailKit.Search;
using Microsoft.IdentityModel.Tokens;
using SqlSugar.DistributedSystem.Snowflake;
using System.Collections.Generic;
namespace DOAN.Service.MES.product
{
@@ -145,15 +146,17 @@ namespace DOAN.Service.MES.product
/// <param name="isHideZero">是否隐藏0</param>
/// <param name="searchType">查询范围 1-物料库 2-转用库</param>
/// <returns>物料库存信息列表</returns>
public List<MaterialInventoryDto> GetMaterialInventoryList(string workorder, bool isHideZero = true, int searchType = 1)
public PagedInfo<MaterialInventoryDto> GetMaterialInventoryList(WorkorderMaterialQueryDto query)
{
try
{
// 参数验证
if (string.IsNullOrEmpty(workorder))
if (string.IsNullOrEmpty(query.Workorder))
{
throw new ArgumentNullException(nameof(workorder), "工单号不能为空");
throw new ArgumentNullException(nameof(query.Workorder), "工单号不能为空");
}
string workorder = query.Workorder;
bool isHideZero = query.IsHideZero;
var workorderInfo = Context
.Queryable<ProWorkorder>()
@@ -162,7 +165,7 @@ namespace DOAN.Service.MES.product
{
throw new ArgumentException("工单号不存在", nameof(workorder));
}
var result = new List<MaterialInventoryDto>();
var result = new PagedInfo<MaterialInventoryDto>();
// 单原材料
if (workorderInfo.RouteCode != "10")
{
@@ -184,7 +187,8 @@ namespace DOAN.Service.MES.product
BatchNo = it.BatchNo,
})
.OrderBy(it => it.MaterialCode)
.ToList();
.OrderBy(it => it.BatchNo)
.ToPage(query);
result = InventoryList;
}
else
@@ -216,7 +220,9 @@ namespace DOAN.Service.MES.product
.OrderBy(it => it.MaterialCode)
.OrderBy(it => it.BatchNo)
.ToList();
result.AddRange(InventoryList);
result.Result.AddRange(InventoryList);
result.TotalNum += 1;
}
}
@@ -239,16 +245,16 @@ namespace DOAN.Service.MES.product
/// <param name="isHideZero">是否隐藏0记录</param>
/// <param name="searchType">查询范围 1-物料库 2-转用库</param>
/// <returns>可领料工单清单</returns>
public List<ProWorkorderDto> GetPickableWorkordersByWorkorder(string workorder, bool isHideZero = true, int searchType = 1)
public PagedInfo<ProWorkorderDto> GetPickableWorkordersByWorkorder(WorkorderMaterialQueryDto query)
{
try
{
// 参数验证
if (string.IsNullOrEmpty(workorder))
if (string.IsNullOrEmpty(query.Workorder))
{
throw new ArgumentNullException(nameof(workorder), "工单号不能为空");
throw new ArgumentNullException(nameof(query.Workorder), "工单号不能为空");
}
string workorder = query.Workorder;
var workorderInfo = Context
.Queryable<ProWorkorder>()
.First(it => it.Workorder == workorder);
@@ -282,15 +288,14 @@ namespace DOAN.Service.MES.product
},
true
)
.Take(30)
.ToList();
.ToPage(query);
}
else
{
// 非10线则返回库存
// 示例返回空列表
return new List<ProWorkorderDto>();
return new PagedInfo<ProWorkorderDto>();
}
}
catch (Exception ex)
@@ -307,15 +312,17 @@ namespace DOAN.Service.MES.product
/// <param name="workorder">工单号</param>
/// <param name="isHideZero">是否隐藏为0记录</param>
/// <returns>成品库存信息列表</returns>
public List<MaterialInventoryDto> GetProductInventoryList(string workorder, bool isHideZero = true)
public PagedInfo<MaterialInventoryDto> GetProductInventoryList(WorkorderMaterialQueryDto query)
{
try
{
// 参数验证
if (string.IsNullOrEmpty(workorder))
if (string.IsNullOrEmpty(query.Workorder))
{
throw new ArgumentNullException(nameof(workorder), "工单号不能为空");
throw new ArgumentNullException(nameof(query.Workorder), "工单号不能为空");
}
string workorder = query.Workorder;
bool isHideZero = query.IsHideZero;
var workorderInfo = Context
.Queryable<ProWorkorder>()
@@ -341,8 +348,7 @@ namespace DOAN.Service.MES.product
BatchNo = it.BatchNo,
})
.OrderByDescending(it => it.BatchNo)
.Take(10)
.ToList();
.ToPage(query);
return result;
}
@@ -360,15 +366,16 @@ namespace DOAN.Service.MES.product
/// <param name="workorder">工单号</param>
/// <param name="isHideZero">是否隐藏为0记录</param>
/// <returns>可出货订单清单</returns>
public List<OrderPurchaseDto> GetShippableOrdersByWorkorder(string workorder, bool isHideZero = true)
public PagedInfo<OrderPurchaseDto> GetShippableOrdersByWorkorder(WorkorderMaterialQueryDto query)
{
try
{
// 参数验证
if (string.IsNullOrEmpty(workorder))
if (string.IsNullOrEmpty(query.Workorder))
{
throw new ArgumentNullException(nameof(workorder), "工单号不能为空");
throw new ArgumentNullException(nameof(query.Workorder), "工单号不能为空");
}
string workorder = query.Workorder;
var workorderInfo = Context
.Queryable<ProWorkorder>()
@@ -396,7 +403,7 @@ namespace DOAN.Service.MES.product
},
true
)
.ToList();
.ToPage(query);
// 示例返回空列表
return orderPurchaseList;