|
@@ -0,0 +1,879 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\common\server;
|
|
|
+
|
|
|
+use app\common\model\FacilityModel;
|
|
|
+use app\common\model\ShsendlistModel;
|
|
|
+use app\common\model\ShsendqueueModel;
|
|
|
+
|
|
|
+//use app\common\server\SouhuanAnalysis;
|
|
|
+
|
|
|
+//use think\facade\Log;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 手环命令创建
|
|
|
+ *
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-01
|
|
|
+ */
|
|
|
+class ShouhuanCommand
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 获取设备信息
|
|
|
+ *
|
|
|
+ * @param [type] $facility_id
|
|
|
+ * @param [type] $device_id_code
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-01
|
|
|
+ */
|
|
|
+ private function getfacilityinfo($facility_id, $device_id_code)
|
|
|
+ {
|
|
|
+ $m_f = new FacilityModel();
|
|
|
+ $fwhere = [
|
|
|
+ 'id' => $facility_id,
|
|
|
+ 'code' => $device_id_code,
|
|
|
+ 'kind' => 1,
|
|
|
+ 'status' => 1,
|
|
|
+ ];
|
|
|
+ $finfo = $m_f->getInfo($fwhere);
|
|
|
+ if (!$finfo) {
|
|
|
+ throw new \Exception("无对应信息:" . $facility_id . "-" . $device_id_code);
|
|
|
+ }
|
|
|
+ return $finfo;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 创建发送信息
|
|
|
+ *
|
|
|
+ * @param [type] $data
|
|
|
+ * @param [type] $command
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-14
|
|
|
+ * $data =['command'=>'','content_arr'=>[],]
|
|
|
+ */
|
|
|
+ public function createsendmsg($facility_id, $device_id_code, $data, $param = [], $sys_user_id = 0)
|
|
|
+ {
|
|
|
+ $command = $data['command'];
|
|
|
+ $infoarr = $this->getsendcommandinfo($command);
|
|
|
+ if (!$infoarr) {
|
|
|
+ // Log::write("无对应命令数据1:" . $command, 'shouhuan');
|
|
|
+ // Log::write($data, 'shouhuan');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $content_arr = $data['content_arr'];
|
|
|
+ $config = $infoarr;
|
|
|
+ $m_ssl = new ShsendlistModel();
|
|
|
+ $commandxy = "3G";
|
|
|
+ //仅创建
|
|
|
+ if ($command == 'AL') {
|
|
|
+ $msg_type = 1;
|
|
|
+ } else {
|
|
|
+ $msg_type = 0;
|
|
|
+ }
|
|
|
+ if ('back' == $config['kind']) {
|
|
|
+ $content = $config['content'];
|
|
|
+ $content = implode(',', $content);
|
|
|
+ $send_type = 0;
|
|
|
+ $is_success = 1;
|
|
|
+ }
|
|
|
+ if ('send' == $config['kind']) {
|
|
|
+ $content = $config['content'];
|
|
|
+ $useconmmand = $content['command'];
|
|
|
+ $content_custom = isset($config['content_custom']) ? $config['content_custom'] : false;
|
|
|
+ $need_back = $config['need_back'];
|
|
|
+ if ($content_custom) {
|
|
|
+ $functionname = 'get' . $command . "Commandinfo";
|
|
|
+ if (method_exists($this, $functionname)) {
|
|
|
+ $content = $useconmmand . "," . $this->$functionname($param);
|
|
|
+ } else {
|
|
|
+ throw new \Exception($command . "自定义方法不存在");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $content = implode(',', $content_arr);
|
|
|
+ }
|
|
|
+ $send_type = 1;
|
|
|
+ if ($need_back) {
|
|
|
+ $is_success = 0;
|
|
|
+ } else {
|
|
|
+ $is_success = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ $weight = $this->getsendweight($command);
|
|
|
+ $msgdata = [
|
|
|
+ 0 => $commandxy,
|
|
|
+ 'device_id_code' => $device_id_code,
|
|
|
+ 'len' => str_pad(strtoupper(dechex(mb_strlen($content))), 4, "0", STR_PAD_LEFT),
|
|
|
+ 'content' => $content,
|
|
|
+ ];
|
|
|
+ $msg = '[' . implode('*', $msgdata) . ']';
|
|
|
+ $sslInsertData = [
|
|
|
+ 'facility_id' => $facility_id,
|
|
|
+ 'device_id_code' => $device_id_code,
|
|
|
+ 'command' => $command,
|
|
|
+ 'send_msg' => $msg,
|
|
|
+ 'send_weight' => $weight,
|
|
|
+ 'send_time' => date('Y-m-d H:i:s'),
|
|
|
+ 'is_success' => $is_success,
|
|
|
+ 'send_type' => $send_type,
|
|
|
+ 'sys_user_id' => $sys_user_id,
|
|
|
+ ];
|
|
|
+ $sslid = $m_ssl->insertData($sslInsertData);
|
|
|
+ if (empty($sslid)) {
|
|
|
+ throw new \Exception("发送数据添加失败");
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'msg' => $msg,
|
|
|
+ 'weight' => $weight,
|
|
|
+ 'createtime' => date('Y-m-d H:i:s'),
|
|
|
+ 'facility_id' => $facility_id,
|
|
|
+ 'device_id_code' => $device_id_code,
|
|
|
+ 'send_list_id' => $sslid,
|
|
|
+ 'msg_type' => $msg_type,
|
|
|
+ ];
|
|
|
+ $m_ssq = new ShsendqueueModel();
|
|
|
+ $id = $m_ssq->insertData($data);
|
|
|
+ if (empty($id)) {
|
|
|
+ throw new \Exception("发送队列数据添加失败");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取回复权重
|
|
|
+ *
|
|
|
+ * @param [type] $command
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-11
|
|
|
+ */
|
|
|
+ public function getsendweight($command)
|
|
|
+ {
|
|
|
+ $weight = -1;
|
|
|
+ switch ($command) {
|
|
|
+ case 'POWEROFF':
|
|
|
+ //关机
|
|
|
+ $weight = 99;
|
|
|
+ break;
|
|
|
+ case 'RESET':
|
|
|
+ //重启
|
|
|
+ $weight = 98; //硬件未测试
|
|
|
+ break;
|
|
|
+ //平台回复命令
|
|
|
+ case 'AL':
|
|
|
+ case 'KA':
|
|
|
+ case 'LK':
|
|
|
+ case 'PING':
|
|
|
+ case 'BPHRT':
|
|
|
+ case 'TEMP':
|
|
|
+ case 'HEART':
|
|
|
+ case 'BLOOD':
|
|
|
+ case 'OXYGEN':
|
|
|
+ $weight = 1;
|
|
|
+ break;
|
|
|
+ //平台发送命令
|
|
|
+ case 'ZONE':
|
|
|
+ case 'UPLOAD':
|
|
|
+ case 'CR':
|
|
|
+ case 'SLEEPTIME':
|
|
|
+ case 'FALLDOWN':
|
|
|
+ case 'FACTORY':
|
|
|
+ case 'SOS':
|
|
|
+ case 'VERNO':
|
|
|
+ case 'LOWBAT':
|
|
|
+ case 'POWEROFF':
|
|
|
+ case 'LSSET':
|
|
|
+ case 'PEDO':
|
|
|
+ case 'PHL':
|
|
|
+ case 'REMIND':
|
|
|
+ case 'SILENCETIME2':
|
|
|
+ case 'BOOTOFF':
|
|
|
+ case 'REMOVE':
|
|
|
+ $weight = 0;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $weight = -1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if ($weight < 0) {
|
|
|
+ //不需设置 发送信息
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return $weight;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取平台发送命令信息
|
|
|
+ *
|
|
|
+ * @param [type] $command
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-11
|
|
|
+ */
|
|
|
+ public function getsendcommandinfo($command)
|
|
|
+ {
|
|
|
+ $command = strtoupper($command);
|
|
|
+ $data = [
|
|
|
+ //平台发送
|
|
|
+ //时区
|
|
|
+ 'ZONE' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'ZONE',
|
|
|
+ 'zone' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ //位置发送间隔
|
|
|
+ 'UPLOAD' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'UPLOAD',
|
|
|
+ 'interval' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ //心率上传间隔
|
|
|
+ 'HRTSTART' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'hrtstart',
|
|
|
+ 'interval' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ //体温上传间隔
|
|
|
+ 'WDSTART' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'wdstart',
|
|
|
+ 'interval' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ //血压上传频率
|
|
|
+ 'BLDSTART' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'bldstart',
|
|
|
+ 'interval' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ //血氧上传频率
|
|
|
+ 'OXSTART' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'oxstart',
|
|
|
+ 'interval' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+
|
|
|
+ //立即定位
|
|
|
+ 'CR' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'CR',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'SLEEPTIME' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'CR',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'content_custom' => true,
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'FALLDOWN' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'FALLDOWN',
|
|
|
+ 'is_open' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'FACTORY' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'FACTORY',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'SOS' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'SOS',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'content_custom' => true,
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'VERNO' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'VERNO',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'LOWBAT' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'LOWBAT',
|
|
|
+ 'is_open' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'POWEROFF' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'POWEROFF',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'LSSET' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'LSSET',
|
|
|
+ 'content_custom' => true,
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'PEDO' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'PEDO',
|
|
|
+ 'is_open' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'PHL' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'PEDO',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'content_custom' => true,
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'REMIND' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'REMIND',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'content_custom' => true,
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'SILENCETIME2' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'SILENCETIME2',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'content_custom' => true,
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'BOOTOFF' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'BOOTOFF',
|
|
|
+ 'is_open' => '',
|
|
|
+ 'bootup_time' => '',
|
|
|
+ 'shutdown_time' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ 'REMOVE' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'REMOVE',
|
|
|
+ 'is_open' => '',
|
|
|
+ ],
|
|
|
+ 'kind' => 'send',
|
|
|
+ 'need_back' => 1,
|
|
|
+ ],
|
|
|
+ //平台回复
|
|
|
+ 'LK' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'LK',
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ 'PING' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'PING',
|
|
|
+ 'isbind' => 1,
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ 'KA' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'KA',
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ 'TEMP' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'temp',
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ 'BPHRT' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'bphrt',
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ 'HEART' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'heart',
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ 'BLOOD' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'blood',
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ 'OXYGEN' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'oxygen',
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ 'AL' => [
|
|
|
+ 'content' => [
|
|
|
+ 'command' => 'AL',
|
|
|
+ ],
|
|
|
+ 'kind' => 'back',
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ if (!isset($data[$command])) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return $data[$command];
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 创建sos电话设置命令
|
|
|
+ * 最多三个电话
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-21
|
|
|
+ */
|
|
|
+ public function getSOSCommandinfo($param)
|
|
|
+ {
|
|
|
+ if (count($param) <= 0) {
|
|
|
+ throw new \Exception("未设置电话");
|
|
|
+
|
|
|
+ }
|
|
|
+ if (count($param) > 3) {
|
|
|
+ throw new \Exception("设置电话数量过多");
|
|
|
+
|
|
|
+ }
|
|
|
+ foreach ($param as $key => $value) {
|
|
|
+ //判断是否为手机号
|
|
|
+ //暂不处理
|
|
|
+ }
|
|
|
+ $info = implode(",", $param);
|
|
|
+ return $info;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 设置跌倒灵敏度命令
|
|
|
+ * [3G*358800006072996*0009*LSSET,3+6]
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-21
|
|
|
+ */
|
|
|
+ public function getLSSETCommandinfo($param)
|
|
|
+ {
|
|
|
+ if (2 != count($param)) {
|
|
|
+ throw new \Exception("LSSET参数错误");
|
|
|
+ }
|
|
|
+ foreach ($param as $key => $value) {
|
|
|
+ if (!is_numeric($value)) {
|
|
|
+ throw new \Exception("LSSET参数错误:" . $value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $info = $param[0] . "+" . $param[1];
|
|
|
+ return $info;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 设置电话本
|
|
|
+ * 最多10条
|
|
|
+ *[{telno=>'',name=>''}]
|
|
|
+ * @param [type] $param
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-21
|
|
|
+ */
|
|
|
+ public function getPHLCommaninfo($param)
|
|
|
+ {
|
|
|
+ if (50 < count($param)) {
|
|
|
+ throw new \Exception("PHL参数错误");
|
|
|
+ }
|
|
|
+ if (0 != count($param) % 2) {
|
|
|
+ throw new \Exception("PHL参数长度错误");
|
|
|
+ }
|
|
|
+ $usedata = [];
|
|
|
+ foreach ($param as $key => $value) {
|
|
|
+ $telno = $value['telno'];
|
|
|
+ $name = $value['name'];
|
|
|
+ //电话号码
|
|
|
+ if (20 < mb_strlen($telno)) {
|
|
|
+ throw new \Exception("PHL电话号码错误:" . $telno);
|
|
|
+ }
|
|
|
+ $name = $this->srtingToUnicode($name);
|
|
|
+ $usedata[] = $telno;
|
|
|
+ $usedata[] = $name;
|
|
|
+ }
|
|
|
+ $info = implode(",", $usedata);
|
|
|
+ return $info;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 设置电话本
|
|
|
+ * 最多10条
|
|
|
+ *{[time=>'',isopen=>'','type'=>'','weeks'=>[]]}
|
|
|
+ * weeks 数组 每个1到7 周日到周六
|
|
|
+ * 最多设置三个
|
|
|
+ * @param [type] $param
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-21
|
|
|
+ */
|
|
|
+ /*
|
|
|
+ 08:10-1-1:闹钟时间 8:10,打开,响铃一次
|
|
|
+ 08:10-1-2:闹钟时间 8:10,打开,每天响铃
|
|
|
+ 08:10-1-3-0111110:闹钟时间 8:10,打开,自定义周一至周五打开
|
|
|
+ 最左边是周日,最右边是周六,即 0111110 的顺序是:周日,周一,周二,周三,周四,周五,周
|
|
|
+ 六(1 为打开,0 为关闭),其中周一至周五打开闹钟
|
|
|
+ */
|
|
|
+ public function getREMINDCommandinfo($param)
|
|
|
+ {
|
|
|
+ if (3 > count($param)) {
|
|
|
+ throw new \Exception("PHL参数错误");
|
|
|
+ }
|
|
|
+ $usedata = [];
|
|
|
+ foreach ($param as $key => $value) {
|
|
|
+ $useweeks = ["0", "0", "0", "0", "0", "0", "0"];
|
|
|
+ $time = $this->formattime($value['time'], 'H:i');
|
|
|
+ $isopen = $value['isopen'];
|
|
|
+ $type = $value['type'];
|
|
|
+ $weeks = $value['weeks'];
|
|
|
+ if (3 == $type) {
|
|
|
+ foreach ($weeks as $wkey => $wvalue) {
|
|
|
+ if ($wvalue >= 1 && $wvalue <= 7) {
|
|
|
+ $useweeks[$wvalue - 1] = '1';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $useweeks = implode("", $useweeks);
|
|
|
+ $type = $useweeks;
|
|
|
+ }
|
|
|
+ $usedata[] = $time . "-" . $isopen . "-" . $type;
|
|
|
+ }
|
|
|
+ $usedata = implode(",", $usedata);
|
|
|
+ return $usedata;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 静默时间段测试
|
|
|
+ *{[starttime=>'',endtime=>'',isopen=>'',weeks=>[]]}
|
|
|
+ * weeks 数组 每个1到7 周日到周六
|
|
|
+ * 最多设置三个
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-21
|
|
|
+ */
|
|
|
+ /*
|
|
|
+ [DW*334588000000156*0038*SILENCETIME2,7:30-21:10-1-0111110,7:30-21:10-1-0111110,7:
|
|
|
+ 30-21:10-0-0111110]
|
|
|
+ 设置上课禁用时间段范围,拦截终端的任何来电。格式为“起始时间-结束时间-自定义星期几”, 比
|
|
|
+ 如上面的 7:30-21:00-0111110,则表示周一到周五 7:30 到 21:00 之间上课禁用生效,起始时间
|
|
|
+ 默认大于结束时间。
|
|
|
+ 总开关:0 为关,1 为开
|
|
|
+ 关于自定义星期几的规则:最左边是周日,最右边是周六,即 0111110 的顺序是:周日,周一,周
|
|
|
+ 二,周三,周四,周五,周六(1 为打开,0 为关闭),所以上面的意思是周一至周五打开上课禁
|
|
|
+ 用。
|
|
|
+ */
|
|
|
+ public function getSILENCETIME2Commandinfo($param)
|
|
|
+ {
|
|
|
+ if (3 <= count($param)) {
|
|
|
+ throw new \Exception("SILENCETIME2参数错误");
|
|
|
+ }
|
|
|
+ $usedata = [];
|
|
|
+ foreach ($param as $key => $value) {
|
|
|
+ $useweeks = ["0", "0", "0", "0", "0", "0", "0"];
|
|
|
+ //未比较时间大小
|
|
|
+ $starttime = $this->formattime($value['starttime'], 'H:i');
|
|
|
+ $endtime = $this->formattime($value['endtime'], 'H:i');
|
|
|
+ $isopen = $value['isopen'];
|
|
|
+ $weeks = $value['weeks'];
|
|
|
+ foreach ($weeks as $wkey => $wvalue) {
|
|
|
+ if ($wvalue >= 1 && $wvalue <= 7) {
|
|
|
+ $useweeks[$wvalue - 1] = '1';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $useweeks = implode("", $useweeks);
|
|
|
+ $usedata[] = $starttime . "-" . $endtime . "-" . $isopen . "-" . $useweeks;
|
|
|
+ }
|
|
|
+ $usedata = implode(",", $usedata);
|
|
|
+ return $usedata;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 睡眠时间段设置
|
|
|
+ *{starttime=>'',endtime=>''}
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-21
|
|
|
+ */
|
|
|
+ public function getSLEEPTIMECommandinfo($param)
|
|
|
+ {
|
|
|
+ if (2 > count($param)) {
|
|
|
+ throw new \Exception("SLEEPTIME参数错误");
|
|
|
+ }
|
|
|
+ $starttime = $this->formattime($param['starttime'], 'H:i');
|
|
|
+ $endtime = $this->formattime($param['endtime'], 'H:i');
|
|
|
+ $usedata = $starttime . "-" . $endtime;
|
|
|
+ return $usedata;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function formattime($time, $format)
|
|
|
+ {
|
|
|
+ $time = strtotime($time);
|
|
|
+ $time = date($format, $time);
|
|
|
+ return $time;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * unicode 编码
|
|
|
+ *
|
|
|
+ * @param [type] $str
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-21
|
|
|
+ */
|
|
|
+ public function srtingToUnicode($str)
|
|
|
+ {
|
|
|
+ $unicode = '';
|
|
|
+ $arr = mb_str_split($str); //适配中文
|
|
|
+ foreach ($arr as $key => $value) {
|
|
|
+ $char = bin2hex(iconv('UTF-8', 'UCS-2BE', $value));
|
|
|
+ $char = str_pad($char, 4, '0', STR_PAD_LEFT);
|
|
|
+ $arr[$key] = $char;
|
|
|
+ }
|
|
|
+ $unicode = implode("", $arr);
|
|
|
+ return $unicode;
|
|
|
+ }
|
|
|
+ //设置 低电报警开关
|
|
|
+ public function createlowbatcommand($facility_id, $device_id_code, $is_open, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'LOWBAT', 'content_arr' => ['command' => 'LOWBAT', 'is_open' => $is_open]];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
|
|
|
+ }
|
|
|
+ //设置 跌倒报警开关
|
|
|
+ public function createfalldowncommand($facility_id, $device_id_code, $is_open, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'FALLDOWN', 'content_arr' => ['command' => 'FALLDOWN', 'is_open' => $is_open]];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 睡眠时间段设置
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-29
|
|
|
+ */
|
|
|
+ public function createsleeptimecommand($facility_id, $device_id_code, $param, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'SLEEPTIME'];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 立即定位
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-29
|
|
|
+ */
|
|
|
+ public function createcrcommand($facility_id, $device_id_code, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'CR'];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 设置警报电话
|
|
|
+ *
|
|
|
+ * @param [type] $facility_id
|
|
|
+ * @param [type] $device_id_code
|
|
|
+ * @param [type] $param
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-29
|
|
|
+ */
|
|
|
+ public function createsoscommand($facility_id, $device_id_code, $param, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'SOS'];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 设置电话本
|
|
|
+ *
|
|
|
+ * @param [type] $arr
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-08-29
|
|
|
+ */
|
|
|
+ public function createphlcommand($facility_id, $device_id_code, $param, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['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)
|
|
|
+ {
|
|
|
+ $zone = $param['zone'];
|
|
|
+ $upload_interval = $param['upload_interval'];
|
|
|
+ $fd_is_open = $param['fd_is_open'];
|
|
|
+ $lowbat_is_open = $param['lowbat_is_open'];
|
|
|
+ $pedo_is_open = $param['pedo_is_open'];
|
|
|
+ $remove_is_open = $param['remove_is_open'];
|
|
|
+ $commandlist = [
|
|
|
+ ['command' => 'ZONE', 'content_arr' => ['command' => 'ZONE', 'zone' => $zone]],
|
|
|
+ ['command' => 'UPLOAD', 'content_arr' => ['command' => 'UPLOAD', 'interval' => $upload_interval]],
|
|
|
+ ['command' => 'CR', 'content_arr' => ['command' => 'CR']],
|
|
|
+ ['command' => 'FALLDOWN', 'content_arr' => ['command' => 'FALLDOWN', 'is_open' => $fd_is_open]],
|
|
|
+ ['command' => 'VERNO', 'content_arr' => ['command' => 'VERNO']],
|
|
|
+ ['command' => 'LOWBAT', 'content_arr' => ['command' => 'LOWBAT', 'is_open' => $lowbat_is_open]],
|
|
|
+ ['command' => 'PEDO', 'content_arr' => ['command' => 'PEDO', 'is_open' => $pedo_is_open]],
|
|
|
+ ['command' => 'REMOVE', 'content_arr' => ['command' => 'REMOVE', 'is_open' => $remove_is_open]],
|
|
|
+ ];
|
|
|
+ foreach ($commandlist as $key => $value) {
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $value, [], $sys_user_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 数据间隔设置
|
|
|
+ * 位置 心率 体温 血压 血氧
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-01
|
|
|
+ */
|
|
|
+ public function setdatainterval($facility_id, $device_id_code, $param = [], $sys_user_id)
|
|
|
+ {
|
|
|
+ $cr_interval = $param['cr_interval'];
|
|
|
+ $hrt_interval = $param['hrt_interval'];
|
|
|
+ $wd_interval = $param['wd_interval'];
|
|
|
+ $bld_interval = $param['bld_interval'];
|
|
|
+ $ox_interval = $param['ox_interval'];
|
|
|
+
|
|
|
+ $commandlist = [
|
|
|
+ ['command' => 'UPLOAD', 'content_arr' => ['command' => 'UPLOAD', 'interval' => $cr_interval]],
|
|
|
+ ['command' => 'HRTSTART', 'content_arr' => ['command' => 'HRTSTART', 'interval' => $hrt_interval]],
|
|
|
+ ['command' => 'WDSTART', 'content_arr' => ['command' => 'WDSTART', 'interval' => $wd_interval]],
|
|
|
+ ['command' => 'BLDSTART', 'content_arr' => ['command' => 'BLDSTART', 'interval' => $bld_interval]],
|
|
|
+ ['command' => 'OXSTART', 'content_arr' => ['command' => 'OXSTART', 'interval' => $ox_interval]],
|
|
|
+ ];
|
|
|
+ foreach ($commandlist as $key => $value) {
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $value, $sys_user_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 关机
|
|
|
+ *
|
|
|
+ * @param [type] $facility_id
|
|
|
+ * @param [type] $device_id_code
|
|
|
+ * @param [type] $sys_user_id
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-05
|
|
|
+ */
|
|
|
+ public function createpoweroffcommand($facility_id, $device_id_code, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'POWEROFF'];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 计步开关
|
|
|
+ *
|
|
|
+ * @param [type] $facility_id
|
|
|
+ * @param [type] $device_id_code
|
|
|
+ * @param [type] $sys_user_id
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-05
|
|
|
+ */
|
|
|
+ public function createpedocommand($facility_id, $device_id_code, $is_open, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'PEDO', 'content_arr' => ['command' => 'PEDO', '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] $param
|
|
|
+ * @param [type] $sys_user_id
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-05
|
|
|
+ */
|
|
|
+ public function createremindcommand($facility_id, $device_id_code, $param, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'REMIND'];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 静默时间
|
|
|
+ *
|
|
|
+ * @param [type] $facility_id
|
|
|
+ * @param [type] $device_id_code
|
|
|
+ * @param [type] $param
|
|
|
+ * @param [type] $sys_user_id
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-05
|
|
|
+ */
|
|
|
+ public function createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'SILENCETIME2'];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 开机关机时间
|
|
|
+ *
|
|
|
+ * @param [type] $facility_id
|
|
|
+ * @param [type] $device_id_code
|
|
|
+ * @param [type] $param
|
|
|
+ * @param [type] $sys_user_id
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-05
|
|
|
+ */
|
|
|
+ public function createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id)
|
|
|
+ {
|
|
|
+ $is_open = $param['is_open'];
|
|
|
+ $bootup_time = $param['bootup_time'];
|
|
|
+ $shutdown_time = $param['shutdown_time'];
|
|
|
+ $command = [
|
|
|
+ 'command' => 'BOOTOFF',
|
|
|
+ 'content' => ['command' => 'BOOTOFF', 'is_open' => $is_open, 'bootup_time' => $bootup_time, 'shutdown_time' => $shutdown_time],
|
|
|
+ ];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 佩戴提醒
|
|
|
+ *
|
|
|
+ * @param [type] $facility_id
|
|
|
+ * @param [type] $device_id_code
|
|
|
+ * @param [type] $param
|
|
|
+ * @param [type] $sys_user_id
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2023-09-05
|
|
|
+ */
|
|
|
+ public function createremovecommand($facility_id, $device_id_code, $is_open, $sys_user_id)
|
|
|
+ {
|
|
|
+ $command = ['command' => 'REMOVE', 'content_arr' => ['command' => 'REMOVE', 'is_open' => $is_open]];
|
|
|
+ $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
|
|
|
+ }
|
|
|
+}
|