feat(预算): 添加预算趋势分析功能并优化图表展示
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 38s
Docker Build & Deploy / Deploy to Production (push) Successful in 10s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 38s
Docker Build & Deploy / Deploy to Production (push) Successful in 10s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
重构预算分析图表组件,添加每日/每月趋势统计功能: 1. 在Repository层添加趋势统计接口 2. 在Service层实现趋势数据计算逻辑 3. 优化前端图表展示,合并偏差分析图表 4. 改进燃尽图使用实际趋势数据 5. 调整UI样式和交互体验
This commit is contained in:
@@ -198,6 +198,16 @@ public interface ITransactionRecordRepository : IBaseRepository<TransactionRecor
|
||||
/// <returns>影响行数</returns>
|
||||
Task<int> ConfirmAllUnconfirmedAsync(long[] ids);
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定分类在指定时间范围内的每日/每月统计趋势
|
||||
/// </summary>
|
||||
Task<Dictionary<DateTime, decimal>> GetFilteredTrendStatisticsAsync(
|
||||
DateTime startDate,
|
||||
DateTime endDate,
|
||||
TransactionType type,
|
||||
IEnumerable<string> classifies,
|
||||
bool groupByMonth = false);
|
||||
|
||||
/// <summary>
|
||||
/// 更新分类名称
|
||||
/// </summary>
|
||||
@@ -719,6 +729,37 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
.Where(t => ids.Contains(t.Id))
|
||||
.ExecuteAffrowsAsync();
|
||||
}
|
||||
|
||||
public async Task<Dictionary<DateTime, decimal>> GetFilteredTrendStatisticsAsync(
|
||||
DateTime startDate,
|
||||
DateTime endDate,
|
||||
TransactionType type,
|
||||
IEnumerable<string> classifies,
|
||||
bool groupByMonth = false)
|
||||
{
|
||||
var query = FreeSql.Select<TransactionRecord>()
|
||||
.Where(t => t.OccurredAt >= startDate && t.OccurredAt <= endDate && t.Type == type);
|
||||
|
||||
if (classifies != null && classifies.Any())
|
||||
{
|
||||
query = query.Where(t => classifies.Contains(t.Classify));
|
||||
}
|
||||
|
||||
var list = await query.ToListAsync(t => new { t.OccurredAt, t.Amount });
|
||||
|
||||
if (groupByMonth)
|
||||
{
|
||||
return list
|
||||
.GroupBy(t => new DateTime(t.OccurredAt.Year, t.OccurredAt.Month, 1))
|
||||
.ToDictionary(g => g.Key, g => g.Sum(x => Math.Abs(x.Amount)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return list
|
||||
.GroupBy(t => t.OccurredAt.Date)
|
||||
.ToDictionary(g => g.Key, g => g.Sum(x => Math.Abs(x.Amount)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user