import dayjs from 'dayjs';
import { getGoafList, getMineData } from '../../system/algorithm/algorithm.api';
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { TreeItem } from '/@/components/Tree/index';
import { getGoafData } from './monitor.api';

// 实时数据相关
export const columns: BasicColumn[] = [
  {
    title: '序号',
    dataIndex: 'orderNo',
  },
  {
    title: '区域',
    dataIndex: 'enforcement',
  },
  {
    title: '煤矿名称',
    dataIndex: 'mineName',
  },
  {
    title: '密闭名称',
    dataIndex: 'sealedName',
  },
  {
    title: '所属煤层',
    dataIndex: 'coalSeam',
  },
  {
    title: '自燃倾向性',
    dataIndex: 'riskLevel',
  },
  {
    title: 'CO(ppm)',
    dataIndex: 'COVal',
  },
  {
    title: 'CH4(%)',
    dataIndex: 'CH4Val',
  },
  {
    title: 'C2H2(ppm)',
    dataIndex: 'C2H2Val',
  },
  {
    title: 'O2(%)',
    dataIndex: 'O2Val',
  },
  {
    title: '温度(℃)',
    dataIndex: 'temperature',
  },
  {
    title: '压差(Pa)',
    dataIndex: 'pressureDiff',
  },
  {
    title: '是否漏风',
    dataIndex: 'leakage',
  },
  {
    title: '自然发火隐患',
    dataIndex: 'fireHazard',
  },
  {
    title: '密闭启封判定',
    dataIndex: 'unsealing',
  },
  {
    title: '爆炸危险性',
    dataIndex: 'explosionHazard',
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'mineCode',
    label: '煤矿名称',
    component: 'MineCascader',
    colProps: { span: 6 },
    // componentProps: {
    //   //请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
    //   api: () => getMineData({ pageNo: 1, pageSize: 999 }),
    //   //数值转成String
    //   numberToString: false,
    //   //标题字段
    //   labelField: 'mineName',
    //   //值字段
    //   valueField: 'id',
    //   //返回结果字段
    //   resultField: 'records',
    // },
  },
  {
    field: 'mineNameAbbr',
    label: '煤矿简称',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'productStatus',
    label: '生产状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '拟建矿井', value: '0' },
        { label: '正常生产矿井', value: '1' },
        { label: '长期停产矿井', value: '1' },
      ],
    },
    colProps: { span: 6 },
  },
  {
    field: 'riskLevel',
    label: '自燃情况',
    component: 'Select',
    componentProps: {
      options: [
        { label: 'Ⅰ类容易自燃', value: '0' },
        { label: 'Ⅱ类自燃', value: '1' },
        { label: 'Ⅲ类不易自燃', value: '2' },
      ],
    },
    colProps: { span: 6 },
  },
];

export const minesData = [
  {
    orderNo: 101, // 序号
    enforcement: '执法一处', // 区域
    mineName: '神木市三江', // 煤矿名称
    sealedName: '采空区密闭', // 密闭名称
    coalSeam: 'XX煤层', // 所属煤层
    riskLevel: 'Ⅰ类容易自燃', // 自燃倾向性（与搜索框选项label一致）
    COVal: 24, // CO浓度(ppm)
    CH4Val: 0, // CH4浓度(%)
    C2H2Val: 0, // C2H2浓度(ppm)
    O2Val: 20, // O2浓度(%)
    temperature: 35, // 温度(℃)
    pressureDiff: 50, // 压差(Pa)
    leakage: '气体涌出', // 是否漏风
    fireHazard: '低风险', // 自然发火隐患
    unsealing: '不可启封', // 密闭启封判定
    explosionHazard: '低风险', // 爆炸危险性
    updateTime: '2025-11-17 15:00:40', // 更新时间
  },
];

export const modalDetailsData: {} = {
  basicInfo: [
    {
      label: '煤矿名称',
      value: '神木市三江能源有限公司',
    },
    {
      label: '密闭名称',
      value: 'xxxx采空区密闭',
    },
    {
      label: '所属煤层',
      value: 'xxxx煤层',
    },
    {
      label: '自燃情况',
      value: 'Ⅰ类容易自燃',
    },
    {
      label: '是否漏风',
      value: '闭内气体涌出',
    },
    {
      label: '自然发火隐患',
      value: '低风险',
    },
    {
      label: '密闭启封判定',
      value: '不可启封',
    },
    {
      label: '爆炸危险性',
      value: '低风险',
    },
  ],
  board: [
    {
      label: 'CO(ppm)',
      value: '21',
    },
    {
      label: 'CO2(PPM)',
      value: '21',
    },
    {
      label: 'O2(%)',
      value: '24',
    },
    {
      label: 'CH4(%)',
      value: '17',
    },
    {
      label: 'C2H4(ppm)',
      value: '23',
    },
    {
      label: 'C2H2(ppm)',
      value: '14',
    },
    {
      label: '温度(℃)',
      value: '14',
    },
    {
      label: '压差(Pa)',
      value: '14',
    },
  ],
  demoBlastData: {
    // 爆炸三角形顶点坐标数据（JSON字符串格式）
    btTriBlast: JSON.stringify({
      A_x: 0,
      A_y: 21,
      B_x: 50,
      B_y: 0,
      E_x: 10,
      E_y: 15,
      F_x: 30,
      F_y: 5,
      G_x: 5,
      G_y: 18,
    }),
    o2val: '12.5',
    coval: '2000',
    gasval: '5.2',
    ch2val: '1500',
    chval: '800',
  },
  gasConcentrationConfig: {
    type: 'line_smooth', // 使用光滑曲线类型
    legend: { show: true },
    xAxis: [
      {
        type: 'category',
        dataKey: 'time',
        name: '时间',
        axisLabel: { color: '#000000' },
        nameTextStyle: { color: '#000' },
      },
    ],
    yAxis: [
      {
        type: 'value',
        show: true,
        name: '浓度(%)',
        splitLine: { show: false },
        axisLine: {
          show: true,
          lineStyle: { color: '#333' },
        },
        axisLabel: { color: '#000000' },
        nameTextStyle: { color: '#000' },
      },
    ],
    series: [
      {
        label: '气体浓度',
        readFrom: 'gasData',
        xprop: 'time',
        yprop: 'value',
        // color: '#000'
      },
    ],
  },
  gasConcentrationData: {
    gasData: [
      // 示例数据，实际应从接口获取
      { time: '00:00', value: 25.5 },
      { time: '04:00', value: 26.3 },
      { time: '08:00', value: 30.9 },
      { time: '12:00', value: 27.8 },
      { time: '16:00', value: 29.1 },
      { time: '20:00', value: 25.5 },
    ],
  },
  pressureConfig: {
    type: 'line', // 使用普通折线图类型
    legend: { show: true, color: '#000000' },
    xAxis: [{ type: 'category', dataKey: 'time', name: '时间', axisLabel: { color: '#000000' } }],
    yAxis: [{ show: true, name: '压力(kPa)', axisLabel: { color: '#000000' } }],
    series: [
      { label: '内部压力', readFrom: 'chartdata', xprop: 'time', yprop: 'inner' },
      { label: '外部压力', readFrom: 'chartdata', xprop: 'time', yprop: 'outer' },
      { label: '压力差', readFrom: 'chartdata', xprop: 'time', yprop: 'diff' },
    ],
  },
  pressureData: {
    chartdata: [
      // 示例数据，实际应从接口获取
      { time: '00:00', inner: 12, outer: 18, diff: 6 },
      { time: '04:00', inner: 15, outer: 17, diff: 2 },
      { time: '08:00', inner: 13, outer: 19, diff: 6 },
      { time: '12:00', inner: 11, outer: 10, diff: 1 },
      { time: '16:00', inner: 14, outer: 18, diff: 4 },
      { time: '20:00', inner: 16, outer: 16, diff: 0 },
    ],
  },
};

// 历史数据相关
export const historicalColumns: BasicColumn[] = [
  {
    title: '序号',
    dataIndex: 'orderNo',
  },
  {
    title: '区域',
    dataIndex: 'enforcement',
  },
  {
    title: '煤矿名称',
    dataIndex: 'mineName',
  },
  {
    title: '密闭名称',
    dataIndex: 'sealedName',
  },
  {
    title: '所属煤层',
    dataIndex: 'coalSeam',
  },
  {
    title: '自燃倾向性',
    dataIndex: 'riskLevel',
  },
  {
    title: 'CO(ppm)',
    dataIndex: 'COVal',
  },
  {
    title: 'CH4(%)',
    dataIndex: 'CH4Val',
  },
  {
    title: 'C2H2(ppm)',
    dataIndex: 'C2H2Val',
  },
  {
    title: 'O2(%)',
    dataIndex: 'O2Val',
  },
  {
    title: '温度(℃)',
    dataIndex: 'temperature',
  },
  {
    title: '压差(Pa)',
    dataIndex: 'pressureDiff',
  },
  {
    title: '是否漏风',
    dataIndex: 'leakage',
  },
  {
    title: '自然发火隐患',
    dataIndex: 'fireHazard',
  },
  {
    title: '密闭启封判定',
    dataIndex: 'unsealing',
  },
  {
    title: '爆炸危险性',
    dataIndex: 'explosionHazard',
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
  },
];

