Update
parent
fd9cbd8c7d
commit
dde34bfbce
|
|
@ -10,7 +10,6 @@ use App\Models\DeviceLog;
|
|||
use App\Models\WormPhoto;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
|
@ -65,6 +64,7 @@ class DeviceLogSyncCommand extends Command
|
|||
/** @var \App\Models\Device */
|
||||
foreach ($devices as $device) {
|
||||
if (! in_array($device->type, [
|
||||
DeviceType::Monitor,
|
||||
DeviceType::Soil,
|
||||
DeviceType::Meteorological,
|
||||
DeviceType::Worm,
|
||||
|
|
@ -78,6 +78,7 @@ class DeviceLogSyncCommand extends Command
|
|||
$this->info('设备编号: ' . $device->sn);
|
||||
$this->info('设备名称: ' . $device->name);
|
||||
$this->info('设备类型: ' . match ($device->type) {
|
||||
DeviceType::Monitor => '苗情设备',
|
||||
DeviceType::Soil => '土壤设备',
|
||||
DeviceType::Meteorological => '气象设备',
|
||||
DeviceType::Worm => '虫情设备',
|
||||
|
|
@ -89,6 +90,14 @@ class DeviceLogSyncCommand extends Command
|
|||
$httpClient = $this->buildHttpClient($device);
|
||||
|
||||
switch ($device->type) {
|
||||
case DeviceType::Monitor:
|
||||
$data = $httpClient->getMonitorPalyAddress($device->sn);
|
||||
|
||||
$device->update([
|
||||
'status' => $data ? DeviceStatus::Online : DeviceStatus::Offline,
|
||||
]);
|
||||
|
||||
break;
|
||||
case DeviceType::Soil:
|
||||
$data = $httpClient->getLatestSoilReport($device->sn);
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,21 @@ class HttpClient
|
|||
return $result['data'] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 苗情设备 - 直播地址
|
||||
*/
|
||||
public function getMonitorPalyAddress(string $deviceId)
|
||||
{
|
||||
$result = $this->get(
|
||||
$this->apiUrl('/api/open-api/open/getSeedingLive'),
|
||||
[
|
||||
'equipmentCode' => $deviceId,
|
||||
]
|
||||
);
|
||||
|
||||
return $result['data'] ?? "";
|
||||
}
|
||||
|
||||
public function get(string $url, array $query = []): array
|
||||
{
|
||||
return $this->request('GET', $url, [
|
||||
|
|
|
|||
Loading…
Reference in New Issue