diff --git a/EdgeManager.php b/EdgeManager.php index 3998f27..218f74f 100644 --- a/EdgeManager.php +++ b/EdgeManager.php @@ -159,7 +159,7 @@ $worker -> onMessage = function(TcpConnection $connection, Request $request) { ], json_encode(array( 'action' => 'result_set_node_data', 'errcode' => 4002, - 'errmsg' => '未登记过的工序单元!' + 'errmsg' => '工序单元有误,请检查是否未指定或未登记!' ))); $connection -> send($response); } else if ($data_capture -> check_res === 'MISMATCH_TYPE') { diff --git a/EdgeManager/EDataCapture/EDataCapture.php b/EdgeManager/EDataCapture/EDataCapture.php index 9eb4f0d..991c0a6 100644 --- a/EdgeManager/EDataCapture/EDataCapture.php +++ b/EdgeManager/EDataCapture/EDataCapture.php @@ -24,25 +24,21 @@ class EDataCapture { $this -> working_subclass = $this -> post -> param -> working_subclass; } }else{ - //根据code查询working_subclasses + if ($this -> no_dup_code) { + $this -> check_res = 'WRONG_WORKING_SUBCLASS'; + return; + } $working_subclass = ENodeConfigure::get_working_subclasses_by_codes($this -> dbconn, $this -> post -> param -> data[0] -> code); - $this -> working_subclass = $working_subclass[0]; + $this -> working_subclass = $working_subclass['working_subclass']; } - if ($this -> no_dup_code) { - $res = pg_fetch_all(pg_query($this -> dbconn, - "SELECT code, type - FROM hf_mes_scada_data_capture_node_configure" - )); - } else { - $res = pg_fetch_all(pg_query($this -> dbconn, sprintf( - "SELECT code, type - FROM hf_mes_scada_data_capture_node_configure - WHERE working_subclass = '%s'", - $this -> working_subclass - ))); - } - + $res = pg_fetch_all(pg_query($this -> dbconn, sprintf( + "SELECT code, type + FROM hf_mes_scada_data_capture_node_configure + WHERE working_subclass = '%s'", + $this -> working_subclass + ))); + $code_type = &$this -> code_type; array_walk($res, function(&$v, $k) use (&$code_type) { $code_type[$v['code']] = $v['type']; diff --git a/EdgeManager/EDataCapture/ENodeConfigure.php b/EdgeManager/EDataCapture/ENodeConfigure.php index ad7c016..e651da4 100644 --- a/EdgeManager/EDataCapture/ENodeConfigure.php +++ b/EdgeManager/EDataCapture/ENodeConfigure.php @@ -16,15 +16,15 @@ class ENodeConfigure { "SELECT EXISTS( SELECT 1 FROM hf_mes_scada_data_capture_node_configure WHERE code = '%s' - )", $this -> post -> code + AND working_subclass = '%s' + )", $this -> post -> code, $this -> post -> working_subclass )); } else { $exists = pg_query($this -> dbconn, sprintf( "SELECT EXISTS( SELECT 1 FROM hf_mes_scada_data_capture_node_configure WHERE code = '%s' - AND working_subclass = '%s' - )", $this -> post -> code, $this -> post -> working_subclass + )", $this -> post -> code )); } @@ -132,7 +132,7 @@ class ENodeConfigure { WHERE code = '%s'", $code )); - return pg_fetch_all_columns($res, 0); + return pg_fetch_assoc($res); } function get_codes_by_working_subclasses() {