新增设备暂停/继续命令
This commit is contained in:
@@ -11,44 +11,57 @@ class ECommand {
|
|||||||
$command2API = [
|
$command2API = [
|
||||||
'server_restart' => '/Admin/ServerCloseAndRestart',
|
'server_restart' => '/Admin/ServerCloseAndRestart',
|
||||||
'server_close' => '/Admin/ServerClose',
|
'server_close' => '/Admin/ServerClose',
|
||||||
|
'device_stop' => '/Edge/DeviceStopRequest',
|
||||||
|
'device_continue' => 'Edge/DeviceContinueRequest'
|
||||||
];
|
];
|
||||||
|
|
||||||
if (str_starts_with($this -> post -> command, 'server')) {
|
$res = pg_query($this -> dbconn, sprintf(
|
||||||
$res = pg_query($this -> dbconn, sprintf(
|
"SELECT url, port
|
||||||
"SELECT url, port
|
FROM hf_mes_scada_edgeserver_controller_server
|
||||||
FROM hf_mes_scada_edgeserver_controller_server
|
WHERE id = '%s'",
|
||||||
WHERE id = '%s'",
|
$this -> post -> server_id
|
||||||
$this -> post -> server_id
|
));
|
||||||
));
|
$server_info = pg_fetch_row($res);
|
||||||
$server_info = pg_fetch_row($res);
|
|
||||||
|
if (str_starts_with($this -> post -> command, 'server'))
|
||||||
$ch = curl_init(
|
$ch = curl_init(
|
||||||
$server_info[0]
|
$server_info[0]
|
||||||
. ":"
|
. ":"
|
||||||
. $server_info[1]
|
. $server_info[1]
|
||||||
. $command2API[$this -> post -> command]
|
. $command2API[$this -> post -> command]
|
||||||
);
|
);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
else if (str_starts_with($this -> post -> command, 'device'))
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
$ch = curl_init(
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
$server_info[0]
|
||||||
curl_setopt(
|
|
||||||
$ch,
|
|
||||||
CURLOPT_USERPWD,
|
|
||||||
$this -> post -> username
|
|
||||||
. ":"
|
. ":"
|
||||||
. $this -> post -> password
|
. $server_info[1]
|
||||||
|
. $command2API[$this -> post -> command]
|
||||||
|
. '?data='
|
||||||
|
. $this -> post -> device_id
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt(
|
||||||
|
$ch,
|
||||||
|
CURLOPT_USERPWD,
|
||||||
|
$this -> post -> username
|
||||||
|
. ":"
|
||||||
|
. $this -> post -> password
|
||||||
|
);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||||
|
$return = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
if ($return) {
|
||||||
|
pg_update(
|
||||||
|
$this -> dbconn,
|
||||||
|
"hf_mes_scada_edgeserver_controller_server",
|
||||||
|
['updated' => false],
|
||||||
|
['id' => $this -> post -> server_id]
|
||||||
);
|
);
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
|
||||||
$return = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
if ($return) {
|
|
||||||
pg_update(
|
|
||||||
$this -> dbconn,
|
|
||||||
"hf_mes_scada_edgeserver_controller_server",
|
|
||||||
['updated' => false],
|
|
||||||
['id' => $this -> post -> server_id]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pg_insert(
|
pg_insert(
|
||||||
@@ -56,6 +69,7 @@ class ECommand {
|
|||||||
'hf_mes_scada_edgeserver_controller_command',
|
'hf_mes_scada_edgeserver_controller_command',
|
||||||
[
|
[
|
||||||
'server_id' => $this -> post -> server_id,
|
'server_id' => $this -> post -> server_id,
|
||||||
|
'device_id' => $this -> post -> server_id ?? NULL,
|
||||||
'command' => $this -> post -> command,
|
'command' => $this -> post -> command,
|
||||||
'success' => $return
|
'success' => $return
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user