操,更改设备状态需要用get方法
This commit is contained in:
@@ -12,7 +12,7 @@ class ECommand {
|
||||
'server_restart' => '/Admin/ServerCloseAndRestart',
|
||||
'server_close' => '/Admin/ServerClose',
|
||||
'device_stop' => '/Edge/DeviceStopRequest',
|
||||
'device_continue' => 'Edge/DeviceContinueRequest'
|
||||
'device_continue' => '/Edge/DeviceContinueRequest'
|
||||
];
|
||||
|
||||
$res = pg_query($this -> dbconn, sprintf(
|
||||
@@ -23,28 +23,29 @@ class ECommand {
|
||||
));
|
||||
$server_info = pg_fetch_row($res);
|
||||
|
||||
if (str_starts_with($this -> post -> command, 'server'))
|
||||
if (str_starts_with($this -> post -> command, 'server')) {
|
||||
$ch = curl_init(
|
||||
$server_info[0]
|
||||
. ":"
|
||||
. $server_info[1]
|
||||
. $command2API[$this -> post -> command]
|
||||
);
|
||||
else if (str_starts_with($this -> post -> command, 'device'))
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
} else if (str_starts_with($this -> post -> command, 'device')) {
|
||||
$ch = curl_init(
|
||||
$server_info[0]
|
||||
. ":"
|
||||
. $server_info[1]
|
||||
. $command2API[$this -> post -> command]
|
||||
. '?data='
|
||||
. $this -> post -> device_id
|
||||
. $this -> post -> device_name
|
||||
);
|
||||
else
|
||||
} 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,
|
||||
@@ -69,7 +70,7 @@ class ECommand {
|
||||
'hf_mes_scada_edgeserver_controller_command',
|
||||
[
|
||||
'server_id' => $this -> post -> server_id,
|
||||
'device_id' => $this -> post -> server_id ?? NULL,
|
||||
'device_name' => $this -> post -> server_id ?? NULL,
|
||||
'command' => $this -> post -> command,
|
||||
'success' => $return
|
||||
],
|
||||
|
||||
@@ -44,7 +44,7 @@ function init_db($server_name, $port, $user, $password) {
|
||||
pg_query($dbconn, "CREATE TABLE IF NOT EXISTS hf_mes_scada_edgeserver_controller_command (
|
||||
id serial8 primary key,
|
||||
server_id serial2 references hf_mes_scada_edgeserver_controller_server(id),
|
||||
device_id text,
|
||||
device_name text,
|
||||
command text,
|
||||
create_date timestamp NOT NULL DEFAULT NOW(),
|
||||
success bool
|
||||
|
||||
Reference in New Issue
Block a user