Update
parent
a2da7a73cd
commit
025cea099e
|
|
@ -4,18 +4,12 @@ namespace App\Console\Commands;
|
|||
|
||||
use App\Enums\DeviceType;
|
||||
use App\Models\Device;
|
||||
use App\Models\MeteorologicalDailyReport;
|
||||
use App\Models\MeteorologicalMonitoringDailyLog;
|
||||
use App\Models\MeteorologicalMonitoringLog;
|
||||
use App\Models\MeteorologicalReport;
|
||||
use App\Models\SoilDailyReport;
|
||||
use App\Models\SoilMonitoringDailyLog;
|
||||
use App\Models\SoilMonitoringLog;
|
||||
use App\Models\SoilReport;
|
||||
use App\Models\WaterQualityDailyReport;
|
||||
use App\Models\WaterQualityMonitoringDailyLog;
|
||||
use App\Models\WaterQualityMonitoringLog;
|
||||
use App\Models\WaterQualityReport;
|
||||
use App\Services\DeviceLogService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
|
|
|
|||
|
|
@ -412,8 +412,7 @@ class DeviceLogService
|
|||
|
||||
$attributes = value(function ($meteorologicalReports) {
|
||||
$data = [
|
||||
'today_rainfall' => ['sum' => 0, 'count' => 0],
|
||||
// 'yesterday_rainfall' => ['sum' => 0, 'count' => 0],
|
||||
'current_rainfall' => 0,
|
||||
'accumulated_rainfall' => ['sum' => 0, 'count' => 0],
|
||||
'moment_rainfall' => ['sum' => 0, 'count' => 0],
|
||||
'pm10' => ['sum' => 0, 'count' => 0],
|
||||
|
|
@ -424,6 +423,7 @@ class DeviceLogService
|
|||
'air_temperature' => ['sum' => 0, 'count' => 0],
|
||||
'air_humidity' => ['sum' => 0, 'count' => 0],
|
||||
'noise' => ['sum' => 0, 'count' => 0],
|
||||
'wind_speed' => ['sum' => 0, 'count' => 0],
|
||||
'wind_samples' => [],
|
||||
];
|
||||
|
||||
|
|
@ -439,9 +439,13 @@ class DeviceLogService
|
|||
'wind_speed' => $meteorologicalReport->wind_speed, // 风速
|
||||
];
|
||||
} elseif (! is_null($v = $meteorologicalReport->{$k})) {
|
||||
if ($k === 'current_rainfall') {
|
||||
$item = $v;
|
||||
} else {
|
||||
$item['sum'] = bcadd($item['sum'], $v, 2);
|
||||
$item['count']++;
|
||||
}
|
||||
}
|
||||
|
||||
$data[$k] = $item;
|
||||
}
|
||||
|
|
@ -451,7 +455,11 @@ class DeviceLogService
|
|||
|
||||
foreach ($data as $key => $item) {
|
||||
switch ($key) {
|
||||
case 'current_rainfall':
|
||||
$attributes['daily_rainfall'] = $item;
|
||||
break;
|
||||
case 'wind_samples':
|
||||
if (! empty($item)) {
|
||||
$attributes['wind_degree'] = value(function (array $windSamples) {
|
||||
if (empty($windSamples)) {
|
||||
return null;
|
||||
|
|
@ -508,6 +516,7 @@ class DeviceLogService
|
|||
|
||||
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_NORTH;
|
||||
}, $attributes['wind_degree']);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue