import { BasicPageParams } from '/@/api/model/baseModel';

export type TDeviceConfigPageQueryParam = BasicPageParams & TDeviceConfigParams;

export type TDeviceConfigParams = {
  page?: any;
  pageSize?: any;
  name?: string;
  transportType?: string;
  orderFiled?: string;
  orderType?: string;
  tbDeviceId?: string;
};

export interface IDeviceConfigAddOrEditModel {
  defaultQueueName?: string; //处理队列
  alarmProfile?: {
    alarmContactId: string;
    createTime: '2021-12-15T02:17:26.644Z';
    creator: string;
    defaultConfig: string;
    description: string;
    deviceProfileId: string;
    enabled: true;
    icon: string;
    id: string;
    messageMode: string;
    name: string;
    roleIds: [string];
    tenantExpireTime: '2021-12-15T02:17:26.644Z';
    tenantId: string;
    tenantStatus: 'DISABLED';
    updateTime: '2021-12-15T02:17:26.644Z';
    updater: string;
  };
  convertJs?: string;
  createTime?: '2021-12-15T02:17:26.644Z';
  creator?: string;
  defaultConfig?: string;
  defaultRuleChainId?: string;
  description?: string;
  enabled?: true;
  icon?: string;
  id?: string;
  name?: string;
  profileData?: {
    configuration: {};
    transportConfiguration: {};
    provisionConfiguration: {
      provisionDeviceSecret: string;
    };
    //报警类型字段
    alarms: [
      {
        id: 'highTemperatureAlarmID';
        alarmType: 'High Temperature Alarm';
        createRules: {
          additionalProp1: {
            condition: {
              condition: [
                {
                  key: {
                    type: 'TIME_SERIES';
                    key: 'temp';
                  };
                  valueType: 'NUMERIC';
                  value: {};
                  predicate: {};
                }
              ];
              spec: {};
            };
            schedule: {
              type: 'ANY_TIME';
            };
            alarmDetails: string;
            dashboardId: {
              id: '784f394c-42b6-435a-983c-b7beff2784f9';
              entityType: 'DASHBOARD';
            };
          };
          additionalProp2: {
            condition: {
              condition: [
                {
                  key: {
                    type: 'TIME_SERIES';
                    key: 'temp';
                  };
                  valueType: 'NUMERIC';
                  value: {};
                  predicate: {};
                }
              ];
              spec: {};
            };
            schedule: {
              type: 'ANY_TIME';
            };
            alarmDetails: string;
            dashboardId: {
              id: '784f394c-42b6-435a-983c-b7beff2784f9';
              entityType: 'DASHBOARD';
            };
          };
          additionalProp3: {
            condition: {
              condition: [
                {
                  key: {
                    type: 'TIME_SERIES';
                    key: 'temp';
                  };
                  valueType: 'NUMERIC';
                  value: {};
                  predicate: {};
                }
              ];
              spec: {};
            };
            schedule: {
              type: 'ANY_TIME';
            };
            alarmDetails: string;
            dashboardId: {
              id: '784f394c-42b6-435a-983c-b7beff2784f9';
              entityType: 'DASHBOARD';
            };
          };
        };
        clearRule: {
          condition: {
            condition: [
              {
                key: {
                  type: 'TIME_SERIES';
                  key: 'temp';
                };
                valueType: 'NUMERIC';
                value: {};
                predicate: {};
              }
            ];
            spec: {};
          };
          schedule: {
            type: 'ANY_TIME';
          };
          alarmDetails: string;
          dashboardId: {
            id: '784f394c-42b6-435a-983c-b7beff2784f9';
            entityType: 'DASHBOARD';
          };
        };
        propagate: true;
        propagateRelationTypes: [string];
      }
    ];
  };
  roleIds?: [string];
  tbProfileId?: string;
  tenantExpireTime?: '2021-12-15T02:17:26.645Z';
  tenantId?: string;
  tenantStatus?: 'DISABLED';
  transportType?: string;
  updateTime?: '2021-12-15T02:17:26.645Z';
  updater?: string;
}

export interface Data {
  CO: number;
}

export interface Details {
  data: Data;
}

export interface AlarmLogItem {
  id: string;
  tenantId: string;
  creator?: any;
  updater?: any;
  createdTime: string;
  updatedTime: string;
  customerId: string;
  tbDeviceId: string;
  originatorType: number;
  deviceId: string;
  deviceName: string;
  type: string;
  severity: string;
  status: string;
  startTs: string;
  endTs: string;
  ackTs: string;
  clearTs: string;
  details: Details;
  propagate: boolean;
  propagateRelationTypes?: any;
  organizationId: string;
  organizationName: string;
}

export interface Configuration {
  type: string;
}

export interface TransportConfiguration {
  type: string;
}

export interface ProvisionConfiguration {
  type: string;
  provisionDeviceSecret?: any;
}

export interface ProfileData {
  configuration: Configuration;
  transportConfiguration: TransportConfiguration;
  provisionConfiguration: ProvisionConfiguration;
  alarms?: any;
}

export interface ProfileRecord {
  id: string;
  creator: string;
  createTime: string;
  updater: string;
  updateTime: string;
  name: string;
  tenantId: string;
  transportType: string;
  provisionType: string;
  deviceType: string;
  tbProfileId: string;
  profileData: ProfileData;
  defaultRuleChainId: string;
  defaultQueueName: string;
  image: string;
  type: string;
  default: boolean;

  checked?: boolean;
}

export interface IDRecord {
  entityType: string;
  id: string;
}

export interface RuleChainRecord {
  id: IDRecord;
  createdTime: number;
  additionalInfo?: any;
  tenantId: IDRecord;
  name: string;
  type: string;
  firstRuleNodeId: IDRecord;
  root: boolean;
  debugMode: boolean;
  configuration?: any;
}
