wang jun 1 year ago
parent
commit
68e79e18bd

+ 7 - 0
application/api/controller/Shouhuan.php

@@ -38,6 +38,7 @@ class Shouhuan extends Controller
             'remove', //佩戴提醒
             'bootoff', //开关机时间
             'call', //拨打电话
+            'keybrd', //拨号开关
         ];
         $data = request()->post();
         $command = $data['command'];
@@ -141,6 +142,12 @@ class Shouhuan extends Controller
         $result = $l_s->createcallcommand($facility_id, $device_id_code, $param, $sys_user_id);
         return $result;
     }
+    private function ctreateKeybrdCommand($facility_id, $device_id_code, $param, $sys_user_id)
+    {
+        $l_s = new Shouhuanlogic();
+        $result = $l_s->createkeybrdcommand($facility_id, $device_id_code, $param, $sys_user_id);
+        return $result;
+    }
     /**
      * 返回正确信息
      *

+ 21 - 0
application/api/logic/Shouhuanlogic.php

@@ -324,4 +324,25 @@ class Shouhuanlogic
         $s_sc->createcallcommand($facility_id, $device_id_code, $telno, $sys_user_id);
         return backarr(1, "操作成功");
     }
+    /**
+     * 拨号开关
+     *
+     * @param  [type] $facility_id
+     * @param  [type] $device_id_code
+     * @param  [type] $param
+     * @param  [type] $sys_user_id
+     * @return void
+     * @author wj
+     * @date 2023-09-18
+     */
+    public function createkeybrdcommand($facility_id, $device_id_code, $param, $sys_user_id)
+    {
+        if (!isset($param['is_open'])) {
+            throw new \Exception("参数错误");
+        }
+        $is_open = empty($param['is_open']) ? 0 : 1;
+        $s_sc = new ShouhuanCommand();
+        $s_sc->createkeybrdcommand($facility_id, $device_id_code, $is_open, $sys_user_id);
+        return backarr(1, "操作成功");
+    }
 }

+ 33 - 2
application/common/server/ShouhuanCommand.php

@@ -399,6 +399,14 @@ class ShouhuanCommand
                 'kind' => 'send',
                 'need_back' => 1,
             ],
+            'KEYBRD' => [
+                'content' => [
+                    'command' => 'KEYBRD',
+                    'is_open' => '',
+                ],
+                'kind' => 'send',
+                'need_back' => 1,
+            ],
             //平台回复
             'LK' => [
                 'content' => [
@@ -889,8 +897,15 @@ class ShouhuanCommand
      */
     public function createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id)
     {
-        Log::write($param, 'shouhuan');
-        $is_open = $param['is_open'];
+        $is_open = empty($param['is_open']) ? 0 : 1;
+
+        $fillfields = ['bootup_time', 'shutdown_time'];
+        foreach ($fillfields as $key => $value) {
+            if (!isset($param[$value]) || empty($param[$value])) {
+                throw new \Exception("BOOTOFF参数错误");
+            }
+        }
+
         $bootup_time = $param['bootup_time'];
         $shutdown_time = $param['shutdown_time'];
         $command = [
@@ -931,4 +946,20 @@ class ShouhuanCommand
         $command = ['command' => 'CALL', 'content_arr' => ['command' => 'CALL', 'telno' => $telno]];
         $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
     }
+    /**
+     * 拨号盘开关
+     *
+     * @param  [type] $facility_id
+     * @param  [type] $device_id_code
+     * @param  [type] $telno
+     * @param  [type] $sys_user_id
+     * @return void
+     * @author wj
+     * @date 2023-09-18
+     */
+    public function createkeybrdcommand($facility_id, $device_id_code, $is_open, $sys_user_id)
+    {
+        $command = ['command' => 'KEYBRD', 'content_arr' => ['command' => 'KEYBRD', 'is_open' => $is_open]];
+        $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
+    }
 }

+ 5 - 0
application/common/server/SouhuanAnalysis.php

@@ -479,6 +479,11 @@ class SouhuanAnalysis
                 'content' => null,
                 'kind' => 'tback',
             ],
+            'KEYBRD' => [
+                'analysis_digit' => null,
+                'content' => null,
+                'kind' => 'tback',
+            ],
         ];
         if (!isset($data[$command])) {
             return false;

+ 1 - 0
application/workerman/ShTcp.php

@@ -135,6 +135,7 @@ class ShTcp extends Server
                 Log::write($e->getMessage(), 'shouhuan');
                 Log::write($e->getTraceAsString(), 'shouhuan');
                 var_dump($e->getMessage());
+                var_dump($e->getTraceAsString());
             }
         }
     }