12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040 |
- <?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";
- $commandxy = "DW";
- //仅创建
- 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;
- }
- return false;
- }
- public function createsendmsg2($facility_id, $device_id_code, $data)
- {
- $command = $data['command'];
- $infoarr = $this->getsendcommandinfo($command);
- //$commandxy = "3G";
- $commandxy = "DW";
- if (!$infoarr) {
- // Log::write("无对应命令数据1:" . $command, 'shouhuan');
- // Log::write($data, 'shouhuan');
- //return false;
- $msgdata = [
- 0 => $commandxy,
- 'device_id_code' => $device_id_code,
- 'len' => str_pad(strtoupper(dechex(mb_strlen($command))), 4, "0", STR_PAD_LEFT),
- 'content' => $command,
- ];
- $msg = '[' . implode('*', $msgdata) . ']';
- return $msg;
- }
- $content_arr = $data['content_arr'];
- $config = $infoarr;
- $m_ssl = new ShsendlistModel();
- if ('back' == $config['kind']) {
- $content = $config['content'];
- $content = $content['command'];
- $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' => 1,
- 'send_type' => 0,
- 'sys_user_id' => 0,
- ];
- $sslid = $m_ssl->insertData($sslInsertData);
- if (empty($sslid)) {
- throw new \Exception("发送数据添加失败");
- }
- return $msg;
- }
- return false;
- }
- /**
- * 获取回复权重
- *
- * @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':
- case 'CALL':
- case 'KEYBRD':
- $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' => 'PHL',
- ],
- '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,
- ],
- //拨打电话
- 'CALL' => [
- 'content' => [
- 'command' => 'CALL',
- 'telno' => '',
- ],
- 'kind' => 'send',
- 'need_back' => 1,
- ],
- 'KEYBRD' => [
- 'content' => [
- 'command' => 'KEYBRD',
- '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',
- ],
- 'TKQ' => [
- 'content' => [
- 'command' => 'TKQ',
- ],
- 'kind' => 'back',
- ],
- 'WG' => [
- 'content' => [
- 'command' => 'WG',
- ],
- 'kind' => 'back',
- ],
- 'UD2' => [
- 'content' => [
- 'command' => 'UD2',
- ],
- '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("SOS未设置电话");
- }
- if (count($param) > 3) {
- throw new \Exception("SOS设置电话数量过多");
- }
- 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 getPHLCommandinfo($param)
- {
- if (empty($param)) {
- throw new \Exception("PHL无设置参数");
- }
- if (count($param) > 50) {
- 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 (empty($param)) {
- throw new \Exception("REMIND参数错误");
- }
- $usedata = [];
- foreach ($param as $key => $value) {
- if (3 > count($value)) {
- throw new \Exception("REMINDC参数错误");
- }
- $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 = '3-' . $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 (empty($param)) {
- throw new \Exception("SILENCETIME2参数错误");
- }
- $usedata = [];
- foreach ($param as $key => $value) {
- if (4 > count($value)) {
- throw new \Exception("SILENCETIME2参数错误");
- }
- $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, $param, $sys_user_id)
- {
- $command = ['command' => 'FALLDOWN', 'content_arr' => ['command' => 'FALLDOWN', 'is_open' => $param['is_open']]];
- $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
- $lssetparam = [];
- switch ($param['lsset_type']) {
- case '1':
- $lssetparam = [3, 6];
- break;
- case '2':
- $lssetparam = [6, 9];
- break;
- case '3':
- $lssetparam = [9, 12];
- break;
- }
- $command = ['command' => 'LSSET', 'content_arr' => ['command' => 'LSSET']];
- $this->createsendmsg($facility_id, $device_id_code, $command, $lssetparam, $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', 'content_arr' => ['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', 'content_arr' => ['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)
- {
- $param = array_filter($param);
- $command = ['command' => 'SOS', 'content_arr' => ['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)
- {
- $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'];
- $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)
- {
- Log::write($param, 'shouhuan');
- $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', 'content_arr' => ['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)
- {
- Log::write($param, 'shouhuan');
- $command = ['command' => 'REMIND', 'content_arr' => ['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)
- {
- Log::write($param, 'shouhuan');
- $command = ['command' => 'SILENCETIME2', 'content_arr' => ['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 = 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 = [
- 'command' => 'BOOTOFF',
- 'content_arr' => ['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);
- }
- /**
- * 拨打电话
- *
- * @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);
- }
- /**
- * 拨号盘开关
- *
- * @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);
- }
- }
|