export const historicalFormSchema: FormSchema[] = [
  {
    field: 'mineCode',
    label: '煤矿名称',
    component: 'MineCascader',
    colProps: { span: 6 },
  },
  {
    field: 'mineNameAbbr',
    label: '煤矿简称',
    component: 'Input',
    colProps: { span: 6 },
  },
  // {
  //   field: 'productStatus',
  //   label: '生产状态',
  //   component: 'Select',
  //   componentProps: {
  //     options: [
  //       { label: '拟建矿井', value: '0' },
  //       { label: '正常生产矿井', value: '1' },
  //       { label: '长期停产矿井', value: '1' },
  //     ],
  //   },
  //   colProps: { span: 6 },
  // },
  // {
  //   field: 'riskLevel',
  //   label: '自燃情况',
  //   component: 'Select',
  //   componentProps: {
  //     options: [
  //       { label: 'Ⅰ类容易自燃', value: '0' },
  //       { label: 'Ⅱ类自燃', value: '1' },
  //       { label: 'Ⅲ类不易自燃', value: '2' },
  //     ],
  //   },
  //   colProps: { span: 6 },
  // },
  // {
  //   field: 'coalSeam',
  //   label: '所属煤层',
  //   component: 'Select',
  //   componentProps: {
  //     options: [
  //       { label: '煤层1', value: '0' },
  //       { label: '煤层2', value: '1' },
  //       { label: '煤层3', value: '2' },
  //     ],
  //   },
  //   colProps: { span: 6 },
  // },
  {
    field: 'goafId',
    label: '密闭名称',
    component: 'ApiSelect',
    componentProps: {
      api: getGoafList,
      //标题字段
      labelField: 'devicePos',
      //值字段
      valueField: 'id',
      //请求参数
      params: {},
      //返回结果字段
      resultField: 'records',
    },
    // required: true,
    colProps: { span: 6 },
  },
  {
    field: 'startTime',
    label: '起始日期',
    component: 'DatePicker',
    componentProps: {
      //日期格式化，页面上显示的值
      format: 'YYYY-MM-DD hh:mm:ss',
      //返回值格式化（绑定值的格式）
      valueFormat: 'YYYY-MM-DD hh:mm:ss',
    },
    defaultValue: dayjs().add(-1, 'day').format('YYYY-MM-DD hh:mm:ss'),
    colProps: { span: 6 },
  },
  {
    field: 'endTime',
    label: '结束日期',
    component: 'DatePicker',
    componentProps: {
      //日期格式化，页面上显示的值
      format: 'YYYY-MM-DD hh:mm:ss',
      //返回值格式化（绑定值的格式）
      valueFormat: 'YYYY-MM-DD hh:mm:ss',
    },
    defaultValue: dayjs().format('YYYY-MM-DD hh:mm:ss'),
    colProps: { span: 6 },
  },
];

export const historicalMinesData = [
  {
    orderNo: 101, // 序号
    enforcement: '执法一处', // 区域
    mineName: '神木市三江', // 煤矿名称
    sealedName: '采空区密闭', // 密闭名称
    coalSeam: 'XX煤层', // 所属煤层
    riskLevel: 'Ⅰ类容易自燃', // 自燃倾向性（与搜索框选项label一致）
    COVal: 24, // CO浓度(ppm)
    CH4Val: 0, // CH4浓度(%)
    C2H2Val: 0, // C2H2浓度(ppm)
    O2Val: 20, // O2浓度(%)
    temperature: 35, // 温度(℃)
    pressureDiff: 50, // 压差(Pa)
    leakage: '气体涌出', // 是否漏风
    fireHazard: '低风险', // 自然发火隐患
    unsealing: '不可启封', // 密闭启封判定
    explosionHazard: '低风险', // 爆炸危险性
    updateTime: '2025-12-22 15:00:40', // 更新时间
  },
];

export const treeData: TreeItem[] = [
  {
    title: '气体参数 ',
    key: '0-0',
    children: [
      { title: 'CO', key: '0-0-0' },
      { title: 'CH4', key: '0-0-1' },
      { title: 'C2H4', key: '0-0-2' },
      { title: 'C2H2', key: '0-0-3' },
      { title: 'CO2', key: '0-0-4' },
      { title: 'O2', key: '0-0-5' },
    ],
  },
  {
    title: '内外压力及压差',
    key: '1-1',
    children: [
      { title: '内压力', key: '1-1-0' },
      { title: '外压力', key: '1-1-1' },
      { title: '压差', key: '1-1-2' },
    ],
  },
  {
    title: '温度',
    key: '2-2',
  },
];

