/*
 * @Author: donghao donghao@supervision.ltd
 * @Date: 2024-02-22 13:38:04
 * @LastEditors: donghao donghao@supervision.ltd
 * @LastEditTime: 2025-03-14 14:03:18
 * @FilePath: \General-AI-Platform-Web-Client\mock\pools\deviceStatusData.ts
 * @Description: 设备状态数据
 */
import { generateRandomDateTimeByYear } from "../utils/mockMoment";
import Mock from "mockjs";

// 定义一些公开的可测试的视频链接
const videoUrls = [
  "https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4",
  "https://www.sample-videos.com/video123/mp4/1080/big_buck_bunny_1080p_100mb.mp4",
  "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
  "https://www.sample-videos.com/video123/mp4/360/big_buck_bunny_360p_5mb.mp4",
  "https://media.w3.org/2010/05/video/movie_300.mp4",
  "https://www.w3schools.com/html/mov_bbb.mp4",
  "https://media.w3.org/2010/05/sintel/trailer.mp4",
  "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4",
  "https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.mp4",
  "https://archive.org/download/Sita_Sings_the_Blues/Sita_Sings_the_Blues_small.mp4",
];

function fetchList(): Record<string, any>[] {
  const currList: Record<string, any>[] = [];
  const nameArr = [
    "摄像模组表面缺陷检测设备",
    "镜片表面缺陷检测设备",
    "中板表面缺陷检测设备",
    "Logo表面缺陷检测设备",
    "手机电池表面缺陷检测设备",
    "部件表面缺陷检测设备",
    "边距缺陷检测设备",
    "成品组装缺陷检测设备",
    "金属工件表面缺陷检测设备",
    "管材表面缺陷检测设备",
  ];

  const codeArr = ["MSRF", "RL0F", "TLOC", "E1AIS", "CRM"];
  const deviceGroupArr = ["立杆", "东西货区", "送料区"];

  for (let i = 0; i < 35; i++) {
    currList.push({
      id: i,
      createTime: generateRandomDateTimeByYear(2023),
      updateTime: "2023-10-17T02:35:41.14308Z",
      name: nameArr[Math.floor(Math.random() * 3)],
      code: codeArr[Math.floor(Math.random() * 4)] + "-" + i,
      deviceGroup:
        deviceGroupArr[Math.floor(Math.random() * 3)] +
        (Math.floor(Math.random() * 3) + 1),
      status: Math.floor(Math.random() * 3) + 1,
      remark: "",
    });
  }
  return currList;
}

// 缺陷从EXL里选几个就好了
// 告警代码MSRF-0 RL0F HTFIF-02 TLOC-1 E1AIS-05
// 设备组:核心检测组001 无尘总装组005 送料监测线02

const mockHistroyData = Mock.mock({
  [`list|${videoUrls.length}`]: [
    {
      "id|+1": 10,
      key: function () {
        return this.id.toString();
      },
      video_url: function () {
        // 依次取出视频链接
        return videoUrls[this.id - 10];
      },
      created_at: function () {
        // 定义起始和结束时间戳
        const startDate = new Date("2025-01-01").getTime();
        const endDate = new Date("2025-03-14 23:59:59").getTime();
        // 生成随机时间戳
        const randomTimestamp =
          startDate + Math.random() * (endDate - startDate);
        // 根据随机时间戳创建日期对象
        const randomDate = new Date(randomTimestamp);
        // 格式化日期为 yyyy-MM-dd HH:mm:ss 格式
        const year = randomDate.getFullYear();
        const month = String(randomDate.getMonth() + 1).padStart(2, "0");
        const day = String(randomDate.getDate()).padStart(2, "0");
        const hours = String(randomDate.getHours()).padStart(2, "0");
        const minutes = String(randomDate.getMinutes()).padStart(2, "0");
        const seconds = String(randomDate.getSeconds()).padStart(2, "0");
        return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
      },
      device: 1,
    },
  ],
});

const currentData = fetchList();
const currentHistroyData = mockHistroyData.list;

//
export const deviceStatusListData = {
  data: {
    data: currentData,
    total: currentData.length,
    current: 1,
    pageSize: 10,
  },
};

export const deviceHistoryListData = {
  data: currentHistroyData,
};