From dd2b56a0d2af5c7eaeb927b69cde1744d9913cc1 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Wed, 19 Oct 2022 10:16:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=94=E8=B1=A1=E7=9B=91=E6=B5=8B=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=A8=A1=E5=9E=8B=E5=92=8C=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Enums/WindDirection.php | 15 +++++ app/Models/MeteorologicalMonitoringLog.php | 39 +++++++++++++ ...e_meteorological_monitoring_logs_table.php | 55 +++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 app/Enums/WindDirection.php create mode 100644 app/Models/MeteorologicalMonitoringLog.php create mode 100644 database/migrations/2022_10_18_172650_create_meteorological_monitoring_logs_table.php 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'); + } +};