wang jun 1 year ago
parent
commit
32e4e2e95f

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

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

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

@@ -303,4 +303,25 @@ class Shouhuanlogic
         $s_sc->createpedocommand($facility_id, $device_id_code, $is_open, $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-15
+     */
+    public function createcallcommand($facility_id, $device_id_code, $param, $sys_user_id)
+    {
+        if (!isset($param['telno']) || empty($param['telno'])) {
+            throw new \Exception("参数错误");
+        }
+        $telno = $param['telno'];
+        $s_sc = new ShouhuanCommand();
+        $s_sc->createcallcommand($facility_id, $device_id_code, $telno, $sys_user_id);
+        return backarr(1, "操作成功");
+    }
 }

+ 41 - 4
application/common/server/ShouhuanCommand.php

@@ -8,7 +8,7 @@ use app\common\model\ShsendqueueModel;
 
 //use app\common\server\SouhuanAnalysis;
 
-//use think\facade\Log;
+use think\facade\Log;
 
 /**
  * 手环命令创建
@@ -63,6 +63,7 @@ class ShouhuanCommand
         }
         $content_arr = $data['content_arr'];
         $config = $infoarr;
+
         $m_ssl = new ShsendlistModel();
         $commandxy = "3G";
         //仅创建
@@ -189,6 +190,7 @@ class ShouhuanCommand
             case 'SILENCETIME2':
             case 'BOOTOFF':
             case 'REMOVE':
+            case 'CALL':
                 $weight = 0;
                 break;
             default:
@@ -388,6 +390,15 @@ class ShouhuanCommand
                 'kind' => 'send',
                 'need_back' => 1,
             ],
+            //拨打电话
+            'CALL' => [
+                'content' => [
+                    'command' => 'CALL',
+                    'telno' => '',
+                ],
+                'kind' => 'send',
+                'need_back' => 1,
+            ],
             //平台回复
             'LK' => [
                 'content' => [
@@ -461,11 +472,11 @@ class ShouhuanCommand
     public function getSOSCommandinfo($param)
     {
         if (count($param) <= 0) {
-            throw new \Exception("未设置电话");
+            throw new \Exception("SOS未设置电话");
 
         }
         if (count($param) > 3) {
-            throw new \Exception("设置电话数量过多");
+            throw new \Exception("SOS设置电话数量过多");
 
         }
         foreach ($param as $key => $value) {
@@ -507,7 +518,10 @@ class ShouhuanCommand
      */
     public function getPHLCommandinfo($param)
     {
-        if (50 < count($param)) {
+        if (empty($param)) {
+            throw new \Exception("PHL无设置参数");
+        }
+        if (count($param) > 50) {
             throw new \Exception("PHL参数错误");
         }
         $usedata = [];
@@ -728,6 +742,7 @@ class ShouhuanCommand
      */
     public function createsoscommand($facility_id, $device_id_code, $param, $sys_user_id)
     {
+        $param = array_filter($param);
         $command = ['command' => 'SOS', 'content_arr' => ['command' => 'SOS']];
         $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
     }
@@ -741,12 +756,14 @@ class ShouhuanCommand
      */
     public function createphlcommand($facility_id, $device_id_code, $param, $sys_user_id)
     {
+        $param = array_filter($param);
         $command = ['command' => 'PHL', 'content_arr' => ['command' => 'PHL']];
         $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
     }
     //设备初始化
     public function facilityinit($facility_id, $device_id_code, $param, $sys_user_id)
     {
+        Log::write($param, 'shouhuan');
         $zone = $param['zone'];
         $upload_interval = $param['upload_interval'];
         $fd_is_open = $param['fd_is_open'];
@@ -777,6 +794,7 @@ class ShouhuanCommand
      */
     public function setdatainterval($facility_id, $device_id_code, $param = [], $sys_user_id)
     {
+        Log::write($param, 'shouhuan');
         $cr_interval = $param['cr_interval'];
         $hrt_interval = $param['hrt_interval'];
         $wd_interval = $param['wd_interval'];
@@ -837,6 +855,7 @@ class ShouhuanCommand
      */
     public function createremindcommand($facility_id, $device_id_code, $param, $sys_user_id)
     {
+        Log::write($param, 'shouhuan');
         $command = ['command' => 'REMIND', 'content_arr' => ['command' => 'REMIND']];
         $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
     }
@@ -853,6 +872,7 @@ class ShouhuanCommand
      */
     public function createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id)
     {
+        Log::write($param, 'shouhuan');
         $command = ['command' => 'SILENCETIME2', 'content_arr' => ['command' => 'SILENCETIME2']];
         $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
     }
@@ -869,6 +889,7 @@ class ShouhuanCommand
      */
     public function createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id)
     {
+        Log::write($param, 'shouhuan');
         $is_open = $param['is_open'];
         $bootup_time = $param['bootup_time'];
         $shutdown_time = $param['shutdown_time'];
@@ -894,4 +915,20 @@ class ShouhuanCommand
         $command = ['command' => 'REMOVE', 'content_arr' => ['command' => 'REMOVE', 'is_open' => $is_open]];
         $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-15
+     */
+    public function createcallcommand($facility_id, $device_id_code, $telno, $sys_user_id)
+    {
+        $command = ['command' => 'CALL', 'content_arr' => ['command' => 'CALL', 'telno' => $telno]];
+        $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
+    }
 }

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

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

+ 2 - 1
application/workerman/ShTcp.php

@@ -73,7 +73,8 @@ class ShTcp extends Server
                         $content = $linedata['content_arr'];
                         $fid = $server_sa->getfacilityid($device_id_code);
                         $result = $server_sa->saveshinfo($fid, $device_id_code, $linedata, $value);
-                        if ($result) {
+                        $config = $linedata['config'];
+                        if ($result && 'tsend' == $config['kind']) {
                             $data = $server_sc->createsendmsg($fid, $device_id_code, $linedata);
                         }
                         $server_sa->receivemsgsuccess($value);