Jing Li 2023-08-04 21:45:47 +08:00
parent b86efdc00b
commit 29e4660cf6
1 changed files with 27 additions and 4 deletions

View File

@ -176,10 +176,33 @@ class BiAngDeviceLogService
};
if ($attribute) {
if ($attribute == 'moment_rainfall') {
$attributes[$attribute] = bcadd($attributes[$attribute] ?? '0.00', $v, 2);
} else {
$attributes[$attribute] = $v;
switch ($attribute) {
case 'moment_rainfall':
$attributes[$attribute] = bcadd($attributes[$attribute] ?? '0.00', $v, 2);
break;
case 'wind_degree':
$attributes[$attribute] = value(function ($v) {
if ($v >= 22.5 && $v < 67.5) {
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_NORTHEAST;
} elseif ($v >= 67.5 && $v < 112.5) {
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_EAST;
} elseif ($v >= 112.5 && $v < 157.5) {
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_SOUTHEAST;
} elseif ($v >= 157.5 && $v < 202.5) {
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_SOUTH;
} elseif ($v >= 202.5 && $v < 247.5) {
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_SOUTHWEST;
} elseif ($v >= 247.5 && $v < 292.5) {
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_WEST;
} elseif ($v >= 292.5 && $v < 337.5) {
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_NORTHWEST;
}
return MeteorologicalMonitoringDailyLog::WIND_DIRECTION_NORTH;
}, $v);
default:
$attributes[$attribute] = $v;
break;
}
}
}