/**
 * 电子围栏坐标点种子数据
 * 添加示例坐标点数据
 */

module.exports = {
  up: async (queryInterface, Sequelize) => {
    // 插入示例坐标点数据
    await queryInterface.bulkInsert('electronic_fence_points', [
      // 银川南湖围栏的坐标点
      {
        fence_id: 2,
        point_order: 0,
        longitude: 106.275,
        latitude: 38.485,
        point_type: 'corner',
        description: '南湖围栏西南角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 2,
        point_order: 1,
        longitude: 106.285,
        latitude: 38.485,
        point_type: 'corner',
        description: '南湖围栏东南角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 2,
        point_order: 2,
        longitude: 106.285,
        latitude: 38.495,
        point_type: 'corner',
        description: '南湖围栏东北角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 2,
        point_order: 3,
        longitude: 106.275,
        latitude: 38.495,
        point_type: 'corner',
        description: '南湖围栏西北角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 2,
        point_order: 4,
        longitude: 106.280,
        latitude: 38.490,
        point_type: 'control',
        description: '南湖围栏中心控制点',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },

      // 银川东区围栏的坐标点
      {
        fence_id: 3,
        point_order: 0,
        longitude: 106.260,
        latitude: 38.480,
        point_type: 'corner',
        description: '东区围栏西南角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 3,
        point_order: 1,
        longitude: 106.270,
        latitude: 38.480,
        point_type: 'corner',
        description: '东区围栏东南角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 3,
        point_order: 2,
        longitude: 106.270,
        latitude: 38.490,
        point_type: 'corner',
        description: '东区围栏东北角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 3,
        point_order: 3,
        longitude: 106.260,
        latitude: 38.490,
        point_type: 'corner',
        description: '东区围栏西北角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },

      // 安全围栏A区的坐标点
      {
        fence_id: 4,
        point_order: 0,
        longitude: 106.250,
        latitude: 38.470,
        point_type: 'corner',
        description: '安全围栏A区西南角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 4,
        point_order: 1,
        longitude: 106.265,
        latitude: 38.470,
        point_type: 'corner',
        description: '安全围栏A区东南角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 4,
        point_order: 2,
        longitude: 106.265,
        latitude: 38.485,
        point_type: 'corner',
        description: '安全围栏A区东北角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 4,
        point_order: 3,
        longitude: 106.250,
        latitude: 38.485,
        point_type: 'corner',
        description: '安全围栏A区西北角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },

      // 大型放牧区的坐标点
      {
        fence_id: 5,
        point_order: 0,
        longitude: 106.240,
        latitude: 38.460,
        point_type: 'corner',
        description: '大型放牧区西南角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 5,
        point_order: 1,
        longitude: 106.280,
        latitude: 38.460,
        point_type: 'corner',
        description: '大型放牧区东南角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 5,
        point_order: 2,
        longitude: 106.280,
        latitude: 38.500,
        point_type: 'corner',
        description: '大型放牧区东北角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 5,
        point_order: 3,
        longitude: 106.240,
        latitude: 38.500,
        point_type: 'corner',
        description: '大型放牧区西北角',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        fence_id: 5,
        point_order: 4,
        longitude: 106.260,
        latitude: 38.480,
        point_type: 'control',
        description: '大型放牧区中心控制点',
        is_active: true,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      }
    ]);

    console.log('✅ 电子围栏坐标点种子数据插入成功');
  },

  down: async (queryInterface, Sequelize) => {
    // 删除所有坐标点数据
    await queryInterface.bulkDelete('electronic_fence_points', null, {});
    console.log('✅ 电子围栏坐标点种子数据删除成功');
  }
};
