操,更改设备状态需要用get方法

This commit is contained in:
Yu Sun
2022-08-19 17:47:32 +08:00
parent a01cf0b232
commit 92fb34f579
2 changed files with 9 additions and 8 deletions

View File

@@ -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
],

View File

@@ -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