- 新增 TradeConfirmationDocumentQueryItem 查询项类 - 实现 TradeConfirmationDocumentQuery.Create 查询方法 - 添加按交易日期范围过滤功能 - 重构 tradeController 中的文档查询逻辑 - 集成文档、合同关系和交易数据的联合查询 - 优化查询性能通过预过滤有效合同关系
43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
namespace YLErp.Modules.TradeModule.QueryModule
|
|
{
|
|
public sealed class TradeConfirmationDocumentQueryItem
|
|
{
|
|
public trade_contract_document Document { get; set; }
|
|
|
|
public trade_contract_r Relation { get; set; }
|
|
}
|
|
|
|
public static class TradeConfirmationDocumentQuery
|
|
{
|
|
public static IQueryable<TradeConfirmationDocumentQueryItem> Create(
|
|
IQueryable<trade_contract_document> documents,
|
|
IQueryable<trade_contract_r> relations,
|
|
IQueryable<trade> trades,
|
|
DateTime? tradeDateStart,
|
|
DateTime? tradeDateEnd)
|
|
{
|
|
if (tradeDateStart.HasValue)
|
|
{
|
|
trades = trades.Where(t => t.TradeDate >= tradeDateStart.Value);
|
|
}
|
|
|
|
if (tradeDateEnd.HasValue)
|
|
{
|
|
var tradeDateEndExclusive = tradeDateEnd.Value.Date.AddDays(1);
|
|
trades = trades.Where(t => t.TradeDate < tradeDateEndExclusive);
|
|
}
|
|
|
|
return from document in documents
|
|
join relation in relations.Where(r => r.IsValid)
|
|
on document.Code equals relation.ContractCode
|
|
join trade in trades
|
|
on relation.TradeId equals trade.id
|
|
select new TradeConfirmationDocumentQueryItem
|
|
{
|
|
Document = document,
|
|
Relation = relation
|
|
};
|
|
}
|
|
}
|
|
}
|