/**
 * filekorolheader: AI模型类型定义 - 模型应用中心相关类型
 * 功能：应用类型、执行历史、调度任务等类型定义
 * 路径：/types/ai-model.ts
 * 规范：遵循crop-x/docs/开发项目规范.md，使用TypeScript类型安全
 */

export type ApplicationType = '智能灌溉' | '病虫害预警' | '施肥推荐' | '产量预测' | '生长监测' | '其他';
export type ApplicationStatus = '运行中' | '已停止' | '故障';
export type TriggerType = '定时触发' | '周期触发' | '事件触发' | '手动触发';
export type TaskStatus = '等待中' | '运行中' | '已完成' | '失败' | '已取消';
export type Priority = '高' | '中' | '低';
export type OutputFormat = '折线图' | '饼状图' | '表格' | '文字';

export interface Application {
  id: string;
  name: string;
  type: ApplicationType;
  description: string;
  modelName: string;
  modelVersion: string;
  inputConfig: {
    fields: string[];
  };
  outputConfig: {
    format: OutputFormat;
  };
  status: ApplicationStatus;
  createTime: string;
  lastRunTime?: string;
  runCount: number;
  successRate: number;
  avgExecutionTime: number;
}

export interface ExecutionHistory {
  id: string;
  executeTime: string;
  status: TaskStatus;
  executionTime: number;
  result?: string;
  errorMessage?: string;
}

export interface ScheduleTask {
  id: string;
  taskNo: string;
  applicationName: string;
  triggerType: TriggerType;
  priority: Priority;
  scheduledTime: string;
  actualStartTime?: string;
  actualEndTime?: string;
  status: TaskStatus;
  executionTime?: number;
  retryCount: number;
  maxRetry: number;
  errorMessage?: string;
  result?: string;
  executionHistory?: ExecutionHistory[];
}

export interface TaskQueue {
  waiting: number;
  running: number;
  completed: number;
  failed: number;
}

export interface ModelService {
  id: string;
  name: string;
  version: string;
  type: string;
  status: string;
}