185 lines
4.4 KiB
TypeScript
185 lines
4.4 KiB
TypeScript
import { AlertSeverity } from './common';
|
|
|
|
export interface WeightStatistics {
|
|
averageWeight: { value: number; unit: string; status: 'ok' | 'warning' | 'critical' };
|
|
avgDailyGain: { value: number; unit: string; status: 'ok' | 'warning' | 'critical' };
|
|
uniformity: { value: number; unit: string; status: 'ok' | 'warning' | 'critical' };
|
|
dataDate?: string; // Optional: display date for the data (e.g., "30 April 2026")
|
|
}
|
|
|
|
export interface WeightDataPoint {
|
|
day: number;
|
|
actual: number; // in grams
|
|
target: number | null; // in grams
|
|
}
|
|
|
|
export interface WeightDistributionPoint {
|
|
range: string; // e.g., "1.4-1.5kg"
|
|
count: number;
|
|
}
|
|
|
|
export enum WeightAlertType {
|
|
SLOW_GROWTH = 'Pertumbuhan Lambat',
|
|
POOR_UNIFORMITY = 'Keseragaman Buruk',
|
|
}
|
|
|
|
export interface WeightAlert {
|
|
id: string;
|
|
type: WeightAlertType;
|
|
severity: AlertSeverity;
|
|
timestamp: Date;
|
|
details: string;
|
|
}
|
|
|
|
export interface MultiCoopWeightData {
|
|
coopId: string;
|
|
coopName: string;
|
|
history: { day: number; weight: number }[];
|
|
}
|
|
|
|
export interface MultiCoopWeightSummary {
|
|
coopId: string;
|
|
coopName: string;
|
|
currentWeight: number;
|
|
adg: number;
|
|
uniformity: number;
|
|
deviation: number;
|
|
}
|
|
|
|
export interface MultiCoopChartPoint {
|
|
day: number;
|
|
[coopName: string]: number;
|
|
}
|
|
|
|
export interface CkaleWeightPoint {
|
|
day: number;
|
|
manual: number | null;
|
|
all: number | null;
|
|
front: number | null;
|
|
back: number | null;
|
|
}
|
|
|
|
export interface FcrDataPoint {
|
|
day: number;
|
|
manualFcr: number | null;
|
|
iotFcr: number | null;
|
|
cobbFcr: number | null;
|
|
}
|
|
|
|
// Weight Distribution API types
|
|
export interface WeightDistributionApiData {
|
|
tanggal: string; // YYYY-MM-DD
|
|
total_predictions: number;
|
|
total_chicken_count: number;
|
|
distribusi: {
|
|
range_bobot: string;
|
|
range_start: number;
|
|
range_end: number;
|
|
frekuensi: number;
|
|
total_ayam: number;
|
|
rata_rata: number;
|
|
}[];
|
|
statistik: {
|
|
min: number | null;
|
|
max: number | null;
|
|
avg: number | null;
|
|
Standard_deviasi: number | null;
|
|
uniformity: number | null;
|
|
};
|
|
}
|
|
|
|
export interface WeightDistributionApiResponse {
|
|
success: boolean;
|
|
mode: 'yesterday' | 'range';
|
|
range_size: number;
|
|
data: WeightDistributionApiData | WeightDistributionApiData[]; // Single object for yesterday, array for range
|
|
}
|
|
|
|
// Extended distribution statistics
|
|
export interface WeightDistributionStats {
|
|
date: string; // Display date
|
|
dayOfCycle: number;
|
|
totalPredictions: number;
|
|
totalChickenCount: number;
|
|
min: number | null;
|
|
max: number | null;
|
|
avg: number | null;
|
|
standardDeviation: number | null;
|
|
uniformity: number | null;
|
|
}
|
|
|
|
// Sensor Weight Summary API types
|
|
export interface SensorWeightSummary {
|
|
device_id: string;
|
|
device_name: string;
|
|
total_weight_prediction: number;
|
|
total_weight_actual: number;
|
|
avg_weight_prediction: number;
|
|
avg_weight_actual: number;
|
|
chicken_count: number;
|
|
}
|
|
|
|
export interface SensorWeightSummaryResponse {
|
|
success: boolean;
|
|
data: SensorWeightSummary[];
|
|
}
|
|
|
|
// Scale Predictions Range API types
|
|
export interface ScalePredictionItem {
|
|
id: string;
|
|
cage_name: string;
|
|
age: number; // Day of cycle
|
|
total_weight_prediction: number;
|
|
total_weight_actual: number;
|
|
avg_weight_prediction: number;
|
|
avg_weight_actual: number;
|
|
chicken_count: number;
|
|
captured_at: string; // ISO datetime
|
|
image_url: string;
|
|
device: string; // Device ID
|
|
}
|
|
|
|
export interface ScalePredictionDayData {
|
|
date: string; // YYYY-MM-DD
|
|
items: ScalePredictionItem[];
|
|
}
|
|
|
|
export interface ScalePredictionRangeResponse {
|
|
success: boolean;
|
|
data: ScalePredictionDayData[];
|
|
}
|
|
|
|
// Processed chart data types
|
|
export interface DailyWeightPoint {
|
|
day: number;
|
|
date: string; // YYYY-MM-DD
|
|
actual: number; // Average weight
|
|
target: number; // Target weight from Cobb standard
|
|
min: number; // Min weight for the day
|
|
max: number; // Max weight for the day
|
|
chickenCount: number; // Total chickens weighed
|
|
}
|
|
|
|
export interface DailyWeightGainPoint {
|
|
day: number;
|
|
date: string;
|
|
gain: number; // Weight gain from previous day
|
|
targetGain: number; // Expected gain from Cobb standard
|
|
status: 'above' | 'near' | 'below'; // Performance vs target
|
|
}
|
|
|
|
export interface DeviceWeightData {
|
|
deviceId: string;
|
|
deviceName: string;
|
|
avgWeight: number;
|
|
chickenCount: number;
|
|
isOnline: boolean;
|
|
lastOnline: string;
|
|
}
|
|
|
|
export interface PerDeviceTrendPoint {
|
|
day: number;
|
|
date: string;
|
|
[deviceName: string]: number | string; // Dynamic device names as keys
|
|
}
|