feat(库存报表): 新增出入库报表功能及变动箱数字段
添加成品库出入库报表功能,包括入库报表和出库报表的查询接口 在WmGoodsRecord模型中新增ChangePackage字段记录变动箱数 修复Job_Blank.cs中多余的return null语句
This commit is contained in:
24
ZR.Service/mes/mm/IService/IMmInventoryReportService.cs
Normal file
24
ZR.Service/mes/mm/IService/IMmInventoryReportService.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.mm;
|
||||
using ZR.Model.MES.mm.Dto;
|
||||
|
||||
namespace ZR.Service.mes.mm.IService
|
||||
{
|
||||
public interface IMmInventoryReportService
|
||||
{
|
||||
/// <summary>
|
||||
/// 按时间、物料号、物料名称、操作人获取分页数据
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <param name="pagerInfo">分页信息</param>
|
||||
/// <returns>分页结果</returns>
|
||||
PagedInfo<WmGoodsRecordReport> GetInventoryReportByPage(WmGoodsRecordReportQueryDto query);
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取详细数据清单
|
||||
/// </summary>
|
||||
/// <param name="id">记录ID</param>
|
||||
/// <returns>详细数据</returns>
|
||||
WmGoodsRecordReport GetInventoryReportDetail(string id);
|
||||
}
|
||||
}
|
||||
24
ZR.Service/mes/mm/IService/IMmOutboundReportService.cs
Normal file
24
ZR.Service/mes/mm/IService/IMmOutboundReportService.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using ZR.Model.MES.mm;
|
||||
using ZR.Model.MES.mm.Dto;
|
||||
using ZR.Model;
|
||||
|
||||
namespace ZR.Service.mes.mm.IService
|
||||
{
|
||||
public interface IMmOutboundReportService
|
||||
{
|
||||
/// <summary>
|
||||
/// 按时间、物料号、物料名称、操作人获取分页数据
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <param name="pagerInfo">分页信息</param>
|
||||
/// <returns>分页结果</returns>
|
||||
PagedInfo<WmGoodsRecordReport> GetOutboundReportByPage(WmGoodsRecordReportQueryDto query);
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取详细数据清单
|
||||
/// </summary>
|
||||
/// <param name="id">记录ID</param>
|
||||
/// <returns>详细数据</returns>
|
||||
WmGoodsRecordReport GetOutboundReportDetail(string id);
|
||||
}
|
||||
}
|
||||
142
ZR.Service/mes/mm/MmInventoryReportService.cs
Normal file
142
ZR.Service/mes/mm/MmInventoryReportService.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using System.Linq;
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.mm;
|
||||
using ZR.Model.MES.mm.Dto;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.mes.mm.IService;
|
||||
using ZR.Service.mes.wms;
|
||||
|
||||
namespace ZR.Service.mes.mm
|
||||
{
|
||||
[AppService(
|
||||
ServiceType = typeof(IMmInventoryReportService),
|
||||
ServiceLifetime = LifeTime.Transient
|
||||
)]
|
||||
public class MmInventoryReportService : BaseService<WmGoodsRecord>, IMmInventoryReportService
|
||||
{
|
||||
/// <summary>
|
||||
/// 按时间、物料号、物料名称、操作人获取分页数据
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <param name="pagerInfo">分页信息</param>
|
||||
/// <returns>分页结果</returns>
|
||||
public PagedInfo<WmGoodsRecordReport> GetInventoryReportByPage(
|
||||
WmGoodsRecordReportQueryDto query
|
||||
)
|
||||
{
|
||||
// 添加查询条件
|
||||
var predicate = Expressionable
|
||||
.Create<WmGoodsRecord, WmMaterial>()
|
||||
.AndIF(query.StartTime.HasValue, (gr, m) => gr.ActionTime >= query.StartTime)
|
||||
.AndIF(query.EndTime.HasValue, (gr, m) => gr.ActionTime <= query.EndTime)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.PartNumber),
|
||||
(gr, m) => gr.Partnumber.Contains(query.PartNumber)
|
||||
)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.Source),
|
||||
(gr, m) => gr.Code.Contains(query.Source)
|
||||
)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.MaterialName),
|
||||
(gr, m) => m.Description.Contains(query.MaterialName)
|
||||
)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.Operator),
|
||||
(gr, m) => gr.CreatedBy.Contains(query.Operator)
|
||||
)
|
||||
.And((gr, m) => gr.ChangeType == 1); // 入库记录
|
||||
|
||||
// 按零件号分组并计算ChangeQuantity合计
|
||||
var result = Context
|
||||
.Queryable<WmGoodsRecord, WmMaterial>(
|
||||
(gr, m) => new JoinQueryInfos(JoinType.Left, gr.Partnumber == m.Partnumber)
|
||||
)
|
||||
.Where(predicate.ToExpression())
|
||||
.GroupBy(
|
||||
(gr, m) =>
|
||||
new
|
||||
{
|
||||
gr.Partnumber,
|
||||
m.ProductName,
|
||||
m.Color,
|
||||
m.Specification,
|
||||
m.Description,
|
||||
m.Unit,
|
||||
gr.CreatedBy
|
||||
}
|
||||
)
|
||||
.Select(
|
||||
(gr, m) =>
|
||||
new WmGoodsRecordReport
|
||||
{
|
||||
Code = gr.Code,
|
||||
Partnumber = gr.Partnumber,
|
||||
ProductName = m.ProductName,
|
||||
Color = m.Color,
|
||||
Specification = m.Specification,
|
||||
Description = m.Description,
|
||||
Unit = m.Unit,
|
||||
ChangePackage = SqlFunc.AggregateSum(gr.ChangePackage),
|
||||
ChangeQuantity = SqlFunc.AggregateSum(gr.ChangeQuantity),
|
||||
CreatedBy = gr.CreatedBy,
|
||||
}
|
||||
)
|
||||
.ToPage(query);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取详细数据清单
|
||||
/// </summary>
|
||||
/// <param name="id">记录ID</param>
|
||||
/// <returns>详细数据</returns>
|
||||
public WmGoodsRecordReport GetInventoryReportDetail(string id)
|
||||
{
|
||||
// 获取原始记录
|
||||
var record = this.GetId(id);
|
||||
if (record == null)
|
||||
return null;
|
||||
|
||||
// 创建报表模型实例
|
||||
var report = new WmGoodsRecordReport
|
||||
{
|
||||
Id = record.Id,
|
||||
FkInventoryId = record.FkInventoryId,
|
||||
Code = record.Code,
|
||||
Partnumber = record.Partnumber,
|
||||
BlankNum = record.BlankNum,
|
||||
ChangeType = record.ChangeType,
|
||||
ChangeQuantity = record.ChangeQuantity,
|
||||
ActionTime = record.ActionTime,
|
||||
Status = record.Status,
|
||||
Remark = record.Remark,
|
||||
CreatedBy = record.CreatedBy,
|
||||
CreatedTime = record.CreatedTime,
|
||||
UpdatedBy = record.UpdatedBy,
|
||||
UpdatedTime = record.UpdatedTime
|
||||
};
|
||||
|
||||
// 如果有零件号,尝试获取物料信息
|
||||
if (!string.IsNullOrEmpty(record.Partnumber))
|
||||
{
|
||||
var materialService = new WmMaterialService();
|
||||
var material = materialService.GetFirst(it => it.Partnumber == record.Partnumber);
|
||||
if (material != null)
|
||||
{
|
||||
report.ProductName = material.ProductName;
|
||||
report.Color = material.Color;
|
||||
report.Specification = material.Specification;
|
||||
report.Description = material.Description;
|
||||
report.Unit = material.Unit;
|
||||
}
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
141
ZR.Service/mes/mm/MmOutboundReportService.cs
Normal file
141
ZR.Service/mes/mm/MmOutboundReportService.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using ZR.Model;
|
||||
using ZR.Model.MES.mm;
|
||||
using ZR.Model.MES.mm.Dto;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.mes.mm.IService;
|
||||
using ZR.Service.mes.wms;
|
||||
|
||||
namespace ZR.Service.mes.mm
|
||||
{
|
||||
[AppService(
|
||||
ServiceType = typeof(IMmOutboundReportService),
|
||||
ServiceLifetime = LifeTime.Transient
|
||||
)]
|
||||
public class MmOutboundReportService : BaseService<WmGoodsRecord>, IMmOutboundReportService
|
||||
{
|
||||
/// <summary>
|
||||
/// 按时间、物料号、物料名称、操作人获取分页数据
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <param name="pagerInfo">分页信息</param>
|
||||
/// <returns>分页结果</returns>
|
||||
public PagedInfo<WmGoodsRecordReport> GetOutboundReportByPage(
|
||||
WmGoodsRecordReportQueryDto query
|
||||
)
|
||||
{
|
||||
// 添加查询条件
|
||||
var predicate = Expressionable
|
||||
.Create<WmGoodsRecord, WmMaterial>()
|
||||
.AndIF(query.StartTime.HasValue, (gr, m) => gr.ActionTime >= query.StartTime)
|
||||
.AndIF(query.EndTime.HasValue, (gr, m) => gr.ActionTime <= query.EndTime)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.PartNumber),
|
||||
(gr, m) => gr.Partnumber.Contains(query.PartNumber)
|
||||
)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.Source),
|
||||
(gr, m) => gr.Code.Contains(query.Source)
|
||||
)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.MaterialName),
|
||||
(gr, m) => m.Description.Contains(query.MaterialName)
|
||||
)
|
||||
.AndIF(
|
||||
!string.IsNullOrEmpty(query.Operator),
|
||||
(gr, m) => gr.CreatedBy.Contains(query.Operator)
|
||||
)
|
||||
.And((gr, m) => gr.ChangeType == 2); // 入库记录
|
||||
|
||||
// 按零件号分组并计算ChangeQuantity合计
|
||||
var result = Context
|
||||
.Queryable<WmGoodsRecord, WmMaterial>(
|
||||
(gr, m) => new JoinQueryInfos(JoinType.Left, gr.Partnumber == m.Partnumber)
|
||||
)
|
||||
.Where(predicate.ToExpression())
|
||||
.GroupBy(
|
||||
(gr, m) =>
|
||||
new
|
||||
{
|
||||
gr.Partnumber,
|
||||
m.ProductName,
|
||||
m.Color,
|
||||
m.Specification,
|
||||
m.Description,
|
||||
m.Unit,
|
||||
gr.CreatedBy
|
||||
}
|
||||
)
|
||||
.Select(
|
||||
(gr, m) =>
|
||||
new WmGoodsRecordReport
|
||||
{
|
||||
Code = gr.Code,
|
||||
Partnumber = gr.Partnumber,
|
||||
ProductName = m.ProductName,
|
||||
Color = m.Color,
|
||||
Specification = m.Specification,
|
||||
Description = m.Description,
|
||||
Unit = m.Unit,
|
||||
ChangePackage = SqlFunc.AggregateSum(gr.ChangePackage),
|
||||
ChangeQuantity = SqlFunc.AggregateSum(gr.ChangeQuantity),
|
||||
CreatedBy = gr.CreatedBy,
|
||||
}
|
||||
)
|
||||
.ToPage(query);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取详细数据清单
|
||||
/// </summary>
|
||||
/// <param name="id">记录ID</param>
|
||||
/// <returns>详细数据</returns>
|
||||
public WmGoodsRecordReport GetOutboundReportDetail(string id)
|
||||
{
|
||||
// 获取原始记录
|
||||
var record = this.GetId(id);
|
||||
if (record == null)
|
||||
return null;
|
||||
|
||||
// 创建报表模型实例
|
||||
var report = new WmGoodsRecordReport
|
||||
{
|
||||
Id = record.Id,
|
||||
FkInventoryId = record.FkInventoryId,
|
||||
Code = record.Code,
|
||||
Partnumber = record.Partnumber,
|
||||
BlankNum = record.BlankNum,
|
||||
ChangeType = record.ChangeType,
|
||||
ChangeQuantity = record.ChangeQuantity,
|
||||
ActionTime = record.ActionTime,
|
||||
Status = record.Status,
|
||||
Remark = record.Remark,
|
||||
CreatedBy = record.CreatedBy,
|
||||
CreatedTime = record.CreatedTime,
|
||||
UpdatedBy = record.UpdatedBy,
|
||||
UpdatedTime = record.UpdatedTime
|
||||
};
|
||||
|
||||
// 如果有零件号,尝试获取物料信息
|
||||
if (!string.IsNullOrEmpty(record.Partnumber))
|
||||
{
|
||||
var materialService = new WmMaterialService();
|
||||
var material = materialService.GetFirst(it => it.Partnumber == record.Partnumber);
|
||||
if (material != null)
|
||||
{
|
||||
report.ProductName = material.ProductName;
|
||||
report.Color = material.Color;
|
||||
report.Specification = material.Specification;
|
||||
report.Description = material.Description;
|
||||
report.Unit = material.Unit;
|
||||
}
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user