diff --git a/app/Enums/WindDirection.php b/app/Enums/WindDirection.php new file mode 100644 index 0000000..e8417b0 --- /dev/null +++ b/app/Enums/WindDirection.php @@ -0,0 +1,15 @@ + WindDirection::class, + 'monitored_at' => 'datetime', + ]; + + protected $fillable = [ + 'device_id', + 'agricultural_base_id', + 'wind_speed', + 'wind_power', + 'wind_direction', + 'wind_degree', + 'air_humidity', + 'air_temperature', + 'air_pressure', + 'co2', + 'noise', + 'illumination', + 'accumulated_rainfall', + 'current_rainfall', + 'moment_rainfall', + 'day_rainfall', + 'pm25', + 'pm10', + 'monitored_at', + ]; +} diff --git a/database/migrations/2022_10_18_172650_create_meteorological_monitoring_logs_table.php b/database/migrations/2022_10_18_172650_create_meteorological_monitoring_logs_table.php new file mode 100644 index 0000000..e57dfa3 --- /dev/null +++ b/database/migrations/2022_10_18_172650_create_meteorological_monitoring_logs_table.php @@ -0,0 +1,55 @@ +id(); + $table->unsignedBigInteger('device_id')->comment('设备ID'); + $table->unsignedBigInteger('agricultural_base_id')->comment('农业基地ID'); + $table->decimal('wind_speed', 8, 2)->nullable()->comment('风速 (单位: m/s)'); + $table->integer('wind_power')->nullable()->comment('风力'); + $table->tinyInteger('wind_direction')->nullable()->comment('风向: 0 北风, 1 东北风, 2 东风, 3 东南风, 4 南风, 5 西南风, 6 西风, 7 西北风'); + $table->integer('wind_degree')->nullable()->comment('风向度数'); + $table->decimal('air_humidity', 8, 2)->nullable()->comment('空气湿度 (单位: db)'); + $table->decimal('air_temperature', 8, 2)->nullable()->comment('气温 (单位: db)'); + $table->decimal('air_pressure', 8, 2)->nullable()->comment('气压 (单位: Kpa)'); + $table->decimal('co2', 8, 2)->nullable()->comment('二氧化碳浓度 (单位: ppm)'); + $table->decimal('noise', 8, 2)->nullable()->comment('噪声 (单位: db)'); + $table->integer('illumination')->nullable()->comment('光照度 (单位: Lux)'); + $table->decimal('accumulated_rainfall', 8, 2)->nullable()->comment('积雨量 (单位: mm)'); + $table->decimal('current_rainfall', 8, 2)->nullable()->comment('当前雨量 (单位: mm)'); + $table->decimal('moment_rainfall', 8, 2)->nullable()->comment('瞬时雨量 (单位: mm)'); + $table->decimal('day_rainfall', 8, 2)->nullable()->comment('日雨量 (单位: mm)'); + $table->integer('pm25')->nullable()->comment('PM2.5浓度 (单位: ug/m3)'); + $table->integer('pm10')->nullable()->comment('PM10浓度 (单位: ug/m3)'); + $table->timestamp('monitored_at')->comment('监控时间(小时)'); + $table->timestamps(); + + // 索引 + $table->index('device_id'); + $table->index('agricultural_base_id'); + $table->unique('monitored_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('meteorological_monitoring_logs'); + } +};