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

module.exports = {
  up: async (queryInterface, Sequelize) => {
    // 插入示例围栏数据
    await queryInterface.bulkInsert('electronic_fences', [
      {
        name: '银川南湖围栏',
        type: 'collector',
        description: '银川南湖区域采集器围栏，用于监控南湖区域的动物活动',
        coordinates: JSON.stringify([
          { lng: 106.275, lat: 38.485 },
          { lng: 106.285, lat: 38.485 },
          { lng: 106.285, lat: 38.495 },
          { lng: 106.275, lat: 38.495 }
        ]),
        center_lng: 106.280,
        center_lat: 38.490,
        area: 10000.0,
        grazing_status: 'grazing',
        inside_count: 0,
        outside_count: 0,
        is_active: true,
        farm_id: 1,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        name: '银川东区围栏',
        type: 'grazing',
        description: '银川东区放牧围栏，用于测试功能',
        coordinates: JSON.stringify([
          { lng: 106.260, lat: 38.480 },
          { lng: 106.270, lat: 38.480 },
          { lng: 106.270, lat: 38.490 },
          { lng: 106.260, lat: 38.490 }
        ]),
        center_lng: 106.265,
        center_lat: 38.485,
        area: 5000.0,
        grazing_status: 'not_grazing',
        inside_count: 5,
        outside_count: 2,
        is_active: true,
        farm_id: 1,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        name: '安全围栏A区',
        type: 'safety',
        description: '安全围栏A区，用于保护重要区域',
        coordinates: JSON.stringify([
          { lng: 106.30, lat: 38.50 },
          { lng: 106.31, lat: 38.50 },
          { lng: 106.31, lat: 38.51 },
          { lng: 106.30, lat: 38.51 }
        ]),
        center_lng: 106.305,
        center_lat: 38.505,
        area: 8000.0,
        grazing_status: 'not_grazing',
        inside_count: 3,
        outside_count: 1,
        is_active: true,
        farm_id: 1,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        name: '大型放牧区',
        type: 'grazing',
        description: '大型放牧区域，适合大规模放牧活动',
        coordinates: JSON.stringify([
          { lng: 106.20, lat: 38.40 },
          { lng: 106.25, lat: 38.40 },
          { lng: 106.25, lat: 38.45 },
          { lng: 106.20, lat: 38.45 }
        ]),
        center_lng: 106.225,
        center_lat: 38.425,
        area: 25000.0,
        grazing_status: 'grazing',
        inside_count: 15,
        outside_count: 3,
        is_active: true,
        farm_id: 1,
        created_by: 1,
        updated_by: 1,
        created_at: new Date(),
        updated_at: new Date()
      }
    ], {});
  },

  down: async (queryInterface, Sequelize) => {
    // 删除所有围栏数据
    await queryInterface.bulkDelete('electronic_fences', null, {});
  }
};
