/**
 * 投食船前端 Mock 初始数据
 * 登录账号: admin / 123456
 */

export const MOCK_SHIP_ID = 123456789;

// 青岛附近海域示例坐标
const ROUTE_A = [
  120.072896, 36.155971, 120.07412, 36.15688, 120.07545, 36.15772,
  120.0768, 36.15855, 120.0781, 36.1594,
];
const ROUTE_B = [
  120.0705, 36.1542, 120.0718, 36.1551, 120.0732, 36.156, 120.0746, 36.1569,
];

function cloneRoute(points) {
  return [...points];
}

export function createInitialStore() {
  const tenants = [
    { id: 1, name: "青岛海洋渔业有限公司", tenantType: 1 },
    { id: 2, name: "个人养殖户-张三", tenantType: 2 },
    { id: 3, name: "威海智能水产合作社", tenantType: 1 },
  ];

  const roles = [
    {
      id: 1,
      roleName: "超级管理员",
      comment: "系统全部权限",
      tenantId: 1,
      tenantName: "青岛海洋渔业有限公司",
      createTime: "2025-01-10 09:00:00",
      createBy: "admin",
      updateBy: "admin",
      updateTime: "2025-03-15 14:20:00",
    },
    {
      id: 2,
      roleName: "运维人员",
      comment: "设备与路线管理",
      tenantId: 1,
      tenantName: "青岛海洋渔业有限公司",
      createTime: "2025-02-01 10:30:00",
      createBy: "admin",
      updateBy: "admin",
      updateTime: "2025-04-01 11:00:00",
    },
    {
      id: 3,
      roleName: "普通用户",
      comment: "仅查看与操作投食船",
      tenantId: 2,
      tenantName: "个人养殖户-张三",
      createTime: "2025-02-15 16:00:00",
      createBy: "admin",
      updateBy: "admin",
      updateTime: "2025-04-10 09:30:00",
    },
  ];

  const users = [
    {
      id: 1,
      username: "admin",
      phone: "13800138000",
      tenantId: 1,
      tenantName: "青岛海洋渔业有限公司",
      status: 1,
      usertype: 2,
      createTime: "2025-01-05 08:00:00",
      roleVos: [{ id: 1, roleName: "超级管理员" }],
    },
    {
      id: 2,
      username: "operator",
      phone: "13900139001",
      tenantId: 1,
      tenantName: "青岛海洋渔业有限公司",
      status: 1,
      usertype: 2,
      createTime: "2025-02-20 10:15:00",
      roleVos: [{ id: 2, roleName: "运维人员" }],
    },
    {
      id: 3,
      username: "zhangsan",
      phone: "13700137002",
      tenantId: 2,
      tenantName: "个人养殖户-张三",
      status: 1,
      usertype: 1,
      createTime: "2025-03-01 14:30:00",
      roleVos: [{ id: 3, roleName: "普通用户" }],
    },
    {
      id: 4,
      username: "lisi",
      phone: "13600136003",
      tenantId: 3,
      tenantName: "威海智能水产合作社",
      status: 0,
      usertype: 2,
      createTime: "2025-04-12 09:45:00",
      roleVos: [],
    },
  ];

  const permissions = [
    {
      id: 1,
      name: "用户管理",
      path: "/index/userManagement",
      comment: "系统管理",
    },
    {
      id: 2,
      name: "角色管理",
      path: "/index/roleManagement",
      comment: "系统管理",
    },
    {
      id: 3,
      name: "权限管理",
      path: "/index/powerManagement",
      comment: "系统管理",
    },
    {
      id: 4,
      name: "租户管理",
      path: "/index/tenantManagement",
      comment: "系统管理",
    },
    {
      id: 5,
      name: "设备管理",
      path: "/index/homepage",
      comment: "投食船",
    },
    {
      id: 6,
      name: "历史路线",
      path: "/index/deviceHistory",
      comment: "投食船",
    },
  ];

  const routeHistories = [
    {
      id: 1,
      routeName: "东区养殖区-多点导航",
      routeType: 1,
      shipId: MOCK_SHIP_ID,
      createTime: "2025-05-20 08:30:00",
      route: cloneRoute(ROUTE_A),
    },
    {
      id: 2,
      routeName: "西区巡检路线",
      routeType: 0,
      shipId: MOCK_SHIP_ID,
      createTime: "2025-05-18 14:20:00",
      route: cloneRoute(ROUTE_B),
    },
    {
      id: 3,
      routeName: "南区定点投喂",
      routeType: 1,
      shipId: MOCK_SHIP_ID,
      createTime: "2025-05-15 10:00:00",
      route: cloneRoute([
        120.068, 36.152, 120.069, 36.153, 120.07, 36.154,
      ]),
    },
  ];

  const errorMessages = [
    {
      id: 1,
      detail: "GPS信号弱，定位精度下降",
      createTime: "2025-05-25 09:12:33",
    },
    {
      id: 2,
      detail: "投食仓余量低于20%",
      createTime: "2025-05-24 16:45:10",
    },
    {
      id: 3,
      detail: "遥控器通信超时，已切换自主模式",
      createTime: "2025-05-23 11:20:05",
    },
    {
      id: 4,
      detail: "电池温度偏高，建议返港充电",
      createTime: "2025-05-22 08:05:44",
    },
  ];

  const faultWarranties = [
    {
      id: 1,
      faultType: 0,
      shipId: MOCK_SHIP_ID,
      createBy: 2,
      contactWay: "13900139001",
      createTime: "2025-05-20 10:30:00",
      status: 0,
      description: "船体左侧支架松动",
    },
    {
      id: 2,
      faultType: 1,
      shipId: MOCK_SHIP_ID,
      createBy: 3,
      contactWay: "13700137002",
      createTime: "2025-05-18 15:20:00",
      status: 1,
      description: "推进电机异响",
    },
    {
      id: 3,
      faultType: 2,
      shipId: MOCK_SHIP_ID,
      createBy: 2,
      contactWay: "13800138000",
      createTime: "2025-05-16 09:00:00",
      status: 0,
      description: "船舱进水传感器报警",
    },
  ];

  let nextId = {
    user: 10,
    role: 10,
    tenant: 10,
    permission: 10,
    route: 10,
    error: 10,
    fault: 10,
  };

  let shipNavIndex = 0;
  const shipNavPath = [
    { longitude: 120.072896, latitude: 36.155971 },
    { longitude: 120.07412, latitude: 36.15688 },
    { longitude: 120.07545, latitude: 36.15772 },
    { longitude: 120.0768, latitude: 36.15855 },
    { longitude: 120.0781, latitude: 36.1594 },
    { longitude: null, latitude: null },
  ];

  return {
    tenants,
    roles,
    users,
    permissions,
    routeHistories,
    errorMessages,
    faultWarranties,
    nextId,
    shipStatus: {
      deviceId: MOCK_SHIP_ID,
      feedWeight: 54,
      speed: 2.8,
      power: 78,
      longitude: 120.072896,
      latitude: 36.155971,
      gpsWarning: 0,
      joyWarning: 0,
      Status: 1,
    },
    shipNavIndex,
    shipNavPath,
    feedbackList: [],
  };
}

export const MOCK_LOGIN = {
  username: "admin",
  password: "123456",
  token: "mock-jwt-token-feedingship-dev",
  userId: 1,
  tenantId: 1,
};
