Browse Source

通风主界面接口测试

q 1 năm trước cách đây
mục cha
commit
203a1cbd7b

+ 131 - 1
Modules/OpcData/Http/Controllers/Api/zaoquan/ZQDcsFanController.php

@@ -60,6 +60,8 @@ class ZQDcsFanController  extends BaseController
                     return $this->get250602hfxList();
                 case '13207jx': // 13207机巷
                     return $this->get13207jxList();
+                case 'index': // 13207机巷
+                    return $this->getInfoList();
                 default:
                     $msg="未知数据";
                     $code=-2;
@@ -69,6 +71,128 @@ class ZQDcsFanController  extends BaseController
     }
 
     /*
+     * 通风入口接口
+     * */
+    public function getInfoList() {
+
+        $keys=[
+            "2008319841133569_2", "2008298772323329_1" // 东井
+            ,"2009735056108545_2", "2009735056749569_2" // 西井
+            ,"2009721035631617_2", "2009721047067649_2" // 1314立井
+            ,"2074993339513857_2", "2074993343917057_2" // 13207机巷
+            ,"2063316486075393_2", "2063316488862721_2" // 250602回风巷
+            ,"2059629794612225_2", "2059629795228673_2" // 110207机巷 -
+//            ,"2059629794612225_2", "2059629795228673_2" // 110207回风巷 -
+            ,"2074999786576897_2", "2074999790310401_2" // 五六分区220708胶带巷
+            ,"2046535459097601_2", "2046535461340161_2" // 五六分区220708辅助巷
+            ,"2046522721719297_2", "2046522723800065_2" // 五六分区1200石门
+            ,"2049479008105473_2", "2049479008132097_2" // 五六分区1200车场
+            ,"2008681964219393_2", "2008682656793601_2" // 五分区通风系统
+        ];
+
+        // 获取点位数据
+        $dataFromGetRequest = $this->apiService->postPointRealData($this->apiUrl, $keys);
+
+
+        // 获取风门数据
+        // 自动风门 http://7.250.4.5:1434/zqk/api/AutomaticAirDoors/AutomaticAirDoor
+        // 自动风窗 http://7.250.4.5:1434/zqk/api/AutomaticWindDevices/AutomaticWindDevice
+        // 变频局扇 http://7.250.4.5:1434/zqk/api/LocalFans/LocalFan
+
+        $autoAirDoorsUrl = 'http://7.250.4.5:1434/zqk/api/AutomaticAirDoors/AutomaticAirDoor';
+        $autoWindDevicesUrl = 'http://7.250.4.5:1434/zqk/api/AutomaticWindDevices/AutomaticWindDevice';
+        $LocalFansUrl = 'http://7.250.4.5:1434/zqk/api/LocalFans/LocalFan';
+
+        $autoAirDoorsData = $this->apiService->postApiData($autoAirDoorsUrl);
+        $autoWindDevicesData = $this->apiService->postApiData($autoWindDevicesUrl);
+        $LocalFansData = $this->apiService->postApiData($LocalFansUrl);
+
+        // 获取饼图数据(数据库)
+        // cq.wind.online_chart
+        $data = "{'analysisSign': 'JSecf85ff100843272', 'analysisTime': '2022-11-21 08:40:08', 'circutCount': 104, 'diagonalCount': 42, 'balanceRatio': 1, 'holeArea': 4.83, 'returnRatio': 0.13, 'returnHf': 20356, 'richFactor': 1, 'airEffcient': 0, 'needTotalQuantity': 16052, 'needQuantity': 15052, 'totalQuantity': 17908, 'vaildWindRate': 0.89635915, 'dsr': 1.0664364}";
+        $windArr = json_decode($data);
+
+        $info = [
+            "charData_1"=>[
+                "series"=>[
+                    "data"=>[
+                        [
+                            "name"=>"有效风",
+                            "value"=>0
+                        ],
+                        [
+                            "name"=>"无效风",
+                            "value"=>0
+                        ]
+                    ]
+                ]
+            ],
+            "charData_2"=>[
+                "series"=>[
+                    "data"=>[
+                        [
+                            "name"=>"供风量",
+                            "value"=>0
+                        ],
+                        [
+                            "name"=>"需风量",
+                            "value"=>15052
+                        ]
+                    ]
+                ]
+            ],
+            "info"=>[
+                [
+                    "label"=>"自动风门",
+                    "value"=>"2扇"
+                ],
+                [
+                    "label"=>"自动风窗",
+                    "value"=>"2扇"
+                ],
+                [
+                    "label"=>"变频风扇",
+                    "value"=>"2扇"
+                ]
+            ],
+            "list"=>[
+                [
+                    "title"=>"东井通风机",
+                    "sys_code"=>"east",
+                    "info"=>[
+                        [
+                            "label"=>"1#风机",
+                            "state"=>0,
+                            "text"=>"停止"
+                        ],
+                        [
+                            "label"=>"2#风机",
+                            "state"=>1,
+                            "text"=>"运行"
+                        ]
+                    ]
+                ],
+                [
+                    "title"=>"西井通风机",
+                    "sys_code"=>"east",
+                    "info"=>[
+                        [
+                            "label"=>"1#风机",
+                            "state"=>0,
+                            "text"=>"停止"
+                        ],
+                        [
+                            "label"=>"2#风机",
+                            "state"=>1,
+                            "text"=>"运行"
+                        ]
+                    ]
+                ]
+            ]
+        ];
+        return json_encode($info);
+    }
+    /*
      * 13207机巷
      */
     public function get13207jxList() {
@@ -2269,6 +2393,12 @@ class ZQDcsFanController  extends BaseController
         return $baseData;
     }
 
+    public function getDBDataFrom($tb_name, $where='') {
+        // 构建 SQL 查询
+        $sqlStr = "select * from $tb_name";
+        $res = $this->executeSql($sqlStr, 3);
+    }
+
     public function executeSql($sqlStr, $modelname = -1) {
 
         try{
@@ -2284,7 +2414,7 @@ class ZQDcsFanController  extends BaseController
                 case 4:
                     return $this->error(-1, '获取详细列表出错!');
                 default:
-                    return $this->error(-1, '未知错误!');
+                    return $this->error(-1, '数据库查询错误!');
             }
 
         }

+ 13 - 17
Modules/OpcData/Services/zaoquan/ZQDcsApiService.php

@@ -63,23 +63,19 @@ class ZQDcsApiService
         return $transformedData;
     }
 
-//    public function postApiData($apiUrl, $postData)
-//    {
-//        // 发送 HTTP POST 请求
-//        $response = $this->client->post($apiUrl, [
-//            'PageNum'=>"-1",
-//            'form_params' => $postData,
-//            // 可以添加其他选项,如 headers、auth 等
-//        ]);
-//
-//        // 获取 API 响应的 JSON 数据
-//        $data = json_decode($response->getBody(), true);
-//
-//        // 对数据进行重组,这里只是一个示例,具体根据实际需求调整
-//        $transformedData = $this->transformData($data);
-//
-//        return $transformedData;
-//    }
+    public function postApiData($apiUrl, $postData = '')
+    {
+        // 发送 HTTP POST 请求
+        $response = $this->client->post($apiUrl, $postData);
+
+        // 获取 API 响应的 JSON 数据
+        $data = json_decode($response->getBody(), true);
+
+        // 对数据进行重组,这里只是一个示例,具体根据实际需求调整
+        $transformedData = $this->transformData($data);
+
+        return $transformedData;
+    }
 
     protected function transformData($data)
     {