|
@@ -0,0 +1,54 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+/**
|
|
|
+ * 会议相关
|
|
|
+ * 请求地址如:http://oa.test/api.php?m=openmeet&a=test&openkey=fee5efd3a93ca5c6a85b679cde60faa2
|
|
|
+ */
|
|
|
+class openDcsOpcClassAction extends openapiAction
|
|
|
+{
|
|
|
+
|
|
|
+ public function testAction() {
|
|
|
+
|
|
|
+ // $shell = "echo 'success' ";
|
|
|
+ // $shellExec = shell_exec($shell);
|
|
|
+ // // var_dump($shellExec);
|
|
|
+ // if($shellExec){echo 'ok';} else {echo 'error'}
|
|
|
+
|
|
|
+ $pids = [
|
|
|
+ "ns=12380;s=九八零变电所80Z004照明回路_Ia",
|
|
|
+ "ns=12380;s=九八零变电所5105_IA",
|
|
|
+ "ns=12380;s=九八零变电所5101_UB",
|
|
|
+ # 添加其他节点地址...
|
|
|
+ ];
|
|
|
+
|
|
|
+ $pyPath = "/home/python_proj/python_custom_script/zaoquan/dcs/";
|
|
|
+ $pyFName = "test1.py";
|
|
|
+ $pyKeyWord = "/usr/bin/python311";
|
|
|
+
|
|
|
+ $pidsJson = json_encode($pids);
|
|
|
+
|
|
|
+ $command = "$pyKeyWord {$pyPath}{$pyFName}". ' ' . escapeshellarg("{$pidsJson}");
|
|
|
+ // $output = shell_exec($command);
|
|
|
+
|
|
|
+ // return shell_exec($command);
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用Python脚本
|
|
|
+ $output = shell_exec($command);
|
|
|
+
|
|
|
+ // 解析Python脚本返回的JSON数据
|
|
|
+ $data = json_decode($output, true);
|
|
|
+ $data['a'] = 'aaa';
|
|
|
+ // 返回JSON格式的数据给前端
|
|
|
+ header('Content-Type: application/json');
|
|
|
+ echo json_encode($data);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ // 返回错误消息给前端
|
|
|
+ header('Content-Type: application/json');
|
|
|
+ echo json_encode(array("error" => $e->getMessage()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|