node configure增改接近完成,删除后端还没做
This commit is contained in:
64
app/EDataCapture/ENodeConfigure.php
Normal file
64
app/EDataCapture/ENodeConfigure.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace EdgeManager\EDataCapture;
|
||||
|
||||
class ENodeConfigure {
|
||||
function __construct(
|
||||
protected $dbconn,
|
||||
protected $post = NULL,
|
||||
protected $get = NULL
|
||||
) {}
|
||||
|
||||
function add_node() {
|
||||
$table_name = "hf_mes_scada_data_capture_node_data_" . $this -> post['process_code'];
|
||||
|
||||
pg_query($this -> dbconn, "BEGIN");
|
||||
$res1 = pg_query($this -> dbconn, sprintf(
|
||||
"CREATE TABLE IF NOT EXISTS %s(
|
||||
id serial8,
|
||||
code text references hf_mes_scada_data_capture_node_configure(code),
|
||||
v_string text,
|
||||
v_int int,
|
||||
v_float float8,
|
||||
v_bool bool,
|
||||
device_code text,
|
||||
batch text,
|
||||
create_date timestamp
|
||||
)", $table_name
|
||||
));
|
||||
$res2 = pg_insert(
|
||||
$this -> dbconn,
|
||||
'hf_mes_scada_data_capture_node_configure',
|
||||
$this -> post
|
||||
);
|
||||
|
||||
if ($res1 and $res2)
|
||||
pg_query($this -> dbconn, "COMMIT");
|
||||
else
|
||||
pg_query($this -> dbconn, "ROLLBACK");
|
||||
|
||||
pg_query($this -> dbconn, sprintf("SELECT create_hypertable('%s','create_date')", $table_name));
|
||||
pg_query($this -> dbconn, sprintf(
|
||||
"CREATE INDEX ON %s (v_string, v_int, v_float, v_bool, create_date DESC)
|
||||
WHERE COALESCE(v_string, v_int::text, v_float::text, v_bool::text) IS NOT NULL
|
||||
", $table_name
|
||||
));
|
||||
}
|
||||
|
||||
function remove_node() {
|
||||
|
||||
}
|
||||
|
||||
function update_node() {
|
||||
return pg_update(
|
||||
$this -> dbconn,
|
||||
'hf_mes_scada_data_capture_node_configure',
|
||||
$this -> post,
|
||||
['code' => $this -> post['code']]
|
||||
);
|
||||
}
|
||||
|
||||
function get_nodes() {
|
||||
$res = pg_query($this -> dbconn, "SELECT * FROM hf_mes_scada_data_capture_node_configure");
|
||||
return pg_fetch_all($res);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user