From 92fb34f57919c51e44e2c83b203c7545467873a9 Mon Sep 17 00:00:00 2001 From: Yu Sun Date: Fri, 19 Aug 2022 17:47:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=EF=BC=8C=E6=9B=B4=E6=94=B9=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=8A=B6=E6=80=81=E9=9C=80=E8=A6=81=E7=94=A8get?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EdgeManager/EController/ECommand.php | 15 ++++++++------- EdgeManager/Init.php | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/EdgeManager/EController/ECommand.php b/EdgeManager/EController/ECommand.php index 9ee124f..2ad4b42 100644 --- a/EdgeManager/EController/ECommand.php +++ b/EdgeManager/EController/ECommand.php @@ -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 ], diff --git a/EdgeManager/Init.php b/EdgeManager/Init.php index f1ab715..aed5ec8 100644 --- a/EdgeManager/Init.php +++ b/EdgeManager/Init.php @@ -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