1071 lines
26 KiB
C#
1071 lines
26 KiB
C#
using OrpaonVision.Core.Results;
|
|
|
|
namespace OrpaonVision.Core.LayerTransition;
|
|
|
|
/// <summary>
|
|
/// 层级转换服务接口。
|
|
/// </summary>
|
|
public interface ILayerTransitionService
|
|
{
|
|
/// <summary>
|
|
/// 检查是否可以前进到下一层。
|
|
/// </summary>
|
|
/// <param name="currentLayer">当前层级。</param>
|
|
/// <param name="transitionContext">转换上下文。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>检查结果。</returns>
|
|
Task<Result<LayerTransitionCheckResult>> CheckCanMoveForwardAsync(int currentLayer, LayerTransitionContext transitionContext, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 检查是否可以后退到上一层。
|
|
/// </summary>
|
|
/// <param name="currentLayer">当前层级。</param>
|
|
/// <param name="transitionContext">转换上下文。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>检查结果。</returns>
|
|
Task<Result<LayerTransitionCheckResult>> CheckCanMoveBackwardAsync(int currentLayer, LayerTransitionContext transitionContext, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 执行层级转换。
|
|
/// </summary>
|
|
/// <param name="transitionRequest">转换请求。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>转换结果。</returns>
|
|
Task<Result<LayerTransitionResult>> ExecuteTransitionAsync(LayerTransitionRequest transitionRequest, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 回滚层级转换。
|
|
/// </summary>
|
|
/// <param name="rollbackRequest">回滚请求。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>回滚结果。</returns>
|
|
Task<Result<LayerTransitionResult>> RollbackTransitionAsync(LayerTransitionRollbackRequest rollbackRequest, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 获取层级转换保护配置。
|
|
/// </summary>
|
|
/// <param name="productTypeCode">产品类型编码。</param>
|
|
/// <param name="layerNumber">层级编号。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>保护配置。</returns>
|
|
Task<Result<LayerTransitionProtectionConfig>> GetProtectionConfigAsync(string productTypeCode, int layerNumber, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 更新层级转换保护配置。
|
|
/// </summary>
|
|
/// <param name="config">保护配置。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>更新结果。</returns>
|
|
Task<Result> UpdateProtectionConfigAsync(LayerTransitionProtectionConfig config, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 获取层级转换历史。
|
|
/// </summary>
|
|
/// <param name="startTime">开始时间。</param>
|
|
/// <param name="endTime">结束时间。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>转换历史。</returns>
|
|
Task<Result<IReadOnlyList<LayerTransitionHistory>>> GetTransitionHistoryAsync(DateTime startTime, DateTime endTime, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 获取层级转换统计信息。
|
|
/// </summary>
|
|
/// <param name="startTime">开始时间。</param>
|
|
/// <param name="endTime">结束时间。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>统计信息。</returns>
|
|
Task<Result<LayerTransitionStatistics>> GetTransitionStatisticsAsync(DateTime startTime, DateTime endTime, CancellationToken cancellationToken = default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换上下文。
|
|
/// </summary>
|
|
public sealed class LayerTransitionContext
|
|
{
|
|
/// <summary>
|
|
/// 产品类型编码。
|
|
/// </summary>
|
|
public string ProductTypeCode { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 会话ID。
|
|
/// </summary>
|
|
public string SessionId { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 当前层级完成状态。
|
|
/// </summary>
|
|
public bool IsCurrentLayerCompleted { get; init; }
|
|
|
|
/// <summary>
|
|
/// 层级完成度。
|
|
/// </summary>
|
|
public double CompletionPercentage { get; init; }
|
|
|
|
/// <summary>
|
|
/// 层级完成时间。
|
|
/// </summary>
|
|
public DateTime? LayerCompletionTimeUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 是否存在错误。
|
|
/// </summary>
|
|
public bool HasErrors { get; init; }
|
|
|
|
/// <summary>
|
|
/// 错误信息。
|
|
/// </summary>
|
|
public IReadOnlyList<string> ErrorMessages { get; init; } = Array.Empty<string>();
|
|
|
|
/// <summary>
|
|
/// 是否需要人工干预。
|
|
/// </summary>
|
|
public bool RequiresManualIntervention { get; init; }
|
|
|
|
/// <summary>
|
|
/// 人工干预原因。
|
|
/// </summary>
|
|
public string? ManualInterventionReason { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换检查结果。
|
|
/// </summary>
|
|
public sealed class LayerTransitionCheckResult
|
|
{
|
|
/// <summary>
|
|
/// 是否允许转换。
|
|
/// </summary>
|
|
public bool CanTransition { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换类型。
|
|
/// </summary>
|
|
public LayerTransitionType TransitionType { get; init; }
|
|
|
|
/// <summary>
|
|
/// 检查时间。
|
|
/// </summary>
|
|
public DateTime CheckTimeUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 允许转换的原因。
|
|
/// </summary>
|
|
public string? AllowReason { get; init; }
|
|
|
|
/// <summary>
|
|
/// 拒绝转换的原因。
|
|
/// </summary>
|
|
public string? DenyReason { get; init; }
|
|
|
|
/// <summary>
|
|
/// 保护策略。
|
|
/// </summary>
|
|
public LayerTransitionProtectionStrategy ProtectionStrategy { get; init; }
|
|
|
|
/// <summary>
|
|
/// 保护条件检查结果。
|
|
/// </summary>
|
|
public IReadOnlyList<ProtectionConditionCheckResult> ProtectionConditionChecks { get; init; } = Array.Empty<ProtectionConditionCheckResult>();
|
|
|
|
/// <summary>
|
|
/// 建议等待时间(秒)。
|
|
/// </summary>
|
|
public int SuggestedWaitTimeSeconds { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保护条件检查结果。
|
|
/// </summary>
|
|
public sealed class ProtectionConditionCheckResult
|
|
{
|
|
/// <summary>
|
|
/// 条件名称。
|
|
/// </summary>
|
|
public string ConditionName { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 是否满足条件。
|
|
/// </summary>
|
|
public bool IsConditionMet { get; init; }
|
|
|
|
/// <summary>
|
|
/// 条件类型。
|
|
/// </summary>
|
|
public ProtectionConditionType ConditionType { get; init; }
|
|
|
|
/// <summary>
|
|
/// 实际值。
|
|
/// </summary>
|
|
public double ActualValue { get; init; }
|
|
|
|
/// <summary>
|
|
/// 阈值。
|
|
/// </summary>
|
|
public double Threshold { get; init; }
|
|
|
|
/// <summary>
|
|
/// 检查详情。
|
|
/// </summary>
|
|
public string? Details { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换请求。
|
|
/// </summary>
|
|
public sealed class LayerTransitionRequest
|
|
{
|
|
/// <summary>
|
|
/// 请求ID。
|
|
/// </summary>
|
|
public Guid RequestId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 产品类型编码。
|
|
/// </summary>
|
|
public string ProductTypeCode { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 会话ID。
|
|
/// </summary>
|
|
public string SessionId { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 当前层级。
|
|
/// </summary>
|
|
public int CurrentLayer { get; init; }
|
|
|
|
/// <summary>
|
|
/// 目标层级。
|
|
/// </summary>
|
|
public int TargetLayer { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换类型。
|
|
/// </summary>
|
|
public LayerTransitionType TransitionType { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换原因。
|
|
/// </summary>
|
|
public string Reason { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 请求用户。
|
|
/// </summary>
|
|
public string RequestUser { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 是否强制转换(忽略保护策略)。
|
|
/// </summary>
|
|
public bool IsForced { get; init; }
|
|
|
|
/// <summary>
|
|
/// 强制转换原因。
|
|
/// </summary>
|
|
public string? ForceReason { get; init; }
|
|
|
|
/// <summary>
|
|
/// 请求时间。
|
|
/// </summary>
|
|
public DateTime RequestTimeUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换结果。
|
|
/// </summary>
|
|
public sealed class LayerTransitionResult
|
|
{
|
|
/// <summary>
|
|
/// 转换是否成功。
|
|
/// </summary>
|
|
public bool IsSuccess { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换ID。
|
|
/// </summary>
|
|
public Guid TransitionId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 请求ID。
|
|
/// </summary>
|
|
public Guid RequestId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换类型。
|
|
/// </summary>
|
|
public LayerTransitionType TransitionType { get; init; }
|
|
|
|
/// <summary>
|
|
/// 源层级。
|
|
/// </summary>
|
|
public int SourceLayer { get; init; }
|
|
|
|
/// <summary>
|
|
/// 目标层级。
|
|
/// </summary>
|
|
public int TargetLayer { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换时间。
|
|
/// </summary>
|
|
public DateTime TransitionTimeUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换耗时(毫秒)。
|
|
/// </summary>
|
|
public long TransitionElapsedMs { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换结果描述。
|
|
/// </summary>
|
|
public string? ResultDescription { get; init; }
|
|
|
|
/// <summary>
|
|
/// 是否触发了保护策略。
|
|
/// </summary>
|
|
public bool ProtectionTriggered { get; init; }
|
|
|
|
/// <summary>
|
|
/// 触发的保护策略。
|
|
/// </summary>
|
|
public LayerTransitionProtectionStrategy TriggeredProtectionStrategy { get; init; }
|
|
|
|
/// <summary>
|
|
/// 回滚信息。
|
|
/// </summary>
|
|
public LayerTransitionRollbackInfo? RollbackInfo { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换回滚请求。
|
|
/// </summary>
|
|
public sealed class LayerTransitionRollbackRequest
|
|
{
|
|
/// <summary>
|
|
/// 请求ID。
|
|
/// </summary>
|
|
public Guid RequestId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 原转换ID。
|
|
/// </summary>
|
|
public Guid OriginalTransitionId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 产品类型编码。
|
|
/// </summary>
|
|
public string ProductTypeCode { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 会话ID。
|
|
/// </summary>
|
|
public string SessionId { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 当前层级。
|
|
/// </summary>
|
|
public int CurrentLayer { get; init; }
|
|
|
|
/// <summary>
|
|
/// 回滚目标层级。
|
|
/// </summary>
|
|
public int RollbackTargetLayer { get; init; }
|
|
|
|
/// <summary>
|
|
/// 回滚原因。
|
|
/// </summary>
|
|
public string Reason { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 回滚用户。
|
|
/// </summary>
|
|
public string RollbackUser { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 回滚时间。
|
|
/// </summary>
|
|
public DateTime RollbackTimeUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换回滚信息。
|
|
/// </summary>
|
|
public sealed class LayerTransitionRollbackInfo
|
|
{
|
|
/// <summary>
|
|
/// 回滚ID。
|
|
/// </summary>
|
|
public Guid RollbackId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 原转换ID。
|
|
/// </summary>
|
|
public Guid OriginalTransitionId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 回滚时间。
|
|
/// </summary>
|
|
public DateTime RollbackTimeUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 回滚原因。
|
|
/// </summary>
|
|
public string RollbackReason { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 回滚用户。
|
|
/// </summary>
|
|
public string RollbackUser { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换保护配置。
|
|
/// </summary>
|
|
public sealed class LayerTransitionProtectionConfig
|
|
{
|
|
/// <summary>
|
|
/// 配置ID。
|
|
/// </summary>
|
|
public Guid ConfigId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 产品类型编码。
|
|
/// </summary>
|
|
public string ProductTypeCode { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 层级编号。
|
|
/// </summary>
|
|
public int LayerNumber { get; init; }
|
|
|
|
/// <summary>
|
|
/// 保护策略。
|
|
/// </summary>
|
|
public LayerTransitionProtectionStrategy ProtectionStrategy { get; init; }
|
|
|
|
/// <summary>
|
|
/// 最小停留时间(秒)。
|
|
/// </summary>
|
|
public int MinimumStayTimeSeconds { get; init; }
|
|
|
|
/// <summary>
|
|
/// 最大停留时间(秒)。
|
|
/// </summary>
|
|
public int MaximumStayTimeSeconds { get; init; }
|
|
|
|
/// <summary>
|
|
/// 完成度阈值(百分比)。
|
|
/// </summary>
|
|
public double CompletionThreshold { get; init; }
|
|
|
|
/// <summary>
|
|
/// 是否允许强制转换。
|
|
/// </summary>
|
|
public bool AllowForceTransition { get; init; }
|
|
|
|
/// <summary>
|
|
/// 强制转换所需权限。
|
|
/// </summary>
|
|
public string RequiredPermissionForForce { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 是否启用自动回滚。
|
|
/// </summary>
|
|
public bool EnableAutoRollback { get; init; }
|
|
|
|
/// <summary>
|
|
/// 自动回滚条件。
|
|
/// </summary>
|
|
public IReadOnlyList<AutoRollbackCondition> AutoRollbackConditions { get; init; } = Array.Empty<AutoRollbackCondition>();
|
|
|
|
/// <summary>
|
|
/// 保护条件列表。
|
|
/// </summary>
|
|
public IReadOnlyList<ProtectionCondition> ProtectionConditions { get; init; } = Array.Empty<ProtectionCondition>();
|
|
|
|
/// <summary>
|
|
/// 是否启用。
|
|
/// </summary>
|
|
public bool IsEnabled { get; init; } = true;
|
|
|
|
/// <summary>
|
|
/// 创建时间。
|
|
/// </summary>
|
|
public DateTime CreatedAtUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 更新时间。
|
|
/// </summary>
|
|
public DateTime UpdatedAtUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 版本号。
|
|
/// </summary>
|
|
public string Version { get; init; } = "1.0";
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保护条件。
|
|
/// </summary>
|
|
public sealed class ProtectionCondition
|
|
{
|
|
/// <summary>
|
|
/// 条件ID。
|
|
/// </summary>
|
|
public Guid ConditionId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 条件名称。
|
|
/// </summary>
|
|
public string ConditionName { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 条件类型。
|
|
/// </summary>
|
|
public ProtectionConditionType ConditionType { get; init; }
|
|
|
|
/// <summary>
|
|
/// 是否为必须满足的条件。
|
|
/// </summary>
|
|
public bool IsMandatory { get; init; } = true;
|
|
|
|
/// <summary>
|
|
/// 阈值。
|
|
/// </summary>
|
|
public double Threshold { get; init; }
|
|
|
|
/// <summary>
|
|
/// 比较操作符。
|
|
/// </summary>
|
|
public ComparisonOperator ComparisonOperator { get; init; }
|
|
|
|
/// <summary>
|
|
/// 条件描述。
|
|
/// </summary>
|
|
public string? Description { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 自动回滚条件。
|
|
/// </summary>
|
|
public sealed class AutoRollbackCondition
|
|
{
|
|
/// <summary>
|
|
/// 条件ID。
|
|
/// </summary>
|
|
public Guid ConditionId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 条件名称。
|
|
/// </summary>
|
|
public string ConditionName { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 条件类型。
|
|
/// </summary>
|
|
public AutoRollbackConditionType ConditionType { get; init; }
|
|
|
|
/// <summary>
|
|
/// 阈值。
|
|
/// </summary>
|
|
public double Threshold { get; init; }
|
|
|
|
/// <summary>
|
|
/// 检查间隔(秒)。
|
|
/// </summary>
|
|
public int CheckIntervalSeconds { get; init; }
|
|
|
|
/// <summary>
|
|
/// 连续失败次数阈值。
|
|
/// </summary>
|
|
public int ConsecutiveFailuresThreshold { get; init; }
|
|
|
|
/// <summary>
|
|
/// 条件描述。
|
|
/// </summary>
|
|
public string? Description { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换历史。
|
|
/// </summary>
|
|
public sealed class LayerTransitionHistory
|
|
{
|
|
/// <summary>
|
|
/// 转换ID。
|
|
/// </summary>
|
|
public Guid TransitionId { get; init; }
|
|
|
|
/// <summary>
|
|
/// 产品类型编码。
|
|
/// </summary>
|
|
public string ProductTypeCode { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 会话ID。
|
|
/// </summary>
|
|
public string SessionId { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 转换类型。
|
|
/// </summary>
|
|
public LayerTransitionType TransitionType { get; init; }
|
|
|
|
/// <summary>
|
|
/// 源层级。
|
|
/// </summary>
|
|
public int SourceLayer { get; init; }
|
|
|
|
/// <summary>
|
|
/// 目标层级。
|
|
/// </summary>
|
|
public int TargetLayer { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换时间。
|
|
/// </summary>
|
|
public DateTime TransitionTimeUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换是否成功。
|
|
/// </summary>
|
|
public bool IsSuccess { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换原因。
|
|
/// </summary>
|
|
public string Reason { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 操作用户。
|
|
/// </summary>
|
|
public string OperatorUser { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 是否强制转换。
|
|
/// </summary>
|
|
public bool IsForced { get; init; }
|
|
|
|
/// <summary>
|
|
/// 保护策略是否触发。
|
|
/// </summary>
|
|
public bool ProtectionTriggered { get; init; }
|
|
|
|
/// <summary>
|
|
/// 回滚信息。
|
|
/// </summary>
|
|
public LayerTransitionRollbackInfo? RollbackInfo { get; init; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性。
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换统计信息。
|
|
/// </summary>
|
|
public sealed class LayerTransitionStatistics
|
|
{
|
|
/// <summary>
|
|
/// 总转换次数。
|
|
/// </summary>
|
|
public int TotalTransitions { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功转换次数。
|
|
/// </summary>
|
|
public int SuccessfulTransitions { get; init; }
|
|
|
|
/// <summary>
|
|
/// 失败转换次数。
|
|
/// </summary>
|
|
public int FailedTransitions { get; init; }
|
|
|
|
/// <summary>
|
|
/// 总体成功率。
|
|
/// </summary>
|
|
public double OverallSuccessRate => TotalTransitions > 0 ? (double)SuccessfulTransitions / TotalTransitions * 100 : 0.0;
|
|
|
|
/// <summary>
|
|
/// 按转换类型分组的统计。
|
|
/// </summary>
|
|
public Dictionary<LayerTransitionType, TransitionTypeStatistics> ByTransitionType { get; init; } = new();
|
|
|
|
/// <summary>
|
|
/// 按产品类型分组的统计。
|
|
/// </summary>
|
|
public Dictionary<string, ProductTypeTransitionStatistics> ByProductType { get; init; } = new();
|
|
|
|
/// <summary>
|
|
/// 按层级分组的统计。
|
|
/// </summary>
|
|
public Dictionary<int, LayerTransitionStatisticsByLayer> ByLayer { get; init; } = new();
|
|
|
|
/// <summary>
|
|
/// 强制转换统计。
|
|
/// </summary>
|
|
public ForceTransitionStatistics ForceTransitions { get; init; } = new();
|
|
|
|
/// <summary>
|
|
/// 保护触发统计。
|
|
/// </summary>
|
|
public ProtectionTriggerStatistics ProtectionTriggers { get; init; } = new();
|
|
|
|
/// <summary>
|
|
/// 统计开始时间。
|
|
/// </summary>
|
|
public DateTime StartTimeUtc { get; init; }
|
|
|
|
/// <summary>
|
|
/// 统计结束时间。
|
|
/// </summary>
|
|
public DateTime EndTimeUtc { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 转换类型统计。
|
|
/// </summary>
|
|
public sealed class TransitionTypeStatistics
|
|
{
|
|
/// <summary>
|
|
/// 转换类型。
|
|
/// </summary>
|
|
public LayerTransitionType TransitionType { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换次数。
|
|
/// </summary>
|
|
public int TransitionCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功次数。
|
|
/// </summary>
|
|
public int SuccessCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功率。
|
|
/// </summary>
|
|
public double SuccessRate => TransitionCount > 0 ? (double)SuccessCount / TransitionCount * 100 : 0.0;
|
|
|
|
/// <summary>
|
|
/// 平均耗时(毫秒)。
|
|
/// </summary>
|
|
public double AverageElapsedMs { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 产品类型转换统计。
|
|
/// </summary>
|
|
public sealed class ProductTypeTransitionStatistics
|
|
{
|
|
/// <summary>
|
|
/// 产品类型编码。
|
|
/// </summary>
|
|
public string ProductTypeCode { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 转换次数。
|
|
/// </summary>
|
|
public int TransitionCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功次数。
|
|
/// </summary>
|
|
public int SuccessCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功率。
|
|
/// </summary>
|
|
public double SuccessRate => TransitionCount > 0 ? (double)SuccessCount / TransitionCount * 100 : 0.0;
|
|
|
|
/// <summary>
|
|
/// 平均耗时(毫秒)。
|
|
/// </summary>
|
|
public double AverageElapsedMs { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按层级分组的转换统计。
|
|
/// </summary>
|
|
public sealed class LayerTransitionStatisticsByLayer
|
|
{
|
|
/// <summary>
|
|
/// 层级编号。
|
|
/// </summary>
|
|
public int LayerNumber { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换次数。
|
|
/// </summary>
|
|
public int TransitionCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功次数。
|
|
/// </summary>
|
|
public int SuccessCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功率。
|
|
/// </summary>
|
|
public double SuccessRate => TransitionCount > 0 ? (double)SuccessCount / TransitionCount * 100 : 0.0;
|
|
|
|
/// <summary>
|
|
/// 平均停留时间(秒)。
|
|
/// </summary>
|
|
public double AverageStayTimeSeconds { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 强制转换统计。
|
|
/// </summary>
|
|
public sealed class ForceTransitionStatistics
|
|
{
|
|
/// <summary>
|
|
/// 强制转换次数。
|
|
/// </summary>
|
|
public int ForceTransitionCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功次数。
|
|
/// </summary>
|
|
public int SuccessCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 成功率。
|
|
/// </summary>
|
|
public double SuccessRate => ForceTransitionCount > 0 ? (double)SuccessCount / ForceTransitionCount * 100 : 0.0;
|
|
|
|
/// <summary>
|
|
/// 按用户分组的统计。
|
|
/// </summary>
|
|
public Dictionary<string, int> ByUser { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保护触发统计。
|
|
/// </summary>
|
|
public sealed class ProtectionTriggerStatistics
|
|
{
|
|
/// <summary>
|
|
/// 保护触发次数。
|
|
/// </summary>
|
|
public int ProtectionTriggerCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 转换被阻止次数。
|
|
/// </summary>
|
|
public int TransitionBlockedCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 强制转换成功次数。
|
|
/// </summary>
|
|
public int ForceSuccessCount { get; init; }
|
|
|
|
/// <summary>
|
|
/// 按保护策略分组的统计。
|
|
/// </summary>
|
|
public Dictionary<LayerTransitionProtectionStrategy, int> ByStrategy { get; init; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换类型枚举。
|
|
/// </summary>
|
|
public enum LayerTransitionType
|
|
{
|
|
/// <summary>
|
|
/// 前进转换。
|
|
/// </summary>
|
|
Forward = 0,
|
|
|
|
/// <summary>
|
|
/// 后退转换。
|
|
/// </summary>
|
|
Backward = 1,
|
|
|
|
/// <summary>
|
|
/// 跳转转换。
|
|
/// </summary>
|
|
Jump = 2,
|
|
|
|
/// <summary>
|
|
/// 重置转换。
|
|
/// </summary>
|
|
Reset = 3
|
|
}
|
|
|
|
/// <summary>
|
|
/// 层级转换保护策略枚举。
|
|
/// </summary>
|
|
public enum LayerTransitionProtectionStrategy
|
|
{
|
|
/// <summary>
|
|
/// 无保护。
|
|
/// </summary>
|
|
None = 0,
|
|
|
|
/// <summary>
|
|
/// 时间保护。
|
|
/// </summary>
|
|
TimeProtection = 1,
|
|
|
|
/// <summary>
|
|
/// 完成度保护。
|
|
/// </summary>
|
|
CompletionProtection = 2,
|
|
|
|
/// <summary>
|
|
/// 综合保护。
|
|
/// </summary>
|
|
Comprehensive = 3,
|
|
|
|
/// <summary>
|
|
/// 严格保护。
|
|
/// </summary>
|
|
Strict = 4
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保护条件类型枚举。
|
|
/// </summary>
|
|
public enum ProtectionConditionType
|
|
{
|
|
/// <summary>
|
|
/// 停留时间条件。
|
|
/// </summary>
|
|
StayTime = 0,
|
|
|
|
/// <summary>
|
|
/// 完成度条件。
|
|
/// </summary>
|
|
Completion = 1,
|
|
|
|
/// <summary>
|
|
/// 错误状态条件。
|
|
/// </summary>
|
|
ErrorStatus = 2,
|
|
|
|
/// <summary>
|
|
/// 人工干预条件。
|
|
/// </summary>
|
|
ManualIntervention = 3,
|
|
|
|
/// <summary>
|
|
/// 系统状态条件。
|
|
/// </summary>
|
|
SystemStatus = 4
|
|
}
|
|
|
|
/// <summary>
|
|
/// 自动回滚条件类型枚举。
|
|
/// </summary>
|
|
public enum AutoRollbackConditionType
|
|
{
|
|
/// <summary>
|
|
/// 错误率条件。
|
|
/// </summary>
|
|
ErrorRate = 0,
|
|
|
|
/// <summary>
|
|
/// 性能条件。
|
|
/// </summary>
|
|
Performance = 1,
|
|
|
|
/// <summary>
|
|
/// 超时条件。
|
|
/// </summary>
|
|
Timeout = 2,
|
|
|
|
/// <summary>
|
|
/// 资源条件。
|
|
/// </summary>
|
|
Resource = 3
|
|
}
|
|
|
|
/// <summary>
|
|
/// 比较操作符枚举。
|
|
/// </summary>
|
|
public enum ComparisonOperator
|
|
{
|
|
/// <summary>
|
|
/// 等于。
|
|
/// </summary>
|
|
Equal = 0,
|
|
|
|
/// <summary>
|
|
/// 不等于。
|
|
/// </summary>
|
|
NotEqual = 1,
|
|
|
|
/// <summary>
|
|
/// 大于。
|
|
/// </summary>
|
|
GreaterThan = 2,
|
|
|
|
/// <summary>
|
|
/// 大于等于。
|
|
/// </summary>
|
|
GreaterThanOrEqual = 3,
|
|
|
|
/// <summary>
|
|
/// 小于。
|
|
/// </summary>
|
|
LessThan = 4,
|
|
|
|
/// <summary>
|
|
/// 小于等于。
|
|
/// </summary>
|
|
LessThanOrEqual = 5
|
|
}
|