export const historicalMockChartData = [
  {
    time: '2025-12-22 00:00:00',
    CO: 22.3,
    CH4: 0.12,
    C2H4: 0.35,
    C2H2: 0.1,
    CO2: 0.85,
    O2: 19.5,
    innerPressure: 101.32,
    outerPressure: 101.1,
    pressureDiff: 0.22,
    temperature: 33.2,
  },
  {
    time: '2025-12-22 01:00:00',
    CO: 23.1,
    CH4: 0.15,
    C2H4: 0.42,
    C2H2: 0.12,
    CO2: 0.92,
    O2: 19.7,
    innerPressure: 101.38,
    outerPressure: 101.15,
    pressureDiff: 0.23,
    temperature: 33.5,
  },
  {
    time: '2025-12-22 02:00:00',
    CO: 22.8,
    CH4: 0.13,
    C2H4: 0.38,
    C2H2: 0.09,
    CO2: 0.88,
    O2: 19.6,
    innerPressure: 101.41,
    outerPressure: 101.18,
    pressureDiff: 0.23,
    temperature: 33.3,
  },
  {
    time: '2025-12-22 03:00:00',
    CO: 21.9,
    CH4: 0.11,
    C2H4: 0.31,
    C2H2: 0.08,
    CO2: 0.81,
    O2: 19.4,
    innerPressure: 101.35,
    outerPressure: 101.12,
    pressureDiff: 0.21,
    temperature: 33.1,
  },
  {
    time: '2025-12-22 04:00:00',
    CO: 22.5,
    CH4: 0.14,
    C2H4: 0.36,
    C2H2: 0.11,
    CO2: 0.86,
    O2: 19.5,
    innerPressure: 101.39,
    outerPressure: 101.16,
    pressureDiff: 0.22,
    temperature: 33.4,
  },
  {
    time: '2025-12-22 05:00:00',
    CO: 23.4,
    CH4: 0.16,
    C2H4: 0.45,
    C2H2: 0.13,
    CO2: 0.95,
    O2: 19.8,
    innerPressure: 101.43,
    outerPressure: 101.2,
    pressureDiff: 0.24,
    temperature: 33.7,
  },
  {
    time: '2025-12-22 06:00:00',
    CO: 24.2,
    CH4: 0.18,
    C2H4: 0.51,
    C2H2: 0.15,
    CO2: 1.02,
    O2: 20.0,
    innerPressure: 101.47,
    outerPressure: 101.23,
    pressureDiff: 0.25,
    temperature: 34.0,
  },
  {
    time: '2025-12-22 07:00:00',
    CO: 25.3,
    CH4: 0.21,
    C2H4: 0.58,
    C2H2: 0.17,
    CO2: 1.08,
    O2: 20.2,
    innerPressure: 101.52,
    outerPressure: 101.27,
    pressureDiff: 0.26,
    temperature: 34.3,
  },
  {
    time: '2025-12-22 08:00:00',
    CO: 26.1,
    CH4: 0.23,
    C2H4: 0.65,
    C2H2: 0.19,
    CO2: 1.15,
    O2: 20.4,
    innerPressure: 101.56,
    outerPressure: 101.3,
    pressureDiff: 0.27,
    temperature: 34.6,
  },
  {
    time: '2025-12-22 09:00:00',
    CO: 27.4,
    CH4: 0.25,
    C2H4: 0.72,
    C2H2: 0.22,
    CO2: 1.23,
    O2: 20.6,
    innerPressure: 101.6,
    outerPressure: 101.33,
    pressureDiff: 0.28,
    temperature: 35.0,
  },
  {
    time: '2025-12-22 10:00:00',
    CO: 28.2,
    CH4: 0.27,
    C2H4: 0.78,
    C2H2: 0.24,
    CO2: 1.29,
    O2: 20.8,
    innerPressure: 101.63,
    outerPressure: 101.35,
    pressureDiff: 0.29,
    temperature: 35.3,
  },
  {
    time: '2025-12-22 11:00:00',
    CO: 27.8,
    CH4: 0.26,
    C2H4: 0.75,
    C2H2: 0.23,
    CO2: 1.26,
    O2: 20.7,
    innerPressure: 101.61,
    outerPressure: 101.34,
    pressureDiff: 0.28,
    temperature: 35.2,
  },
  {
    time: '2025-12-22 12:00:00',
    CO: 26.9,
    CH4: 0.24,
    C2H4: 0.69,
    C2H2: 0.21,
    CO2: 1.19,
    O2: 20.5,
    innerPressure: 101.58,
    outerPressure: 101.32,
    pressureDiff: 0.27,
    temperature: 34.9,
  },
  {
    time: '2025-12-22 13:00:00',
    CO: 26.3,
    CH4: 0.22,
    C2H4: 0.64,
    C2H2: 0.19,
    CO2: 1.14,
    O2: 20.3,
    innerPressure: 101.55,
    outerPressure: 101.3,
    pressureDiff: 0.26,
    temperature: 34.7,
  },
  {
    time: '2025-12-22 14:00:00',
    CO: 25.7,
    CH4: 0.2,
    C2H4: 0.59,
    C2H2: 0.18,
    CO2: 1.09,
    O2: 20.1,
    innerPressure: 101.53,
    outerPressure: 101.28,
    pressureDiff: 0.25,
    temperature: 34.5,
  },
  {
    time: '2025-12-22 15:00:00',
    CO: 24.9,
    CH4: 0.18,
    C2H4: 0.53,
    C2H2: 0.16,
    CO2: 1.03,
    O2: 19.9,
    innerPressure: 101.49,
    outerPressure: 101.25,
    pressureDiff: 0.24,
    temperature: 34.2,
  },
  {
    time: '2025-12-22 16:00:00',
    CO: 24.3,
    CH4: 0.17,
    C2H4: 0.49,
    C2H2: 0.15,
    CO2: 0.98,
    O2: 19.8,
    innerPressure: 101.46,
    outerPressure: 101.22,
    pressureDiff: 0.23,
    temperature: 34.0,
  },
  {
    time: '2025-12-22 17:00:00',
    CO: 23.8,
    CH4: 0.16,
    C2H4: 0.46,
    C2H2: 0.14,
    CO2: 0.94,
    O2: 19.7,
    innerPressure: 101.44,
    outerPressure: 101.21,
    pressureDiff: 0.23,
    temperature: 33.8,
  },
  {
    time: '2025-12-22 18:00:00',
    CO: 23.5,
    CH4: 0.15,
    C2H4: 0.43,
    C2H2: 0.13,
    CO2: 0.91,
    O2: 19.6,
    innerPressure: 101.42,
    outerPressure: 101.19,
    pressureDiff: 0.22,
    temperature: 33.7,
  },
  {
    time: '2025-12-22 19:00:00',
    CO: 24.1,
    CH4: 0.17,
    C2H4: 0.48,
    C2H2: 0.15,
    CO2: 0.97,
    O2: 19.8,
    innerPressure: 101.45,
    outerPressure: 101.22,
    pressureDiff: 0.24,
    temperature: 33.9,
  },
  {
    time: '2025-12-22 20:00:00',
    CO: 24.7,
    CH4: 0.19,
    C2H4: 0.52,
    C2H2: 0.16,
    CO2: 1.01,
    O2: 20.0,
    innerPressure: 101.48,
    outerPressure: 101.24,
    pressureDiff: 0.25,
    temperature: 34.1,
  },
  {
    time: '2025-12-22 21:00:00',
    CO: 25.2,
    CH4: 0.2,
    C2H4: 0.56,
    C2H2: 0.18,
    CO2: 1.05,
    O2: 20.1,
    innerPressure: 101.51,
    outerPressure: 101.26,
    pressureDiff: 0.26,
    temperature: 34.3,
  },
  {
    time: '2025-12-22 22:00:00',
    CO: 24.5,
    CH4: 0.18,
    C2H4: 0.5,
    C2H2: 0.16,
    CO2: 0.99,
    O2: 19.9,
    innerPressure: 101.47,
    outerPressure: 101.23,
    pressureDiff: 0.24,
    temperature: 34.0,
  },
  {
    time: '2025-12-22 23:00:00',
    CO: 23.7,
    CH4: 0.16,
    C2H4: 0.45,
    C2H2: 0.14,
    CO2: 0.93,
    O2: 19.7,
    innerPressure: 101.43,
    outerPressure: 101.2,
    pressureDiff: 0.23,
    temperature: 33.8,
  },
  {
    time: '2025-11-18 00:00:00',
    CO: 22.9,
    CH4: 0.14,
    C2H4: 0.39,
    C2H2: 0.11,
    CO2: 0.89,
    O2: 19.6,
    innerPressure: 101.37,
    outerPressure: 101.17,
    pressureDiff: 0.22,
    temperature: 33.4,
  },
];
