diff --git a/app/Http/Controllers/DeviceController.php b/app/Http/Controllers/DeviceController.php index c28ae22..4fbabfe 100644 --- a/app/Http/Controllers/DeviceController.php +++ b/app/Http/Controllers/DeviceController.php @@ -518,6 +518,21 @@ class DeviceController extends Controller 'p', 'k', ]; + + switch ($device->supplier_key) { + case 'device-supplier-biang': + $fields = [ + 'conductivity', + 'humidity', + 'temperature', + 'n', + 'p', + 'k', + 'ph', + ]; + break; + } + /** @var \Illuminate\Support\Collection */ $monitoringLogs = ( $isSameDay diff --git a/app/Models/SoilMonitoringDailyLog.php b/app/Models/SoilMonitoringDailyLog.php index d5f3409..9a73b80 100644 --- a/app/Models/SoilMonitoringDailyLog.php +++ b/app/Models/SoilMonitoringDailyLog.php @@ -22,6 +22,7 @@ class SoilMonitoringDailyLog extends Model 'n', 'p', 'k', + 'ph', 'moisture', 'monitored_at', ]; diff --git a/app/Models/SoilMonitoringLog.php b/app/Models/SoilMonitoringLog.php index 1845557..c9e37ee 100644 --- a/app/Models/SoilMonitoringLog.php +++ b/app/Models/SoilMonitoringLog.php @@ -27,6 +27,7 @@ class SoilMonitoringLog extends Model 'n', 'p', 'k', + 'ph', 'monitored_at', 'moisture', 'is_filled', diff --git a/app/Services/BiAngDeviceService.php b/app/Services/BiAngDeviceService.php index 4a6e2b4..e57604e 100644 --- a/app/Services/BiAngDeviceService.php +++ b/app/Services/BiAngDeviceService.php @@ -99,6 +99,7 @@ class BiAngDeviceService 'soilConductivity' => 'conductivity', 'soilTemperature' => 'temperature', 'soilMoisture' => 'humidity', + 'soilPH' => 'ph', default => null, }; @@ -418,6 +419,7 @@ class BiAngDeviceService 'temperature' => ['sum' => 0, 'count' => 0], 'humidity' => ['sum' => 0, 'count' => 0], 'moisture' => ['sum' => 0, 'count' => 0], + 'ph' => ['sum' => 0, 'count' => 0], ]; foreach ($soilReports as $soilReport) { diff --git a/database/migrations/2024_06_02_130959_add_ph_to_soil_monitoring_logs_table.php b/database/migrations/2024_06_02_130959_add_ph_to_soil_monitoring_logs_table.php new file mode 100644 index 0000000..f42c710 --- /dev/null +++ b/database/migrations/2024_06_02_130959_add_ph_to_soil_monitoring_logs_table.php @@ -0,0 +1,32 @@ +decimal('ph', 4, 2)->nullable()->comment('酸碱度'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('soil_monitoring_logs', function (Blueprint $table) { + $table->dropColumn(['ph']); + }); + } +}; diff --git a/database/migrations/2024_06_02_131158_add_ph_to_soil_monitoring_daily_logs_table.php b/database/migrations/2024_06_02_131158_add_ph_to_soil_monitoring_daily_logs_table.php new file mode 100644 index 0000000..7859aec --- /dev/null +++ b/database/migrations/2024_06_02_131158_add_ph_to_soil_monitoring_daily_logs_table.php @@ -0,0 +1,32 @@ +decimal('ph', 4, 2)->nullable()->comment('酸碱度'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('soil_monitoring_daily_logs', function (Blueprint $table) { + $table->dropColumn(['ph']); + }); + } +};