diff --git a/app/Models/Device.php b/app/Models/Device.php index f4e8fc6..174e3a4 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -69,4 +69,9 @@ class Device extends Model { return $this->type === static::TYPE_SOIL; } + + public function isTypeMeteorological(): bool + { + return $this->type === static::TYPE_METEOROLOGICAL; + } } diff --git a/app/Services/DeviceLogService.php b/app/Services/DeviceLogService.php index b7ca938..7e89f20 100644 --- a/app/Services/DeviceLogService.php +++ b/app/Services/DeviceLogService.php @@ -54,6 +54,65 @@ class DeviceLogService continue; } + if ($device->isTypeSoil()) { + // 如果包含气象设备监测字段,则跳过 + if (Arr::hasAny($item['data'], [ + 'day_rainfall', + 'accumulate_rainfall', + 'potassium_content', + 'moment_rainfall', + 'pm10_concentration', + 'pm25_concentration', + 'box_noise', + 'box_carbon', + 'box_humidity', + 'box_pressure', + 'box_temperature', + 'box_illumination', + 'wind_power', + 'wind_speed', + 'wind_degree', + 'wind_direction', + ])) { + continue; + } + } elseif ($device->isTypeMeteorological()) { + // 如果包含土壤设备监测字段,则跳过 + if (Arr::hasAny($item['data'], [ + 'nitrogen_content', + 'phosphorus_content', + 'potassium_content', + 'conductivity', + 'soil_humidity', + 'soil_temperature', + ])) { + continue; + } + } + + if ( + $device->isTypeSoil() && Arr::hasAny($item['data'], [ + + ]) + ) { + + } elseif ( + $device->isTypeMeteorological() && + Arr::hasAny( + $item['data'], + [ + 'nitrogen_content', + 'phosphorus_content', + 'potassium_content', + 'conductivity', + 'soil_humidity', + 'soil_temperature', + ] + ) + ) { + continue; + } + $isSoilMonitoring = Arr::hasAny($item['data'], [ 'soil_humidity', 'soil_temperature',