| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- /**
- * 会议相关
- * 请求地址如:oa.test/api.php?m=openTest&a=dcs_door&openkey=d9302364e2a2d9fdcab2707a46fbab5a&staff_num=123456
- */
- class openDcsApiClassAction 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()));
- }
- }
- public function dcs_doorAction() {
- $rawArr = $this->getpostarr();
- $groupArr = m("dcs_group")->getall("1=1 and is_show=1");
- $rowArr = ["nav"=>[]];
- $pcon = 0;
- for ($i = 0; $i < count($groupArr); $i++) {
- $row = $groupArr[$i];
- if ($row['pid'] == 0) {
- $rowArr["nav"][$pcon] = [
- "title"=>$row['name'],
- "list"=>[]
- ];
- for ($j = 0; $j <count($groupArr); $j++) {
- $crow = $groupArr[$j];
- if ($crow['pid'] == $row['id']) {
- $rowArr["nav"][$pcon]["list"][] = [
- "id" => $crow['id'],
- "icon" => URL.(empty($crow['icon']) ? $row['icon'] : $crow['icon']),
- "module"=>$row['key'],
- "name"=>$crow['name'],
- "sys_code"=>$crow['key'],
- ];
- }
- }
- $pcon++;
- }
- }
- return $rowArr;
- }
- public function dcs_auth_checkAction() {
- $staffNum = $this->get('staff_num');
- $sys_id = $this->get('sys_id');
- if (empty($staffNum) || empty($sys_id)) {
- $this->showreturn('', '参数错误!', 201);
- }
- $uInfo = m("admin")->getone("user='{$staffNum}'");
- $checkAuth = m("dcs_auth")->getall("FIND_IN_SET($sys_id, `range`) and FIND_IN_SET({$uInfo['id']}, `user_ids`) ");
- // 找到权限
- if (!empty($checkAuth) && count($checkAuth) > 0) {
- $urlInfo = m("dcs_group")->getone("id={$sys_id}");
- $this->showreturn([url=>trim($urlInfo['url'])], '成功!', 200);
- } else {
- $this->showreturn('', '暂无权限访问,请联系管理员!', 202);
- }
- }
- }
|