采集数据时新增一个parent_code字段,同时device_code更改为必填
This commit is contained in:
@@ -175,6 +175,15 @@ $worker -> onMessage = function(TcpConnection $connection, Request $request) {
|
||||
'errmsg' => '节点编码和数值类型不匹配!'
|
||||
)));
|
||||
$connection -> send($response);
|
||||
} else if ($data_capture -> check_res === 'NO_DEVICE_CODE') {
|
||||
$response = new Response(200, [
|
||||
'Content-Type' => 'application/json;charset=utf-8',
|
||||
], json_encode(array(
|
||||
'action' => 'result_set_node_data',
|
||||
'errcode' => 4002,
|
||||
'errmsg' => 'device_code为必填字段!'
|
||||
)));
|
||||
$connection -> send($response);
|
||||
}
|
||||
$res = $data_capture -> set_node_data();
|
||||
if ($res === true) {
|
||||
|
||||
@@ -51,13 +51,18 @@ class EDataCapture {
|
||||
if (!$check_func($row -> value)) {
|
||||
$this -> check_res = 'MISMATCH_TYPE';
|
||||
return;
|
||||
} else {
|
||||
$this -> data[$row -> code][] = [
|
||||
'value' => $row -> value,
|
||||
'device_code' => $row -> device_code ?? NULL,
|
||||
'batch' => $row -> batch ?? NULL
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($row -> device_code)) {
|
||||
$this -> check_res = 'NO_DEVICE_CODE';
|
||||
return;
|
||||
}
|
||||
$this -> data[$row -> code][] = [
|
||||
'value' => $row -> value,
|
||||
'device_code' => $row -> device_code,
|
||||
'parent_code' => $row -> parent_code ?? NULL,
|
||||
'batch' => $row -> batch ?? NULL
|
||||
];
|
||||
}
|
||||
unset($row);
|
||||
}
|
||||
@@ -78,7 +83,8 @@ class EDataCapture {
|
||||
"('%s', '%s', '%s', '%s')",
|
||||
$code,
|
||||
$row['value'] === false ? 'f' : $row['value'],
|
||||
$row['device_code'] ?? NULL,
|
||||
$row['device_code'],
|
||||
$row['parent_code'] ?? NULL,
|
||||
$row['batch'] ?? NULL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,12 +38,13 @@ class ENodeConfigure {
|
||||
$res[] = pg_query($this -> dbconn, sprintf(
|
||||
'CREATE TABLE IF NOT EXISTS "%s" (
|
||||
id serial8,
|
||||
code text,
|
||||
code text NOT NULL,
|
||||
v_string text,
|
||||
v_int int,
|
||||
v_float float8,
|
||||
v_bool bool,
|
||||
device_code text,
|
||||
device_code text NOT NULL,
|
||||
parent_code text,
|
||||
batch text,
|
||||
capture_time timestamp NOT NULL DEFAULT NOW()
|
||||
)', $table_name
|
||||
|
||||
@@ -32,19 +32,21 @@
|
||||
{
|
||||
"action": "set_node_data",
|
||||
"param": {
|
||||
"working_subclass": <string>,
|
||||
"working_subclass": <string>, // 可选
|
||||
"data": [
|
||||
{
|
||||
"code": <string>,
|
||||
// value的类型需与type对应
|
||||
"value": <string | int | float | bool>,
|
||||
"device_code": [string],
|
||||
"batch": [string]
|
||||
"device_code": [string], // 必需字段
|
||||
"parent_code": [string], // 可选字段,对应MES中的code
|
||||
"batch": [string] // 可选字段
|
||||
},
|
||||
{
|
||||
"code": <string>,
|
||||
"value": <string | int | float | bool>,
|
||||
"device_code": [string],
|
||||
"parent_code": [string],
|
||||
"batch": [string]
|
||||
},
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user