using OrpaonVision.Core.Results;
using OrpaonVision.Core.Common;
namespace OrpaonVision.Core.Statistics;
///
/// 统计服务接口。
///
public interface IStatisticsService
{
///
/// 获取节拍统计信息。
///
/// 开始时间。
/// 结束时间。
/// 产品类型编码(可选)。
/// 取消令牌。
/// 节拍统计信息。
Task> GetCycleTimeStatisticsAsync(DateTime startTime, DateTime endTime, string? productTypeCode = null, CancellationToken cancellationToken = default);
///
/// 获取班次统计信息。
///
/// 班次日期。
/// 班次类型(可选)。
/// 产品类型编码(可选)。
/// 取消令牌。
/// 班次统计信息。
Task> GetShiftStatisticsAsync(DateTime shiftDate, ShiftType? shiftType = null, string? productTypeCode = null, CancellationToken cancellationToken = default);
///
/// 获取班次列表。
///
/// 开始日期。
/// 结束日期。
/// 取消令牌。
/// 班次列表。
Task>> GetShiftListAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default);
///
/// 获取生产效率统计。
///
/// 开始时间。
/// 结束时间。
/// 产品类型编码(可选)。
/// 统计粒度。
/// 取消令牌。
/// 生产效率统计。
Task> GetProductionEfficiencyStatisticsAsync(DateTime startTime, DateTime endTime, string? productTypeCode = null, StatisticsGranularity granularity = StatisticsGranularity.Hourly, CancellationToken cancellationToken = default);
///
/// 获取质量统计信息。
///
/// 开始时间。
/// 结束时间。
/// 产品类型编码(可选)。
/// 取消令牌。
/// 质量统计信息。
Task> GetQualityStatisticsAsync(DateTime startTime, DateTime endTime, string? productTypeCode = null, CancellationToken cancellationToken = default);
///
/// 获取设备利用率统计。
///
/// 开始时间。
/// 结束时间。
/// 设备ID(可选)。
/// 取消令牌。
/// 设备利用率统计。
Task> GetEquipmentUtilizationStatisticsAsync(DateTime startTime, DateTime endTime, string? equipmentId = null, CancellationToken cancellationToken = default);
///
/// 获取报警统计信息。
///
/// 开始时间。
/// 结束时间。
/// 报警级别(可选)。
/// 取消令牌。
/// 报警统计信息。
Task> GetAlarmStatisticsSummaryAsync(DateTime startTime, DateTime endTime, AlarmLevel? alarmLevel = null, CancellationToken cancellationToken = default);
///
/// 获取综合生产报告。
///
/// 报告类型。
/// 开始时间。
/// 结束时间。
/// 产品类型编码(可选)。
/// 取消令牌。
/// 综合生产报告。
Task> GetComprehensiveProductionReportAsync(ProductionReportType reportType, DateTime startTime, DateTime endTime, string? productTypeCode = null, CancellationToken cancellationToken = default);
///
/// 获取实时统计仪表板数据。
///
/// 产品类型编码(可选)。
/// 取消令牌。
/// 实时统计仪表板数据。
Task> GetRealTimeStatisticsDashboardAsync(string? productTypeCode = null, CancellationToken cancellationToken = default);
///
/// 获取历史趋势数据。
///
/// 指标类型。
/// 开始时间。
/// 结束时间。
/// 产品类型编码(可选)。
/// 统计粒度。
/// 取消令牌。
/// 历史趋势数据。
Task> GetHistoricalTrendDataAsync(MetricType metricType, DateTime startTime, DateTime endTime, string? productTypeCode = null, StatisticsGranularity granularity = StatisticsGranularity.Hourly, CancellationToken cancellationToken = default);
///
/// 创建统计配置。
///
/// 统计配置。
/// 取消令牌。
/// 创建结果。
Task> CreateStatisticsConfigAsync(StatisticsConfig config, CancellationToken cancellationToken = default);
///
/// 更新统计配置。
///
/// 统计配置。
/// 取消令牌。
/// 更新结果。
Task UpdateStatisticsConfigAsync(StatisticsConfig config, CancellationToken cancellationToken = default);
///
/// 获取统计配置。
///
/// 配置类型。
/// 产品类型编码(可选)。
/// 取消令牌。
/// 统计配置。
Task> GetStatisticsConfigAsync(StatisticsConfigType configType, string? productTypeCode = null, CancellationToken cancellationToken = default);
///
/// 导出统计数据。
///
/// 导出请求。
/// 取消令牌。
/// 导出结果。
Task> ExportStatisticsAsync(StatisticsExportRequest exportRequest, CancellationToken cancellationToken = default);
}
///
/// 节拍统计信息。
///
public sealed class CycleTimeStatistics
{
///
/// 统计时间范围。
///
public TimeRange TimeRange { get; init; } = new();
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 总处理数量。
///
public int TotalProcessedCount { get; init; }
///
/// 成功处理数量。
///
public int SuccessfulProcessedCount { get; init; }
///
/// 失败处理数量。
///
public int FailedProcessedCount { get; init; }
///
/// 总体成功率。
///
public double OverallSuccessRate => TotalProcessedCount > 0 ? (double)SuccessfulProcessedCount / TotalProcessedCount * 100 : 0.0;
///
/// 平均节拍时间(秒)。
///
public double AverageCycleTimeSeconds { get; init; }
///
/// 最短节拍时间(秒)。
///
public double MinCycleTimeSeconds { get; init; }
///
/// 最长节拍时间(秒)。
///
public double MaxCycleTimeSeconds { get; init; }
///
/// 节拍时间标准差(秒)。
///
public double CycleTimeStandardDeviationSeconds { get; init; }
///
/// 目标节拍时间(秒)。
///
public double TargetCycleTimeSeconds { get; init; }
///
/// 节拍达成率。
///
public double CycleTimeAchievementRate => TargetCycleTimeSeconds > 0 ? (double)CountAchievedCycleTime / TotalProcessedCount * 100 : 0.0;
///
/// 达到目标节拍的数量。
///
public int CountAchievedCycleTime { get; init; }
///
/// 按小时分组的节拍统计。
///
public Dictionary ByHour { get; init; } = new();
///
/// 按产品类型分组的节拍统计。
///
public Dictionary ByProductType { get; init; } = new();
///
/// 节拍时间分布。
///
public CycleTimeDistribution Distribution { get; init; } = new();
///
/// 趋势分析。
///
public CycleTimeTrend Trend { get; init; } = new();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 时间范围。
///
public sealed class TimeRange
{
///
/// 开始时间。
///
public DateTime StartTimeUtc { get; init; }
///
/// 结束时间。
///
public DateTime EndTimeUtc { get; init; }
///
/// 时间跨度(小时)。
///
public double DurationHours => (EndTimeUtc - StartTimeUtc).TotalHours;
}
///
/// 按小时分组的节拍统计。
///
public sealed class HourlyCycleTimeStatistics
{
///
/// 小时。
///
public int Hour { get; init; }
///
/// 处理数量。
///
public int ProcessedCount { get; init; }
///
/// 成功数量。
///
public int SuccessCount { get; init; }
///
/// 平均节拍时间(秒)。
///
public double AverageCycleTimeSeconds { get; init; }
///
/// 成功率。
///
public double SuccessRate => ProcessedCount > 0 ? (double)SuccessCount / ProcessedCount * 100 : 0.0;
}
///
/// 按产品类型分组的节拍统计。
///
public sealed class ProductTypeCycleTimeStatistics
{
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 处理数量。
///
public int ProcessedCount { get; init; }
///
/// 成功数量。
///
public int SuccessCount { get; init; }
///
/// 平均节拍时间(秒)。
///
public double AverageCycleTimeSeconds { get; init; }
///
/// 成功率。
///
public double SuccessRate => ProcessedCount > 0 ? (double)SuccessCount / ProcessedCount * 100 : 0.0;
}
///
/// 节拍时间分布。
///
public sealed class CycleTimeDistribution
{
///
/// 小于目标时间的数量。
///
public int BelowTargetCount { get; init; }
///
/// 在目标时间±10%范围内的数量。
///
public int WithinTargetRangeCount { get; init; }
///
/// 超过目标时间10%的数量。
///
public int AboveTargetRangeCount { get; init; }
///
/// 小于目标时间的百分比。
///
public double BelowTargetPercentage { get; init; }
///
/// 在目标时间±10%范围内的百分比。
///
public double WithinTargetRangePercentage { get; init; }
///
/// 超过目标时间10%的百分比。
///
public double AboveTargetRangePercentage { get; init; }
}
///
/// 节拍趋势分析。
///
public sealed class CycleTimeTrend
{
///
/// 趋势方向。
///
public TrendDirection Direction { get; init; }
///
/// 变化率(百分比)。
///
public double ChangeRatePercentage { get; init; }
///
/// 趋势描述。
///
public string TrendDescription { get; init; } = string.Empty;
///
/// 预测下个周期的节拍时间(秒)。
///
public double PredictedNextCycleTimeSeconds { get; init; }
///
/// 置信度。
///
public double Confidence { get; init; }
}
///
/// 班次统计信息。
///
public sealed class ShiftStatistics
{
///
/// 班次信息。
///
public ShiftInfo ShiftInfo { get; init; } = new();
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 计划生产数量。
///
public int PlannedProductionCount { get; init; }
///
/// 实际生产数量。
///
public int ActualProductionCount { get; init; }
///
/// 合格产品数量。
///
public int QualifiedProductionCount { get; init; }
///
/// 不合格产品数量。
///
public int UnqualifiedProductionCount { get; init; }
///
/// 生产完成率。
///
public double ProductionCompletionRate => PlannedProductionCount > 0 ? (double)ActualProductionCount / PlannedProductionCount * 100 : 0.0;
///
/// 质量合格率。
///
public double QualityPassRate => ActualProductionCount > 0 ? (double)QualifiedProductionCount / ActualProductionCount * 100 : 0.0;
///
/// 班次开始时间。
///
public DateTime ShiftStartTimeUtc { get; init; }
///
/// 班次结束时间。
///
public DateTime ShiftEndTimeUtc { get; init; }
///
/// 实际工作时间(小时)。
///
public double ActualWorkingHours { get; init; }
///
/// 设备停机时间(小时)。
///
public double EquipmentDowntimeHours { get; init; }
///
/// 设备利用率。
///
public double EquipmentUtilizationRate => ActualWorkingHours > 0 ? (ActualWorkingHours - EquipmentDowntimeHours) / ActualWorkingHours * 100 : 0.0;
///
/// 平均节拍时间(秒)。
///
public double AverageCycleTimeSeconds { get; init; }
///
/// 班次效率。
///
public double ShiftEfficiency => ActualWorkingHours > 0 ? (double)ActualProductionCount / ActualWorkingHours : 0.0;
///
/// 按小时分组的统计。
///
public Dictionary ByHour { get; init; } = new();
///
/// 按产品类型分组的统计。
///
public Dictionary ByProductType { get; init; } = new();
///
/// 异常事件统计。
///
public ShiftAnomalyStatistics AnomalyStatistics { get; init; } = new();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 班次信息。
///
public sealed class ShiftInfo
{
///
/// 班次ID。
///
public Guid ShiftId { get; init; }
///
/// 班次日期。
///
public DateTime ShiftDate { get; init; }
///
/// 班次类型。
///
public ShiftType ShiftType { get; init; }
///
/// 班次名称。
///
public string ShiftName { get; init; } = string.Empty;
///
/// 班次开始时间。
///
public TimeSpan StartTime { get; init; }
///
/// 班次结束时间。
///
public TimeSpan EndTime { get; init; }
///
/// 班次时长(小时)。
///
public double DurationHours => (EndTime - StartTime).TotalHours;
///
/// 操作员列表。
///
public IReadOnlyList Operators { get; init; } = Array.Empty();
///
/// 主管。
///
public string? Supervisor { get; init; }
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 按小时分组的班次统计。
///
public sealed class HourlyShiftStatistics
{
///
/// 小时。
///
public int Hour { get; init; }
///
/// 生产数量。
///
public int ProductionCount { get; init; }
///
/// 合格数量。
///
public int QualifiedCount { get; init; }
///
/// 质量合格率。
///
public double QualityPassRate => ProductionCount > 0 ? (double)QualifiedCount / ProductionCount * 100 : 0.0;
///
/// 设备运行时间(分钟)。
///
public double EquipmentRunningMinutes { get; init; }
///
/// 设备停机时间(分钟)。
///
public double EquipmentDowntimeMinutes { get; init; }
}
///
/// 按产品类型分组的班次统计。
///
public sealed class ProductTypeShiftStatistics
{
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 生产数量。
///
public int ProductionCount { get; init; }
///
/// 合格数量。
///
public int QualifiedCount { get; init; }
///
/// 质量合格率。
///
public double QualityPassRate => ProductionCount > 0 ? (double)QualifiedCount / ProductionCount * 100 : 0.0;
///
/// 平均节拍时间(秒)。
///
public double AverageCycleTimeSeconds { get; init; }
}
///
/// 班次异常统计。
///
public sealed class ShiftAnomalyStatistics
{
///
/// 总异常数量。
///
public int TotalAnomalyCount { get; init; }
///
/// 设备故障数量。
///
public int EquipmentFailureCount { get; init; }
///
/// 质量异常数量。
///
public int QualityAnomalyCount { get; init; }
///
/// 工艺异常数量。
///
public int ProcessAnomalyCount { get; init; }
///
/// 停机时间(分钟)。
///
public double DowntimeMinutes { get; init; }
///
/// 异常率。
///
public double AnomalyRate { get; init; }
}
///
/// 生产效率统计。
///
public sealed class ProductionEfficiencyStatistics
{
///
/// 统计时间范围。
///
public TimeRange TimeRange { get; init; } = new();
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 统计粒度。
///
public StatisticsGranularity Granularity { get; init; }
///
/// 计划工作时间(小时)。
///
public double PlannedWorkingHours { get; init; }
///
/// 实际工作时间(小时)。
///
public double ActualWorkingHours { get; init; }
///
/// 设备运行时间(小时)。
///
public double EquipmentRunningHours { get; init; }
///
/// 计划生产数量。
///
public int PlannedProductionCount { get; init; }
///
/// 实际生产数量。
///
public int ActualProductionCount { get; init; }
///
/// 合格生产数量。
///
public int QualifiedProductionCount { get; init; }
///
/// 时间利用率。
///
public double TimeUtilizationRate => PlannedWorkingHours > 0 ? ActualWorkingHours / PlannedWorkingHours * 100 : 0.0;
///
/// 设备利用率。
///
public double EquipmentUtilizationRate => ActualWorkingHours > 0 ? EquipmentRunningHours / ActualWorkingHours * 100 : 0.0;
///
/// 生产完成率。
///
public double ProductionCompletionRate => PlannedProductionCount > 0 ? (double)ActualProductionCount / PlannedProductionCount * 100 : 0.0;
///
/// 质量合格率。
///
public double QualityPassRate => ActualProductionCount > 0 ? (double)QualifiedProductionCount / ActualProductionCount * 100 : 0.0;
///
/// 综合效率(OEE)。
///
public double OverallEquipmentEffectiveness => TimeUtilizationRate * EquipmentUtilizationRate * ProductionCompletionRate * QualityPassRate / 10000;
///
/// 按时间分组的效率数据。
///
public Dictionary ByTimeSlot { get; init; } = new();
///
/// 效率趋势分析。
///
public EfficiencyTrend Trend { get; init; } = new();
///
/// 效率基准对比。
///
public EfficiencyBenchmark Benchmark { get; init; } = new();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 时间段效率。
///
public sealed class TimeSlotEfficiency
{
///
/// 时间点。
///
public DateTime TimeSlot { get; init; }
///
/// 生产数量。
///
public int ProductionCount { get; init; }
///
/// 合格数量。
///
public int QualifiedCount { get; init; }
///
/// 设备运行时间(分钟)。
///
public double EquipmentRunningMinutes { get; init; }
///
/// 综合效率。
///
public double OverallEfficiency { get; init; }
}
///
/// 效率趋势分析。
///
public sealed class EfficiencyTrend
{
///
/// 趋势方向。
///
public TrendDirection Direction { get; init; }
///
/// 变化率(百分比)。
///
public double ChangeRatePercentage { get; init; }
///
/// 趋势描述。
///
public string TrendDescription { get; init; } = string.Empty;
///
/// 预测下个周期的效率。
///
public double PredictedNextEfficiency { get; init; }
///
/// 置信度。
///
public double Confidence { get; init; }
}
///
/// 效率基准对比。
///
public sealed class EfficiencyBenchmark
{
///
/// 历史最佳效率。
///
public double HistoricalBestEfficiency { get; init; }
///
/// 历史平均效率。
///
public double HistoricalAverageEfficiency { get; init; }
///
/// 行业基准效率。
///
public double IndustryBenchmarkEfficiency { get; init; }
///
/// 目标效率。
///
public double TargetEfficiency { get; init; }
///
/// 与历史最佳的差距。
///
public double GapToHistoricalBest => HistoricalBestEfficiency - (HistoricalBestEfficiency + IndustryBenchmarkEfficiency + TargetEfficiency) / 3;
///
/// 达标率。
///
public double AchievementRate => TargetEfficiency > 0 ? (HistoricalBestEfficiency + IndustryBenchmarkEfficiency + TargetEfficiency) / 3 / TargetEfficiency * 100 : 0.0;
}
///
/// 质量统计信息。
///
public sealed class QualityStatistics
{
///
/// 统计时间范围。
///
public TimeRange TimeRange { get; init; } = new();
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 总检测数量。
///
public int TotalInspectionCount { get; init; }
///
/// 合格数量。
///
public int QualifiedCount { get; init; }
///
/// 不合格数量。
///
public int UnqualifiedCount { get; init; }
///
/// 总体合格率。
///
public double OverallPassRate => TotalInspectionCount > 0 ? (double)QualifiedCount / TotalInspectionCount * 100 : 0.0;
///
/// 按缺陷类型分组的统计。
///
public Dictionary ByDefectType { get; init; } = new();
///
/// 按严重程度分组的统计。
///
public Dictionary BySeverity { get; init; } = new();
///
/// 按产品类型分组的统计。
///
public Dictionary ByProductType { get; init; } = new();
///
/// 按检测时间分组的统计。
///
public Dictionary ByTimeSlot { get; init; } = new();
///
/// 质量趋势分析。
///
public QualityTrend Trend { get; init; } = new();
///
/// 质量改进建议。
///
public IReadOnlyList ImprovementSuggestions { get; init; } = Array.Empty();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 缺陷统计。
///
public sealed class DefectStatistics
{
///
/// 缺陷类型。
///
public DefectType DefectType { get; init; }
///
/// 缺陷数量。
///
public int DefectCount { get; init; }
///
/// 占比。
///
public double Percentage { get; init; }
///
/// 平均严重程度。
///
public double AverageSeverity { get; init; }
}
///
/// 严重程度统计。
///
public sealed class SeverityStatistics
{
///
/// 严重程度。
///
public DefectSeverity Severity { get; init; }
///
/// 缺陷数量。
///
public int DefectCount { get; init; }
///
/// 占比。
///
public double Percentage { get; init; }
}
///
/// 按产品类型分组的质量统计。
///
public sealed class ProductTypeQualityStatistics
{
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 检测数量。
///
public int InspectionCount { get; init; }
///
/// 合格数量。
///
public int QualifiedCount { get; init; }
///
/// 合格率。
///
public double PassRate => InspectionCount > 0 ? (double)QualifiedCount / InspectionCount * 100 : 0.0;
}
///
/// 按检测时间的质量统计。
///
public sealed class QualityTimeSlotStatistics
{
///
/// 检测时间。
///
public DateTime InspectionTime { get; init; }
///
/// 检测数量。
///
public int InspectionCount { get; init; }
///
/// 合格数量。
///
public int QualifiedCount { get; init; }
///
/// 合格率。
///
public double PassRate => InspectionCount > 0 ? (double)QualifiedCount / InspectionCount * 100 : 0.0;
}
///
/// 质量趋势分析。
///
public sealed class QualityTrend
{
///
/// 趋势方向。
///
public TrendDirection Direction { get; init; }
///
/// 变化率(百分比)。
///
public double ChangeRatePercentage { get; init; }
///
/// 趋势描述。
///
public string TrendDescription { get; init; } = string.Empty;
///
/// 预测下个周期的合格率。
///
public double PredictedNextPassRate { get; init; }
///
/// 置信度。
///
public double Confidence { get; init; }
}
///
/// 质量改进建议。
///
public sealed class QualityImprovementSuggestion
{
///
/// 建议ID。
///
public Guid SuggestionId { get; init; }
///
/// 建议类型。
///
public SuggestionType SuggestionType { get; init; }
///
/// 建议标题。
///
public string Title { get; init; } = string.Empty;
///
/// 建议描述。
///
public string Description { get; init; } = string.Empty;
///
/// 优先级。
///
public int Priority { get; init; }
///
/// 预期效果。
///
public string ExpectedImpact { get; init; } = string.Empty;
///
/// 实施难度。
///
public ImplementationDifficulty Difficulty { get; init; }
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 建议类型枚举。
///
public enum SuggestionType
{
///
/// 工艺改进。
///
ProcessImprovement = 0,
///
/// 设备维护。
///
EquipmentMaintenance = 1,
///
/// 材料更换。
///
MaterialReplacement = 2,
///
/// 操作培训。
///
OperatorTraining = 3,
///
/// 环境改善。
///
EnvironmentImprovement = 4,
///
/// 检测优化。
///
InspectionOptimization = 5,
///
/// 其他建议。
///
Other = 6
}
///
/// 设备利用率统计。
///
public sealed class EquipmentUtilizationStatistics
{
///
/// 统计时间范围。
///
public TimeRange TimeRange { get; init; } = new();
///
/// 设备ID。
///
public string EquipmentId { get; init; } = string.Empty;
///
/// 设备名称。
///
public string EquipmentName { get; init; } = string.Empty;
///
/// 计划运行时间(小时)。
///
public double PlannedRunningHours { get; init; }
///
/// 实际运行时间(小时)。
///
public double ActualRunningHours { get; init; }
///
/// 生产时间(小时)。
///
public double ProductionHours { get; init; }
///
/// 维护时间(小时)。
///
public double MaintenanceHours { get; init; }
///
/// 故障时间(小时)。
///
public double FailureHours { get; init; }
///
/// 空闲时间(小时)。
///
public double IdleHours { get; init; }
///
/// 总体利用率。
///
public double OverallUtilizationRate => PlannedRunningHours > 0 ? ActualRunningHours / PlannedRunningHours * 100 : 0.0;
///
/// 生产利用率。
///
public double ProductionUtilizationRate => ActualRunningHours > 0 ? ProductionHours / ActualRunningHours * 100 : 0.0;
///
/// 可用率。
///
public double AvailabilityRate => PlannedRunningHours > 0 ? (PlannedRunningHours - MaintenanceHours - FailureHours) / PlannedRunningHours * 100 : 0.0;
///
/// 平均无故障时间(小时)。
///
public double MeanTimeBetweenFailuresHours { get; init; }
///
/// 平均修复时间(小时)。
///
public double MeanTimeToRepairHours { get; init; }
///
/// 按日期分组的利用率。
///
public Dictionary ByDate { get; init; } = new();
///
/// 利用率趋势分析。
///
public UtilizationTrend Trend { get; init; } = new();
///
/// 维护建议。
///
public IReadOnlyList MaintenanceSuggestions { get; init; } = Array.Empty();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 按日期分组的利用率统计。
///
public sealed class DailyUtilizationStatistics
{
///
/// 日期。
///
public DateTime Date { get; init; }
///
/// 计划运行时间(小时)。
///
public double PlannedRunningHours { get; init; }
///
/// 实际运行时间(小时)。
///
public double ActualRunningHours { get; init; }
///
/// 利用率。
///
public double UtilizationRate => PlannedRunningHours > 0 ? ActualRunningHours / PlannedRunningHours * 100 : 0.0;
}
///
/// 利用率趋势分析。
///
public sealed class UtilizationTrend
{
///
/// 趋势方向。
///
public TrendDirection Direction { get; init; }
///
/// 变化率(百分比)。
///
public double ChangeRatePercentage { get; init; }
///
/// 趋势描述。
///
public string TrendDescription { get; init; } = string.Empty;
///
/// 预测下个周期的利用率。
///
public double PredictedNextUtilization { get; init; }
///
/// 置信度。
///
public double Confidence { get; init; }
}
///
/// 维护建议。
///
public sealed class MaintenanceSuggestion
{
///
/// 建议ID。
///
public Guid SuggestionId { get; init; }
///
/// 维护类型。
///
public MaintenanceType MaintenanceType { get; init; }
///
/// 建议标题。
///
public string Title { get; init; } = string.Empty;
///
/// 建议描述。
///
public string Description { get; init; } = string.Empty;
///
/// 优先级。
///
public int Priority { get; init; }
///
/// 预计维护时间(小时)。
///
public double EstimatedMaintenanceHours { get; init; }
///
/// 预计成本。
///
public double EstimatedCost { get; init; }
///
/// 建议维护时间。
///
public DateTime? SuggestedMaintenanceTime { get; init; }
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 维护类型枚举。
///
public enum MaintenanceType
{
///
/// 预防性维护。
///
Preventive = 0,
///
/// 预测性维护。
///
Predictive = 1,
///
/// 纠正性维护。
///
Corrective = 2,
///
/// 紧急维护。
///
Emergency = 3,
///
/// 改善性维护。
///
Improvement = 4
}
///
/// 报警统计摘要。
///
public sealed class AlarmStatisticsSummary
{
///
/// 统计时间范围。
///
public TimeRange TimeRange { get; init; } = new();
///
/// 总报警数量。
///
public int TotalAlarmCount { get; init; }
///
/// 活跃报警数量。
///
public int ActiveAlarmCount { get; init; }
///
/// 已确认报警数量。
///
public int ConfirmedAlarmCount { get; init; }
///
/// 已清除报警数量。
///
public int ClearedAlarmCount { get; init; }
///
/// 按报警级别分组的统计。
///
public Dictionary ByAlarmLevel { get; init; } = new();
///
/// 按报警类型分组的统计。
///
public Dictionary ByAlarmType { get; init; } = new();
///
/// 平均确认时间(分钟)。
///
public double AverageConfirmTimeMinutes { get; init; }
///
/// 平均清除时间(分钟)。
///
public double AverageClearTimeMinutes { get; init; }
///
/// 报警频率(每小时)。
///
public double AlarmFrequencyPerHour { get; init; }
///
/// 报警趋势。
///
public AlarmTrend Trend { get; init; } = new();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 报警趋势分析。
///
public sealed class AlarmTrend
{
///
/// 趋势方向。
///
public TrendDirection Direction { get; init; }
///
/// 变化率(百分比)。
///
public double ChangeRatePercentage { get; init; }
///
/// 趋势描述。
///
public string TrendDescription { get; init; } = string.Empty;
///
/// 预测下个周期的报警数量。
///
public int PredictedNextAlarmCount { get; init; }
///
/// 置信度。
///
public double Confidence { get; init; }
}
///
/// 综合生产报告。
///
public sealed class ComprehensiveProductionReport
{
///
/// 报告ID。
///
public Guid ReportId { get; init; }
///
/// 报告类型。
///
public ProductionReportType ReportType { get; init; }
///
/// 报告时间范围。
///
public TimeRange TimeRange { get; init; } = new();
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 报告生成时间。
///
public DateTime GeneratedAtUtc { get; init; }
///
/// 执行摘要。
///
public ExecutiveSummary ExecutiveSummary { get; init; } = new();
///
/// 生产统计。
///
public ProductionStatistics Production { get; init; } = new();
///
/// 质量统计。
///
public QualityStatistics Quality { get; init; } = new();
///
/// 设备统计。
///
public EquipmentStatistics Equipment { get; init; } = new();
///
/// 报警统计。
///
public AlarmStatisticsSummary Alarms { get; init; } = new();
///
/// 趋势分析。
///
public TrendAnalysis Trends { get; init; } = new();
///
/// 改进建议。
///
public IReadOnlyList Recommendations { get; init; } = Array.Empty();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 生产报告类型枚举。
///
public enum ProductionReportType
{
///
/// 日报。
///
Daily = 0,
///
/// 周报。
///
Weekly = 1,
///
/// 月报。
///
Monthly = 2,
///
/// 季报。
///
Quarterly = 3,
///
/// 年报。
///
Annual = 4,
///
/// 自定义报告。
///
Custom = 5
}
///
/// 执行摘要。
///
public sealed class ExecutiveSummary
{
///
/// 总体评分。
///
public double OverallScore { get; init; }
///
/// 关键指标。
///
public Dictionary KeyMetrics { get; init; } = new();
///
/// 主要成就。
///
public IReadOnlyList Achievements { get; init; } = Array.Empty();
///
/// 主要问题。
///
public IReadOnlyList Issues { get; init; } = Array.Empty();
///
/// 摘要描述。
///
public string SummaryDescription { get; init; } = string.Empty;
}
///
/// 生产统计。
///
public sealed class ProductionStatistics
{
///
/// 计划产量。
///
public int PlannedProduction { get; init; }
///
/// 实际产量。
///
public int ActualProduction { get; init; }
///
/// 合格产量。
///
public int QualifiedProduction { get; init; }
///
/// 生产完成率。
///
public double ProductionCompletionRate => PlannedProduction > 0 ? (double)ActualProduction / PlannedProduction * 100 : 0.0;
///
/// 质量合格率。
///
public double QualityPassRate => ActualProduction > 0 ? (double)QualifiedProduction / ActualProduction * 100 : 0.0;
///
/// 平均节拍时间(秒)。
///
public double AverageCycleTimeSeconds { get; init; }
}
///
/// 设备统计。
///
public sealed class EquipmentStatistics
{
///
/// 设备数量。
///
public int EquipmentCount { get; init; }
///
/// 平均利用率。
///
public double AverageUtilizationRate { get; init; }
///
/// 平均可用率。
///
public double AverageAvailabilityRate { get; init; }
///
/// 总停机时间(小时)。
///
public double TotalDowntimeHours { get; init; }
}
///
/// 趋势分析。
///
public sealed class TrendAnalysis
{
///
/// 生产趋势。
///
public TrendDirection ProductionTrend { get; init; }
///
/// 质量趋势。
///
public TrendDirection QualityTrend { get; init; }
///
/// 设备趋势。
///
public TrendDirection EquipmentTrend { get; init; }
///
/// 报警趋势。
///
public TrendDirection AlarmTrend { get; init; }
///
/// 趋势描述。
///
public string TrendDescription { get; init; } = string.Empty;
}
///
/// 改进建议。
///
public sealed class ImprovementRecommendation
{
///
/// 建议ID。
///
public Guid RecommendationId { get; init; }
///
/// 建议类别。
///
public RecommendationCategory Category { get; init; }
///
/// 建议标题。
///
public string Title { get; init; } = string.Empty;
///
/// 建议描述。
///
public string Description { get; init; } = string.Empty;
///
/// 优先级。
///
public int Priority { get; init; }
///
/// 预期收益。
///
public string ExpectedBenefit { get; init; } = string.Empty;
///
/// 实施成本。
///
public double ImplementationCost { get; init; }
///
/// 投资回报率。
///
public double ReturnOnInvestment { get; init; }
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 建议类别枚举。
///
public enum RecommendationCategory
{
///
/// 生产优化。
///
ProductionOptimization = 0,
///
/// 质量改进。
///
QualityImprovement = 1,
///
/// 设备维护。
///
EquipmentMaintenance = 2,
///
/// 工艺改进。
///
ProcessImprovement = 3,
///
/// 人员培训。
///
PersonnelTraining = 4,
///
/// 成本控制。
///
CostControl = 5,
///
/// 安全改善。
///
SafetyImprovement = 6,
///
/// 其他建议。
///
Other = 7
}
///
/// 实时统计仪表板数据。
///
public sealed class RealTimeStatisticsDashboard
{
///
/// 数据更新时间。
///
public DateTime LastUpdatedUtc { get; init; }
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 当前班次信息。
///
public ShiftInfo CurrentShift { get; init; } = new();
///
/// 实时生产指标。
///
public RealTimeProductionMetrics Production { get; init; } = new();
///
/// 实时质量指标。
///
public RealTimeQualityMetrics Quality { get; init; } = new();
///
/// 实时设备指标。
///
public RealTimeEquipmentMetrics Equipment { get; init; } = new();
///
/// 实时报警指标。
///
public RealTimeAlarmMetrics Alarms { get; init; } = new();
///
/// 实时效率指标。
///
public RealTimeEfficiencyMetrics Efficiency { get; init; } = new();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 实时生产指标。
///
public sealed class RealTimeProductionMetrics
{
///
/// 当前小时产量。
///
public int CurrentHourProduction { get; init; }
///
/// 当前班次产量。
///
public int CurrentShiftProduction { get; init; }
///
/// 今日产量。
///
public int TodayProduction { get; init; }
///
/// 当前节拍时间(秒)。
///
public double CurrentCycleTimeSeconds { get; init; }
///
/// 节拍达成率。
///
public double CycleTimeAchievementRate { get; init; }
///
/// 生产速度趋势。
///
public TrendDirection ProductionSpeedTrend { get; init; }
}
///
/// 实时质量指标。
///
public sealed class RealTimeQualityMetrics
{
///
/// 当前小时合格率。
///
public double CurrentHourPassRate { get; init; }
///
/// 当前班次合格率。
///
public double CurrentShiftPassRate { get; init; }
///
/// 今日合格率。
///
public double TodayPassRate { get; init; }
///
/// 最近缺陷数量。
///
public int RecentDefectCount { get; init; }
///
/// 质量趋势。
///
public TrendDirection QualityTrend { get; init; }
}
///
/// 实时设备指标。
///
public sealed class RealTimeEquipmentMetrics
{
///
/// 运行设备数量。
///
public int RunningEquipmentCount { get; init; }
///
/// 停机设备数量。
///
public int DownEquipmentCount { get; init; }
///
/// 当前利用率。
///
public double CurrentUtilizationRate { get; init; }
///
/// 当前可用率。
///
public double CurrentAvailabilityRate { get; init; }
///
/// 设备状态趋势。
///
public TrendDirection EquipmentStatusTrend { get; init; }
}
///
/// 实时报警指标。
///
public sealed class RealTimeAlarmMetrics
{
///
/// 活跃报警数量。
///
public int ActiveAlarmCount { get; init; }
///
/// 今日新增报警数量。
///
public int TodayNewAlarmCount { get; init; }
///
/// 严重报警数量。
///
public int CriticalAlarmCount { get; init; }
///
/// 最近报警时间。
///
public DateTime? LastAlarmTime { get; init; }
///
/// 报警趋势。
///
public TrendDirection AlarmTrend { get; init; }
}
///
/// 实时效率指标。
///
public sealed class RealTimeEfficiencyMetrics
{
///
/// 当前OEE。
///
public double CurrentOEE { get; init; }
///
/// 时间利用率。
///
public double TimeUtilizationRate { get; init; }
///
/// 设备利用率。
///
public double EquipmentUtilizationRate { get; init; }
///
/// 性能效率。
///
public double PerformanceEfficiency { get; init; }
///
/// 效率趋势。
///
public TrendDirection EfficiencyTrend { get; init; }
}
///
/// 历史趋势数据。
///
public sealed class HistoricalTrendData
{
///
/// 指标类型。
///
public MetricType MetricType { get; init; }
///
/// 统计粒度。
///
public StatisticsGranularity Granularity { get; init; }
///
/// 时间范围。
///
public TimeRange TimeRange { get; init; } = new();
///
/// 趋势数据点。
///
public IReadOnlyList DataPoints { get; init; } = Array.Empty();
///
/// 趋势分析。
///
public TrendAnalysis TrendAnalysis { get; init; } = new();
///
/// 统计摘要。
///
public TrendStatisticsSummary Statistics { get; init; } = new();
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 指标类型枚举。
///
public enum MetricType
{
///
/// 产量。
///
Production = 0,
///
/// 质量。
///
Quality = 1,
///
/// 设备利用率。
///
EquipmentUtilization = 2,
///
/// 节拍时间。
///
CycleTime = 3,
///
/// OEE。
///
OEE = 4,
///
/// 报警数量。
///
AlarmCount = 5,
///
/// 停机时间。
///
Downtime = 6,
///
/// 效率。
///
Efficiency = 7
}
///
/// 统计粒度枚举。
///
public enum StatisticsGranularity
{
///
/// 按分钟。
///
Minutely = 0,
///
/// 按小时。
///
Hourly = 1,
///
/// 按班次。
///
Shiftly = 2,
///
/// 按天。
///
Daily = 3,
///
/// 按周。
///
Weekly = 4,
///
/// 按月。
///
Monthly = 5,
///
/// 按季度。
///
Quarterly = 6,
///
/// 按年。
///
Yearly = 7
}
///
/// 趋势数据点。
///
public sealed class TrendDataPoint
{
///
/// 时间点。
///
public DateTime Timestamp { get; init; }
///
/// 数值。
///
public double Value { get; init; }
///
/// 单位。
///
public string Unit { get; init; } = string.Empty;
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 趋势统计摘要。
///
public sealed class TrendStatisticsSummary
{
///
/// 数据点数量。
///
public int DataPointCount { get; init; }
///
/// 最小值。
///
public double MinValue { get; init; }
///
/// 最大值。
///
public double MaxValue { get; init; }
///
/// 平均值。
///
public double AverageValue { get; init; }
///
/// 中位数。
///
public double MedianValue { get; init; }
///
/// 标准差。
///
public double StandardDeviation { get; init; }
///
/// 变异系数。
///
public double CoefficientOfVariation => AverageValue > 0 ? StandardDeviation / AverageValue : 0.0;
}
///
/// 统计配置。
///
public sealed class StatisticsConfig
{
///
/// 配置ID。
///
public Guid ConfigId { get; init; }
///
/// 配置类型。
///
public StatisticsConfigType ConfigType { get; init; }
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 配置名称。
///
public string ConfigName { get; init; } = string.Empty;
///
/// 配置描述。
///
public string ConfigDescription { get; init; } = string.Empty;
///
/// 配置参数。
///
public Dictionary Parameters { get; init; } = new();
///
/// 是否启用。
///
public bool IsEnabled { get; init; } = true;
///
/// 创建时间。
///
public DateTime CreatedAtUtc { get; init; }
///
/// 更新时间。
///
public DateTime UpdatedAtUtc { get; init; }
///
/// 版本号。
///
public string Version { get; init; } = "1.0";
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 统计配置类型枚举。
///
public enum StatisticsConfigType
{
///
/// 节拍统计配置。
///
CycleTime = 0,
///
/// 班次统计配置。
///
Shift = 1,
///
/// 质量统计配置。
///
Quality = 2,
///
/// 设备统计配置。
///
Equipment = 3,
///
/// 报警统计配置。
///
Alarm = 4,
///
/// 效率统计配置。
///
Efficiency = 5,
///
/// 综合报告配置。
///
Comprehensive = 6,
///
/// 实时监控配置。
///
RealTime = 7
}
///
/// 统计导出请求。
///
public sealed class StatisticsExportRequest
{
///
/// 请求ID。
///
public Guid RequestId { get; init; }
///
/// 导出类型。
///
public StatisticsExportType ExportType { get; init; }
///
/// 导出格式。
///
public ExportFormat ExportFormat { get; init; }
///
/// 统计类型。
///
public StatisticsType StatisticsType { get; init; }
///
/// 时间范围。
///
public TimeRange TimeRange { get; init; } = new();
///
/// 产品类型编码。
///
public string ProductTypeCode { get; init; } = string.Empty;
///
/// 统计粒度。
///
public StatisticsGranularity Granularity { get; init; }
///
/// 导出参数。
///
public Dictionary ExportParameters { get; init; } = new();
///
/// 请求用户。
///
public string RequestUser { get; init; } = string.Empty;
///
/// 请求时间。
///
public DateTime RequestTimeUtc { get; init; }
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 统计导出结果。
///
public sealed class StatisticsExportResult
{
///
/// 请求ID。
///
public Guid RequestId { get; init; }
///
/// 是否成功导出。
///
public bool IsSuccess { get; init; }
///
/// 导出文件路径。
///
public string? FilePath { get; init; }
///
/// 导出文件大小(字节)。
///
public long FileSizeBytes { get; init; }
///
/// 导出记录数量。
///
public int RecordCount { get; init; }
///
/// 导出耗时(毫秒)。
///
public long ExportElapsedMs { get; init; }
///
/// 导出时间。
///
public DateTime ExportTimeUtc { get; init; }
///
/// 结果描述。
///
public string? ResultDescription { get; init; }
///
/// 扩展属性。
///
public Dictionary ExtendedProperties { get; init; } = new();
}
///
/// 统计导出类型枚举。
///
public enum StatisticsExportType
{
///
/// 节拍统计导出。
///
CycleTime = 0,
///
/// 班次统计导出。
///
Shift = 1,
///
/// 质量统计导出。
///
Quality = 2,
///
/// 设备统计导出。
///
Equipment = 3,
///
/// 报警统计导出。
///
Alarm = 4,
///
/// 效率统计导出。
///
Efficiency = 5,
///
/// 综合报告导出。
///
Comprehensive = 6,
///
/// 历史趋势导出。
///
HistoricalTrend = 7
}
///
/// 统计类型枚举。
///
public enum StatisticsType
{
///
/// 节拍统计。
///
CycleTime = 0,
///
/// 班次统计。
///
Shift = 1,
///
/// 生产效率统计。
///
ProductionEfficiency = 2,
///
/// 质量统计。
///
Quality = 3,
///
/// 设备利用率统计。
///
EquipmentUtilization = 4,
///
/// 报警统计摘要。
///
AlarmSummary = 5,
///
/// 综合生产报告。
///
ComprehensiveReport = 6
}
///
/// 班次类型枚举。
///
public enum ShiftType
{
///
/// 早班。
///
Morning = 0,
///
/// 中班。
///
Afternoon = 1,
///
/// 晚班。
///
Night = 2,
///
/// 通宵班。
///
Overnight = 3,
///
/// 全天班。
///
AllDay = 4
}