track/src/TrackCenter.Domain/Aggregates/WarningAggregate/IWarningRuleRepository.cs
zzh aeae900b5e feat: simplify transport warning to product+country with assessment SLA
AppKey-level scheme; scene matches one product and one country; stores assessment total hours (days×24) with migration SQL.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 11:13:38 +08:00

121 lines
5.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using TrackCenter.Domain.Aggregates.WarningAggregate.Complete;
using TrackCenter.Domain.Aggregates.WarningAggregate.Return;
using TrackCenter.Domain.Aggregates.WarningAggregate.Transport;
namespace TrackCenter.Domain.Aggregates.WarningAggregate;
/// <summary>
/// 预警规则仓储
/// </summary>
public interface IWarningRuleRepository : IBasicRepository<WarningRuleEntity>
{
#region 规则主体
// 检查名称是否重复
Task<bool> CheckNameDuplicateAsync(int id, string appKey, string customer, string name, WarningRuleType warningType);
// 检查是同一【应用+客户+类型】是否有多个启用的预警规则主体
Task<bool> CheckEnableDuplicateAsync(int warningId, string appKey, string customer, WarningRuleType warningType);
// 新增/更新预警规则主体,并返回id
Task<int> UpsertReturnIdAsync(WarningRuleEntity entity);
// 更新版本号
Task<string> UpdateVersionAsync(WarningRuleEntity entity);
// 模糊查询预警规则主体
Task<List<WarningRuleEntity>> GetWarningRuleListAsync(string? appKey, string? customer, string? kpiname, bool? isEnabled, int? warningType);
// 获取启用的预警规则主体
Task<WarningRuleEntity?> GetWarningRuleForEnabledAsync(string appKey, string customer, WarningRuleType warningType);
// 获取启用的预警规则主体
Task<IReadOnlyDictionary<int, WarningRuleEntity>> GetWarningRuleForEnabledAsync(HashSet<(string AppKey, string Customer)> conditions, WarningRuleType warningType);
/// <summary>
/// 按 AppKey 获取启用的预警规则主体(运输时效:方案级,不按客户)
/// </summary>
Task<IReadOnlyDictionary<int, WarningRuleEntity>> GetWarningRuleForEnabledByAppKeysAsync(HashSet<string> appKeys, WarningRuleType warningType);
// 获取预警规则主体根据id
Task<WarningRuleEntity?> GetWarningRuleByIdAsync(int id, WarningRuleType? warningType = null);
#endregion
#region 运输时效预警规则
// 获取运输预警场景列表
Task<List<TransportWarningSceneEntity>> GetTransportSceneAsync(int warningId);
// 获取运输预警场景列表
Task<List<TransportWarningSceneEntity>> GetTransportSceneAsync(Expression<Func<TransportWarningSceneEntity, bool>> whereExpression);
// 获取运输预警场景列表
Task<TransportWarningSceneEntity?> GetTransportSceneAsync(int warningId, int sceneId);
// 全量获取的运输时效场景规则项目
Task<List<TransportWarningSceneRuleItemEntity>> GetTransportSceneRuleItemsAsync(int warningId, int sceneId);
// 获取运输预警场景规则项目
Task<List<TransportWarningSceneRuleItemEntity>> GetTransportSceneRuleItemsAsync(
Expression<Func<TransportWarningSceneRuleItemEntity, bool>> whereExpression);
// 新增/更新 运输预警场景
Task<int> UpsertTransportSceneReturnIdAsync(TransportWarningSceneEntity entity);
// 批量更新运输时效场景规则项目
Task<int> BulkUpdateTransportSceneRuleItemsAsync(List<TransportWarningSceneRuleItemEntity> entities);
// 批量新增运输时效场景规则项目
Task<int> BulkInsertTransportSceneRuleItemsAsync(List<TransportWarningSceneRuleItemEntity> entities);
// 删除运输预警场景规则项目
Task<int> DeleteTransportSceneRuleItemsAsync(HashSet<int> ruleItemIds);
// 删除运输预警场景,并返回删除的规则项目id
Task<bool> DeleteTransportSceneAsync(int warningId, int sceneId);
#endregion
#region 回传时效预警规则
// 获取全量回传预警规则规则项目
Task<List<ReturnWarningRuleItemEntity>> GetReturnRuleItemsAsync(int warningId);
// 按规则项目id获取预警规则
Task<List<ReturnWarningRuleItemEntity>> GetReturnRuleItemsAsync(HashSet<int> ruleItemIds);
// 批量新增回传时效场景规则项目
Task<int> BulkInsertReturnRuleItemsAsync(List<ReturnWarningRuleItemEntity> entities);
// 批量更新回传预警规则规则项目
Task<int> BulkUpdateReturnRuleItemsAsync(List<ReturnWarningRuleItemEntity> entities);
// 删除回传预警规则项目
Task<int> DeleteReturnRuleItemsAsync(HashSet<int> ruleItemIds);
#endregion
#region 完整预警规则
// 获取全量预警规则规则项目
Task<List<CompleteWarningRuleItemEntity>> GetCompleteRuleItemsAsync(int warningId);
// 按规则项目id获取预警规则
Task<List<CompleteWarningRuleItemEntity>> GetCompleteRuleItemsAsync(HashSet<int> ruleItemIds);
// 获取完整预警规则项目
Task<List<CompleteWarningRuleItemEntity>> GetCompleteRuleItemsAsync(Expression<Func<CompleteWarningRuleItemEntity, bool>> whereExpression);
// 批量更新预警规则规则项目
Task<int> BulkUpdateCompleteRuleItemsAsync(List<CompleteWarningRuleItemEntity> entities);
// 批量新增完整时效规则项目
Task<int> BulkInsertCompleteRuleItemsAsync(List<CompleteWarningRuleItemEntity> entities);
// 删除完整预警场景规则项目
Task<int> DeleteCompleteRuleItemsAsync(HashSet<int> ruleItemIds);
#endregion
}