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