修改使工序单元间允许重复code
This commit is contained in:
@@ -71,7 +71,7 @@ $worker -> onMessage = function(TcpConnection $connection, Request $request) {
|
|||||||
else if ($res === "REPLICATED")
|
else if ($res === "REPLICATED")
|
||||||
$connection -> send(json_encode(array(
|
$connection -> send(json_encode(array(
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => '节点编码不可重复!'
|
'msg' => '同一工序单元内的节点编码不可重复!'
|
||||||
)));
|
)));
|
||||||
else if ($res === false) {
|
else if ($res === false) {
|
||||||
$connection -> send(json_encode(array(
|
$connection -> send(json_encode(array(
|
||||||
|
|||||||
@@ -22,10 +22,12 @@ class EDataCapture {
|
|||||||
$this -> working_subclass = $this -> post -> param -> working_subclass;
|
$this -> working_subclass = $this -> post -> param -> working_subclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = pg_fetch_all(pg_query($this -> dbconn,
|
$res = pg_fetch_all(pg_query($this -> dbconn, sprintf(
|
||||||
"SELECT code, type
|
"SELECT code, type
|
||||||
FROM hf_mes_scada_data_capture_node_configure"
|
FROM hf_mes_scada_data_capture_node_configure
|
||||||
));
|
WHERE working_subclass = '%s'",
|
||||||
|
$this -> post -> param -> working_subclass
|
||||||
|
)));
|
||||||
|
|
||||||
$code_type = &$this -> code_type;
|
$code_type = &$this -> code_type;
|
||||||
array_walk($res, function(&$v, $k) use (&$code_type) {
|
array_walk($res, function(&$v, $k) use (&$code_type) {
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ class ENodeConfigure {
|
|||||||
function add_node() {
|
function add_node() {
|
||||||
$exists = pg_query($this -> dbconn, sprintf(
|
$exists = pg_query($this -> dbconn, sprintf(
|
||||||
"SELECT EXISTS(
|
"SELECT EXISTS(
|
||||||
SELECT 1 FROM hf_mes_scada_data_capture_node_configure WHERE code='%s'
|
SELECT 1 FROM hf_mes_scada_data_capture_node_configure
|
||||||
)", $this -> post -> code
|
WHERE code = '%s'
|
||||||
|
AND working_subclass = '%s'
|
||||||
|
)", $this -> post -> code, $this -> post -> working_subclass
|
||||||
));
|
));
|
||||||
if (pg_fetch_assoc($exists)['exists'] == 't') {
|
if (pg_fetch_assoc($exists)['exists'] == 't') {
|
||||||
return "REPLICATED";
|
return "REPLICATED";
|
||||||
@@ -23,7 +25,7 @@ class ENodeConfigure {
|
|||||||
$res[] = pg_query($this -> dbconn, sprintf(
|
$res[] = pg_query($this -> dbconn, sprintf(
|
||||||
'CREATE TABLE IF NOT EXISTS "%s" (
|
'CREATE TABLE IF NOT EXISTS "%s" (
|
||||||
id serial8,
|
id serial8,
|
||||||
code text references hf_mes_scada_data_capture_node_configure(code),
|
code text,
|
||||||
v_string text,
|
v_string text,
|
||||||
v_int int,
|
v_int int,
|
||||||
v_float float8,
|
v_float float8,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ function init_db($server_name, $user, $password) {
|
|||||||
// 全局未启用TSDB的时候在这里对scada数据库启用就好
|
// 全局未启用TSDB的时候在这里对scada数据库启用就好
|
||||||
pg_query($dbconn, "CREATE EXTENSION IF NOT EXISTS timescaledb");
|
pg_query($dbconn, "CREATE EXTENSION IF NOT EXISTS timescaledb");
|
||||||
pg_query($dbconn, "CREATE TABLE IF NOT EXISTS hf_mes_scada_data_capture_node_configure (
|
pg_query($dbconn, "CREATE TABLE IF NOT EXISTS hf_mes_scada_data_capture_node_configure (
|
||||||
id serial2,
|
id serial2 primary key,
|
||||||
code text primary key NOT NULL,
|
code text,
|
||||||
name text NOT NULL,
|
name text NOT NULL,
|
||||||
type text NOT NULL,
|
type text NOT NULL,
|
||||||
flow_code text,
|
flow_code text,
|
||||||
@@ -21,5 +21,24 @@ function init_db($server_name, $user, $password) {
|
|||||||
create_date timestamp NOT NULL DEFAULT NOW(),
|
create_date timestamp NOT NULL DEFAULT NOW(),
|
||||||
note text
|
note text
|
||||||
)");
|
)");
|
||||||
|
pg_query($dbconn, "CREATE TABLE IF NOT EXISTS hf_mes_scada_edgeserver_controller_server (
|
||||||
|
id serial2 primary key,
|
||||||
|
code text,
|
||||||
|
name text NOT NULL,
|
||||||
|
ip text NOT NULL,
|
||||||
|
port int2 NOT NULL,
|
||||||
|
sync_addr text NOT NULL,
|
||||||
|
create_date timestamp NOT NULL DEFAULT NOW(),
|
||||||
|
note text
|
||||||
|
)");
|
||||||
|
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,
|
||||||
|
node text,
|
||||||
|
command text,
|
||||||
|
create_date timestamp NOT NULL DEFAULT NOW(),
|
||||||
|
update_status bool
|
||||||
|
)");
|
||||||
pg_close($dbconn);
|
pg_close($dbconn);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user