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