/** 报告中心 / 安全隐患台账 / 批量检测 — 初始数据 */

function iso(d) {
  return new Date(d).toISOString()
}

export const DEFECT_STATUS = {
  DISCOVERED: 'discovered',
  REVIEWING: 'reviewing',
  CONFIRMED: 'confirmed',
  REMEDIATING: 'remediating',
  CLOSED: 'closed',
}

export const BATCH_STATUS = {
  PENDING: 'pending',
  RUNNING: 'running',
  COMPLETED: 'completed',
  FAILED: 'failed',
  CANCELLED: 'cancelled',
}

export const REPORT_TEMPLATES = [
  {
    template_id: 'weekly_inspection',
    name: '桥梁巡检周报',
    description: '汇总周期内安全隐患检测任务、安全隐患台账与预警处置情况',
    sections: ['检测任务统计', '隐患分级分布', '预警闭环', '建议措施'],
  },
  {
    template_id: 'special_detection',
    name: '专项检测报告',
    description: '针对单次或批量桥梁安全隐患检测输出详细指标与结果图索引',
    sections: ['检测对象', '模型与参数', '指标明细', '结论建议'],
  },
  {
    template_id: 'alert_summary',
    name: '监测预警汇总',
    description: '传感器预警、阈值越限与处置时效统计',
    sections: ['预警概览', '分级统计', '未关闭事项', '趋势说明'],
  },
]

export function createInitialProfessionalState() {
  const t = iso('2026-06-01T10:00:00')
  return {
    defects: [
      {
        defect_id: 1,
        defect_code: 'DEF-2026-001',
        bridge_section: '主跨箱梁',
        component: '底板',
        disease_type: '混凝土裂缝',
        grade: 'MODERATE',
        severity_score: 0.38,
        status: DEFECT_STATUS.CONFIRMED,
        detection_id: 10001,
        media_name: '主跨箱梁底板_S12.jpg',
        model_name: 'BridgeSeg-YOLOv8-L',
        reviewer: '',
        review_note: '',
        discovered_at: iso('2026-04-12T09:20:00'),
        updated_at: t,
      },
      {
        defect_id: 2,
        defect_code: 'DEF-2026-002',
        bridge_section: '3号墩',
        component: '立面',
        disease_type: '裂缝/剥落',
        grade: 'SEVERE',
        severity_score: 0.62,
        status: DEFECT_STATUS.REVIEWING,
        detection_id: 10002,
        media_name: 'Pier3_立面_北.mp4',
        model_name: 'CrackNet-Res50',
        reviewer: '',
        review_note: '',
        discovered_at: iso('2026-04-11T17:00:00'),
        updated_at: t,
      },
      {
        defect_id: 3,
        defect_code: 'DEF-2026-003',
        bridge_section: '伸缩缝 J03',
        component: '填缝区',
        disease_type: '剥落渗水',
        grade: 'MILD',
        severity_score: 0.22,
        status: DEFECT_STATUS.DISCOVERED,
        detection_id: 10003,
        media_name: '伸缩缝_J03.png',
        model_name: 'BridgeSeg-YOLOv8-L',
        reviewer: '',
        review_note: '',
        discovered_at: iso('2026-04-11T11:30:00'),
        updated_at: t,
      },
    ],
    batchJobs: [
      {
        batch_id: 1,
        batch_name: '四月上旬箱梁专项批量检测',
        model_id: 201,
        model_name: 'BridgeSeg-YOLOv8-L',
        status: BATCH_STATUS.COMPLETED,
        progress: 100,
        total_count: 3,
        success_count: 3,
        fail_count: 0,
        items: [
          { media_id: 301, media_name: '主跨箱梁底板_S12.jpg', status: 'completed', detection_id: 10001 },
          { media_id: 303, media_name: '伸缩缝_J03.png', status: 'completed', detection_id: 10003 },
          { media_id: 305, media_name: '桥面铺装_DRONE_01.jpg', status: 'completed', detection_id: null },
        ],
        created_at: iso('2026-04-10T08:00:00'),
        finished_at: iso('2026-04-10T09:15:00'),
      },
    ],
    reports: [
      {
        report_id: 1,
        template_id: 'weekly_inspection',
        template_name: '桥梁巡检周报',
        title: '检澜巡检周报_2026-W14',
        bridge_name: '示例长江大桥',
        period: '2026-04-01 ~ 2026-04-07',
        status: 'generated',
        file_name: '检澜巡检周报_2026-W14.xlsx',
        created_at: iso('2026-04-08T10:00:00'),
        created_by: 'admin',
      },
    ],
    nextIds: { defect: 4, batch: 2, report: 2 },
  }
}
