From 47004e23772ccaf3461df849ee8a2c7cdc4f4b11 Mon Sep 17 00:00:00 2001 From: wuyanwei <2468489804@qq.com> Date: Wed, 10 Aug 2022 17:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0set=5Fnode=5Fdata=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=A0=B9=E6=8D=AEcode=E6=9F=A5=E8=AF=A2working=5Fsubc?= =?UTF-8?q?lass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EdgeManager/EDataCapture/EDataCapture.php | 24 +++++++++++++-------- EdgeManager/EDataCapture/ENodeConfigure.php | 10 +++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/EdgeManager/EDataCapture/EDataCapture.php b/EdgeManager/EDataCapture/EDataCapture.php index 9df0560..9eb4f0d 100644 --- a/EdgeManager/EDataCapture/EDataCapture.php +++ b/EdgeManager/EDataCapture/EDataCapture.php @@ -13,14 +13,20 @@ class EDataCapture { protected $data = [], ) { if (!is_null($this -> post)) { - if (!in_array( - $this -> post -> param -> working_subclass, - ENodeConfigure::get_working_subclasses($this -> dbconn) - )) { - $this -> check_res = 'WRONG_WORKING_SUBCLASS'; - return; - } else { - $this -> working_subclass = $this -> post -> param -> working_subclass; + if(isset($this -> post -> param -> working_subclass)){ + if (!in_array( + $this -> post -> param -> working_subclass, + ENodeConfigure::get_working_subclasses($this -> dbconn) + )) { + $this -> check_res = 'WRONG_WORKING_SUBCLASS'; + return; + } else { + $this -> working_subclass = $this -> post -> param -> working_subclass; + } + }else{ + //根据code查询working_subclasses + $working_subclass = ENodeConfigure::get_working_subclasses_by_codes($this -> dbconn, $this -> post -> param -> data[0] -> code); + $this -> working_subclass = $working_subclass[0]; } if ($this -> no_dup_code) { @@ -33,7 +39,7 @@ class EDataCapture { "SELECT code, type FROM hf_mes_scada_data_capture_node_configure WHERE working_subclass = '%s'", - $this -> post -> param -> working_subclass + $this -> working_subclass ))); } diff --git a/EdgeManager/EDataCapture/ENodeConfigure.php b/EdgeManager/EDataCapture/ENodeConfigure.php index 7197aa3..f55be8b 100644 --- a/EdgeManager/EDataCapture/ENodeConfigure.php +++ b/EdgeManager/EDataCapture/ENodeConfigure.php @@ -125,6 +125,16 @@ class ENodeConfigure { return pg_fetch_all_columns($res, 0); } + static function get_working_subclasses_by_codes($dbconn, $code) { + $res = pg_query($dbconn, sprintf( + "SELECT working_subclass + FROM hf_mes_scada_data_capture_node_configure + WHERE code = '%s'", + $code + )); + return pg_fetch_all_columns($res, 0); + } + function get_codes_by_working_subclasses() { $res = pg_query($this -> dbconn, sprintf( "SELECT code