ShouhuanCommand.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. <?php
  2. namespace app\common\server;
  3. use app\common\model\FacilityModel;
  4. use app\common\model\ShsendlistModel;
  5. use app\common\model\ShsendqueueModel;
  6. //use app\common\server\SouhuanAnalysis;
  7. use think\facade\Log;
  8. /**
  9. * 手环命令创建
  10. *
  11. * @author wj
  12. * @date 2023-09-01
  13. */
  14. class ShouhuanCommand
  15. {
  16. /**
  17. * 获取设备信息
  18. *
  19. * @param [type] $facility_id
  20. * @param [type] $device_id_code
  21. * @return void
  22. * @author wj
  23. * @date 2023-09-01
  24. */
  25. private function getfacilityinfo($facility_id, $device_id_code)
  26. {
  27. $m_f = new FacilityModel();
  28. $fwhere = [
  29. 'id' => $facility_id,
  30. 'code' => $device_id_code,
  31. 'kind' => 1,
  32. 'status' => 1,
  33. ];
  34. $finfo = $m_f->getInfo($fwhere);
  35. if (!$finfo) {
  36. throw new \Exception("无对应信息:" . $facility_id . "-" . $device_id_code);
  37. }
  38. return $finfo;
  39. }
  40. /**
  41. * 创建发送信息
  42. *
  43. * @param [type] $data
  44. * @param [type] $command
  45. * @return void
  46. * @author wj
  47. * @date 2023-08-14
  48. * $data =['command'=>'','content_arr'=>[],]
  49. */
  50. public function createsendmsg($facility_id, $device_id_code, $data, $param = [], $sys_user_id = 0)
  51. {
  52. $command = $data['command'];
  53. $infoarr = $this->getsendcommandinfo($command);
  54. if (!$infoarr) {
  55. // Log::write("无对应命令数据1:" . $command, 'shouhuan');
  56. // Log::write($data, 'shouhuan');
  57. return false;
  58. }
  59. $content_arr = $data['content_arr'];
  60. $config = $infoarr;
  61. $m_ssl = new ShsendlistModel();
  62. $commandxy = "3G";
  63. //仅创建
  64. if ($command == 'AL') {
  65. $msg_type = 1;
  66. } else {
  67. $msg_type = 0;
  68. }
  69. if ('back' == $config['kind']) {
  70. $content = $config['content'];
  71. $content = implode(',', $content);
  72. $send_type = 0;
  73. $is_success = 1;
  74. }
  75. if ('send' == $config['kind']) {
  76. $content = $config['content'];
  77. $useconmmand = $content['command'];
  78. $content_custom = isset($config['content_custom']) ? $config['content_custom'] : false;
  79. $need_back = $config['need_back'];
  80. if ($content_custom) {
  81. $functionname = 'get' . $command . "Commandinfo";
  82. if (method_exists($this, $functionname)) {
  83. $content = $useconmmand . "," . $this->$functionname($param);
  84. } else {
  85. throw new \Exception($command . "自定义方法不存在");
  86. }
  87. } else {
  88. $content = implode(',', $content_arr);
  89. }
  90. $send_type = 1;
  91. if ($need_back) {
  92. $is_success = 0;
  93. } else {
  94. $is_success = 1;
  95. }
  96. }
  97. $weight = $this->getsendweight($command);
  98. $msgdata = [
  99. 0 => $commandxy,
  100. 'device_id_code' => $device_id_code,
  101. 'len' => str_pad(strtoupper(dechex(mb_strlen($content))), 4, "0", STR_PAD_LEFT),
  102. 'content' => $content,
  103. ];
  104. $msg = '[' . implode('*', $msgdata) . ']';
  105. $sslInsertData = [
  106. 'facility_id' => $facility_id,
  107. 'device_id_code' => $device_id_code,
  108. 'command' => $command,
  109. 'send_msg' => $msg,
  110. 'send_weight' => $weight,
  111. 'send_time' => date('Y-m-d H:i:s'),
  112. 'is_success' => $is_success,
  113. 'send_type' => $send_type,
  114. 'sys_user_id' => $sys_user_id,
  115. ];
  116. $sslid = $m_ssl->insertData($sslInsertData);
  117. if (empty($sslid)) {
  118. throw new \Exception("发送数据添加失败");
  119. }
  120. $data = [
  121. 'msg' => $msg,
  122. 'weight' => $weight,
  123. 'createtime' => date('Y-m-d H:i:s'),
  124. 'facility_id' => $facility_id,
  125. 'device_id_code' => $device_id_code,
  126. 'send_list_id' => $sslid,
  127. 'msg_type' => $msg_type,
  128. ];
  129. $m_ssq = new ShsendqueueModel();
  130. $id = $m_ssq->insertData($data);
  131. if (empty($id)) {
  132. throw new \Exception("发送队列数据添加失败");
  133. }
  134. return true;
  135. }
  136. /**
  137. * 获取回复权重
  138. *
  139. * @param [type] $command
  140. * @return void
  141. * @author wj
  142. * @date 2023-08-11
  143. */
  144. public function getsendweight($command)
  145. {
  146. $weight = -1;
  147. switch ($command) {
  148. case 'POWEROFF':
  149. //关机
  150. $weight = 99;
  151. break;
  152. case 'RESET':
  153. //重启
  154. $weight = 98; //硬件未测试
  155. break;
  156. //平台回复命令
  157. case 'AL':
  158. case 'KA':
  159. case 'LK':
  160. case 'PING':
  161. case 'BPHRT':
  162. case 'TEMP':
  163. case 'HEART':
  164. case 'BLOOD':
  165. case 'OXYGEN':
  166. $weight = 1;
  167. break;
  168. //平台发送命令
  169. case 'ZONE':
  170. case 'UPLOAD':
  171. case 'CR':
  172. case 'SLEEPTIME':
  173. case 'FALLDOWN':
  174. case 'FACTORY':
  175. case 'SOS':
  176. case 'VERNO':
  177. case 'LOWBAT':
  178. case 'POWEROFF':
  179. case 'LSSET':
  180. case 'PEDO':
  181. case 'PHL':
  182. case 'REMIND':
  183. case 'SILENCETIME2':
  184. case 'BOOTOFF':
  185. case 'REMOVE':
  186. case 'CALL':
  187. $weight = 0;
  188. break;
  189. default:
  190. $weight = -1;
  191. break;
  192. }
  193. if ($weight < 0) {
  194. //不需设置 发送信息
  195. return false;
  196. }
  197. return $weight;
  198. }
  199. /**
  200. * 获取平台发送命令信息
  201. *
  202. * @param [type] $command
  203. * @return void
  204. * @author wj
  205. * @date 2023-08-11
  206. */
  207. public function getsendcommandinfo($command)
  208. {
  209. $command = strtoupper($command);
  210. $data = [
  211. //平台发送
  212. //时区
  213. 'ZONE' => [
  214. 'content' => [
  215. 'command' => 'ZONE',
  216. 'zone' => '',
  217. ],
  218. 'kind' => 'send',
  219. 'need_back' => 1,
  220. ],
  221. //位置发送间隔
  222. 'UPLOAD' => [
  223. 'content' => [
  224. 'command' => 'UPLOAD',
  225. 'interval' => '',
  226. ],
  227. 'kind' => 'send',
  228. 'need_back' => 1,
  229. ],
  230. //心率上传间隔
  231. 'HRTSTART' => [
  232. 'content' => [
  233. 'command' => 'hrtstart',
  234. 'interval' => '',
  235. ],
  236. 'kind' => 'send',
  237. 'need_back' => 1,
  238. ],
  239. //体温上传间隔
  240. 'WDSTART' => [
  241. 'content' => [
  242. 'command' => 'wdstart',
  243. 'interval' => '',
  244. ],
  245. 'kind' => 'send',
  246. 'need_back' => 1,
  247. ],
  248. //血压上传频率
  249. 'BLDSTART' => [
  250. 'content' => [
  251. 'command' => 'bldstart',
  252. 'interval' => '',
  253. ],
  254. 'kind' => 'send',
  255. 'need_back' => 1,
  256. ],
  257. //血氧上传频率
  258. 'OXSTART' => [
  259. 'content' => [
  260. 'command' => 'oxstart',
  261. 'interval' => '',
  262. ],
  263. 'kind' => 'send',
  264. 'need_back' => 1,
  265. ],
  266. //立即定位
  267. 'CR' => [
  268. 'content' => [
  269. 'command' => 'CR',
  270. ],
  271. 'kind' => 'send',
  272. 'need_back' => 1,
  273. ],
  274. 'SLEEPTIME' => [
  275. 'content' => [
  276. 'command' => 'CR',
  277. ],
  278. 'kind' => 'send',
  279. 'content_custom' => true,
  280. 'need_back' => 1,
  281. ],
  282. 'FALLDOWN' => [
  283. 'content' => [
  284. 'command' => 'FALLDOWN',
  285. 'is_open' => '',
  286. ],
  287. 'kind' => 'send',
  288. 'need_back' => 1,
  289. ],
  290. 'FACTORY' => [
  291. 'content' => [
  292. 'command' => 'FACTORY',
  293. ],
  294. 'kind' => 'send',
  295. 'need_back' => 1,
  296. ],
  297. 'SOS' => [
  298. 'content' => [
  299. 'command' => 'SOS',
  300. ],
  301. 'kind' => 'send',
  302. 'content_custom' => true,
  303. 'need_back' => 1,
  304. ],
  305. 'VERNO' => [
  306. 'content' => [
  307. 'command' => 'VERNO',
  308. ],
  309. 'kind' => 'send',
  310. 'need_back' => 1,
  311. ],
  312. 'LOWBAT' => [
  313. 'content' => [
  314. 'command' => 'LOWBAT',
  315. 'is_open' => '',
  316. ],
  317. 'kind' => 'send',
  318. 'need_back' => 1,
  319. ],
  320. 'POWEROFF' => [
  321. 'content' => [
  322. 'command' => 'POWEROFF',
  323. ],
  324. 'kind' => 'send',
  325. 'need_back' => 1,
  326. ],
  327. 'LSSET' => [
  328. 'content' => [
  329. 'command' => 'LSSET',
  330. 'content_custom' => true,
  331. ],
  332. 'kind' => 'send',
  333. 'need_back' => 1,
  334. ],
  335. 'PEDO' => [
  336. 'content' => [
  337. 'command' => 'PEDO',
  338. 'is_open' => '',
  339. ],
  340. 'kind' => 'send',
  341. 'need_back' => 1,
  342. ],
  343. 'PHL' => [
  344. 'content' => [
  345. 'command' => 'PHL',
  346. ],
  347. 'kind' => 'send',
  348. 'content_custom' => true,
  349. 'need_back' => 1,
  350. ],
  351. 'REMIND' => [
  352. 'content' => [
  353. 'command' => 'REMIND',
  354. ],
  355. 'kind' => 'send',
  356. 'content_custom' => true,
  357. 'need_back' => 1,
  358. ],
  359. 'SILENCETIME2' => [
  360. 'content' => [
  361. 'command' => 'SILENCETIME2',
  362. ],
  363. 'kind' => 'send',
  364. 'content_custom' => true,
  365. 'need_back' => 1,
  366. ],
  367. 'BOOTOFF' => [
  368. 'content' => [
  369. 'command' => 'BOOTOFF',
  370. 'is_open' => '',
  371. 'bootup_time' => '',
  372. 'shutdown_time' => '',
  373. ],
  374. 'kind' => 'send',
  375. 'need_back' => 1,
  376. ],
  377. 'REMOVE' => [
  378. 'content' => [
  379. 'command' => 'REMOVE',
  380. 'is_open' => '',
  381. ],
  382. 'kind' => 'send',
  383. 'need_back' => 1,
  384. ],
  385. //拨打电话
  386. 'CALL' => [
  387. 'content' => [
  388. 'command' => 'CALL',
  389. 'telno' => '',
  390. ],
  391. 'kind' => 'send',
  392. 'need_back' => 1,
  393. ],
  394. //平台回复
  395. 'LK' => [
  396. 'content' => [
  397. 'command' => 'LK',
  398. ],
  399. 'kind' => 'back',
  400. ],
  401. 'PING' => [
  402. 'content' => [
  403. 'command' => 'PING',
  404. 'isbind' => 1,
  405. ],
  406. 'kind' => 'back',
  407. ],
  408. 'KA' => [
  409. 'content' => [
  410. 'command' => 'KA',
  411. ],
  412. 'kind' => 'back',
  413. ],
  414. 'TEMP' => [
  415. 'content' => [
  416. 'command' => 'temp',
  417. ],
  418. 'kind' => 'back',
  419. ],
  420. 'BPHRT' => [
  421. 'content' => [
  422. 'command' => 'bphrt',
  423. ],
  424. 'kind' => 'back',
  425. ],
  426. 'HEART' => [
  427. 'content' => [
  428. 'command' => 'heart',
  429. ],
  430. 'kind' => 'back',
  431. ],
  432. 'BLOOD' => [
  433. 'content' => [
  434. 'command' => 'blood',
  435. ],
  436. 'kind' => 'back',
  437. ],
  438. 'OXYGEN' => [
  439. 'content' => [
  440. 'command' => 'oxygen',
  441. ],
  442. 'kind' => 'back',
  443. ],
  444. 'AL' => [
  445. 'content' => [
  446. 'command' => 'AL',
  447. ],
  448. 'kind' => 'back',
  449. ],
  450. ];
  451. if (!isset($data[$command])) {
  452. return false;
  453. }
  454. return $data[$command];
  455. }
  456. /**
  457. * 创建sos电话设置命令
  458. * 最多三个电话
  459. *
  460. * @return void
  461. * @author wj
  462. * @date 2023-08-21
  463. */
  464. public function getSOSCommandinfo($param)
  465. {
  466. if (count($param) <= 0) {
  467. throw new \Exception("SOS未设置电话");
  468. }
  469. if (count($param) > 3) {
  470. throw new \Exception("SOS设置电话数量过多");
  471. }
  472. foreach ($param as $key => $value) {
  473. //判断是否为手机号
  474. //暂不处理
  475. }
  476. $info = implode(",", $param);
  477. return $info;
  478. }
  479. /**
  480. * 设置跌倒灵敏度命令
  481. * [3G*358800006072996*0009*LSSET,3+6]
  482. *
  483. * @return void
  484. * @author wj
  485. * @date 2023-08-21
  486. */
  487. public function getLSSETCommandinfo($param)
  488. {
  489. if (2 != count($param)) {
  490. throw new \Exception("LSSET参数错误");
  491. }
  492. foreach ($param as $key => $value) {
  493. if (!is_numeric($value)) {
  494. throw new \Exception("LSSET参数错误:" . $value);
  495. }
  496. }
  497. $info = $param[0] . "+" . $param[1];
  498. return $info;
  499. }
  500. /**
  501. * 设置电话本
  502. * 最多10条
  503. *[{telno=>'',name=>''}]
  504. * @param [type] $param
  505. * @return void
  506. * @author wj
  507. * @date 2023-08-21
  508. */
  509. public function getPHLCommandinfo($param)
  510. {
  511. if (empty($param)) {
  512. throw new \Exception("PHL无设置参数");
  513. }
  514. if (count($param) > 50) {
  515. throw new \Exception("PHL参数错误");
  516. }
  517. $usedata = [];
  518. foreach ($param as $key => $value) {
  519. $telno = $value['telno'];
  520. $name = $value['name'];
  521. //电话号码
  522. if (20 < mb_strlen($telno)) {
  523. throw new \Exception("PHL电话号码错误:" . $telno);
  524. }
  525. $name = $this->srtingToUnicode($name);
  526. $usedata[] = $telno;
  527. $usedata[] = $name;
  528. }
  529. $info = implode(",", $usedata);
  530. return $info;
  531. }
  532. /**
  533. * 设置电话本
  534. * 最多10条
  535. *{[time=>'',isopen=>'','type'=>'','weeks'=>[]]}
  536. * weeks 数组 每个1到7 周日到周六
  537. * 最多设置三个
  538. * @param [type] $param
  539. * @return void
  540. * @author wj
  541. * @date 2023-08-21
  542. */
  543. /*
  544. 08:10-1-1:闹钟时间 8:10,打开,响铃一次
  545. 08:10-1-2:闹钟时间 8:10,打开,每天响铃
  546. 08:10-1-3-0111110:闹钟时间 8:10,打开,自定义周一至周五打开
  547. 最左边是周日,最右边是周六,即 0111110 的顺序是:周日,周一,周二,周三,周四,周五,周
  548. 六(1 为打开,0 为关闭),其中周一至周五打开闹钟
  549. */
  550. public function getREMINDCommandinfo($param)
  551. {
  552. if (empty($param)) {
  553. throw new \Exception("REMINDC参数错误");
  554. }
  555. $usedata = [];
  556. foreach ($param as $key => $value) {
  557. if (3 > count($value)) {
  558. throw new \Exception("REMINDC参数错误");
  559. }
  560. $useweeks = ["0", "0", "0", "0", "0", "0", "0"];
  561. $time = $this->formattime($value['time'], 'H:i');
  562. $isopen = $value['isopen'];
  563. $type = $value['type'];
  564. $weeks = $value['weeks'];
  565. if (3 == $type) {
  566. foreach ($weeks as $wkey => $wvalue) {
  567. if ($wvalue >= 1 && $wvalue <= 7) {
  568. $useweeks[$wvalue - 1] = '1';
  569. }
  570. }
  571. $useweeks = implode("", $useweeks);
  572. $type = $useweeks;
  573. }
  574. $usedata[] = $time . "-" . $isopen . "-" . $type;
  575. }
  576. $usedata = implode(",", $usedata);
  577. return $usedata;
  578. }
  579. /**
  580. * 静默时间段测试
  581. *{[starttime=>'',endtime=>'',isopen=>'',weeks=>[]]}
  582. * weeks 数组 每个1到7 周日到周六
  583. * 最多设置三个
  584. *
  585. * @return void
  586. * @author wj
  587. * @date 2023-08-21
  588. */
  589. /*
  590. [DW*334588000000156*0038*SILENCETIME2,7:30-21:10-1-0111110,7:30-21:10-1-0111110,7:
  591. 30-21:10-0-0111110]
  592. 设置上课禁用时间段范围,拦截终端的任何来电。格式为“起始时间-结束时间-自定义星期几”, 比
  593. 如上面的 7:30-21:00-0111110,则表示周一到周五 7:30 到 21:00 之间上课禁用生效,起始时间
  594. 默认大于结束时间。
  595. 总开关:0 为关,1 为开
  596. 关于自定义星期几的规则:最左边是周日,最右边是周六,即 0111110 的顺序是:周日,周一,周
  597. 二,周三,周四,周五,周六(1 为打开,0 为关闭),所以上面的意思是周一至周五打开上课禁
  598. 用。
  599. */
  600. public function getSILENCETIME2Commandinfo($param)
  601. {
  602. if (empty($param)) {
  603. throw new \Exception("SILENCETIME2参数错误");
  604. }
  605. $usedata = [];
  606. foreach ($param as $key => $value) {
  607. if (4 > count($value)) {
  608. throw new \Exception("SILENCETIME2参数错误");
  609. }
  610. $useweeks = ["0", "0", "0", "0", "0", "0", "0"];
  611. //未比较时间大小
  612. $starttime = $this->formattime($value['starttime'], 'H:i');
  613. $endtime = $this->formattime($value['endtime'], 'H:i');
  614. $isopen = $value['isopen'];
  615. $weeks = $value['weeks'];
  616. foreach ($weeks as $wkey => $wvalue) {
  617. if ($wvalue >= 1 && $wvalue <= 7) {
  618. $useweeks[$wvalue - 1] = '1';
  619. }
  620. }
  621. $useweeks = implode("", $useweeks);
  622. $usedata[] = $starttime . "-" . $endtime . "-" . $isopen . "-" . $useweeks;
  623. }
  624. $usedata = implode(",", $usedata);
  625. return $usedata;
  626. }
  627. /**
  628. * 睡眠时间段设置
  629. *{starttime=>'',endtime=>''}
  630. *
  631. * @return void
  632. * @author wj
  633. * @date 2023-08-21
  634. */
  635. public function getSLEEPTIMECommandinfo($param)
  636. {
  637. if (2 > count($param)) {
  638. throw new \Exception("SLEEPTIME参数错误");
  639. }
  640. $starttime = $this->formattime($param['starttime'], 'H:i');
  641. $endtime = $this->formattime($param['endtime'], 'H:i');
  642. $usedata = $starttime . "-" . $endtime;
  643. return $usedata;
  644. }
  645. public function formattime($time, $format)
  646. {
  647. $time = strtotime($time);
  648. $time = date($format, $time);
  649. return $time;
  650. }
  651. /**
  652. * unicode 编码
  653. *
  654. * @param [type] $str
  655. * @return void
  656. * @author wj
  657. * @date 2023-08-21
  658. */
  659. public function srtingToUnicode($str)
  660. {
  661. $unicode = '';
  662. $arr = mb_str_split($str); //适配中文
  663. foreach ($arr as $key => $value) {
  664. $char = bin2hex(iconv('UTF-8', 'UCS-2BE', $value));
  665. $char = str_pad($char, 4, '0', STR_PAD_LEFT);
  666. $arr[$key] = $char;
  667. }
  668. $unicode = implode("", $arr);
  669. return $unicode;
  670. }
  671. //设置 低电报警开关
  672. public function createlowbatcommand($facility_id, $device_id_code, $is_open, $sys_user_id)
  673. {
  674. $command = ['command' => 'LOWBAT', 'content_arr' => ['command' => 'LOWBAT', 'is_open' => $is_open]];
  675. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  676. }
  677. //设置 跌倒报警开关
  678. public function createfalldowncommand($facility_id, $device_id_code, $param, $sys_user_id)
  679. {
  680. $command = ['command' => 'FALLDOWN', 'content_arr' => ['command' => 'FALLDOWN', 'is_open' => $param['is_open']]];
  681. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  682. $lssetparam = [];
  683. switch ($param['lsset_type']) {
  684. case '1':
  685. $lssetparam = [3, 6];
  686. break;
  687. case '2':
  688. $lssetparam = [6, 9];
  689. break;
  690. case '3':
  691. $lssetparam = [9, 12];
  692. break;
  693. }
  694. $command = ['command' => 'LSSET', 'content_arr' => ['command' => 'LSSET']];
  695. $this->createsendmsg($facility_id, $device_id_code, $command, $lssetparam, $sys_user_id);
  696. }
  697. /**
  698. * 睡眠时间段设置
  699. *
  700. * @return void
  701. * @author wj
  702. * @date 2023-08-29
  703. */
  704. public function createsleeptimecommand($facility_id, $device_id_code, $param, $sys_user_id)
  705. {
  706. $command = ['command' => 'SLEEPTIME', 'content_arr' => ['command' => 'SLEEPTIME']];
  707. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  708. }
  709. /**
  710. * 立即定位
  711. *
  712. * @return void
  713. * @author wj
  714. * @date 2023-08-29
  715. */
  716. public function createcrcommand($facility_id, $device_id_code, $sys_user_id)
  717. {
  718. $command = ['command' => 'CR', 'content_arr' => ['command' => 'CR']];
  719. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  720. }
  721. /**
  722. * 设置警报电话
  723. *
  724. * @param [type] $facility_id
  725. * @param [type] $device_id_code
  726. * @param [type] $param
  727. * @return void
  728. * @author wj
  729. * @date 2023-08-29
  730. */
  731. public function createsoscommand($facility_id, $device_id_code, $param, $sys_user_id)
  732. {
  733. $param = array_filter($param);
  734. $command = ['command' => 'SOS', 'content_arr' => ['command' => 'SOS']];
  735. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  736. }
  737. /**
  738. * 设置电话本
  739. *
  740. * @param [type] $arr
  741. * @return void
  742. * @author wj
  743. * @date 2023-08-29
  744. */
  745. public function createphlcommand($facility_id, $device_id_code, $param, $sys_user_id)
  746. {
  747. $param = array_filter($param);
  748. $command = ['command' => 'PHL', 'content_arr' => ['command' => 'PHL']];
  749. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  750. }
  751. //设备初始化
  752. public function facilityinit($facility_id, $device_id_code, $param, $sys_user_id)
  753. {
  754. Log::write($param, 'shouhuan');
  755. $zone = $param['zone'];
  756. $upload_interval = $param['upload_interval'];
  757. $fd_is_open = $param['fd_is_open'];
  758. $lowbat_is_open = $param['lowbat_is_open'];
  759. $pedo_is_open = $param['pedo_is_open'];
  760. $remove_is_open = $param['remove_is_open'];
  761. $commandlist = [
  762. ['command' => 'ZONE', 'content_arr' => ['command' => 'ZONE', 'zone' => $zone]],
  763. ['command' => 'UPLOAD', 'content_arr' => ['command' => 'UPLOAD', 'interval' => $upload_interval]],
  764. ['command' => 'CR', 'content_arr' => ['command' => 'CR']],
  765. ['command' => 'FALLDOWN', 'content_arr' => ['command' => 'FALLDOWN', 'is_open' => $fd_is_open]],
  766. ['command' => 'VERNO', 'content_arr' => ['command' => 'VERNO']],
  767. ['command' => 'LOWBAT', 'content_arr' => ['command' => 'LOWBAT', 'is_open' => $lowbat_is_open]],
  768. ['command' => 'PEDO', 'content_arr' => ['command' => 'PEDO', 'is_open' => $pedo_is_open]],
  769. ['command' => 'REMOVE', 'content_arr' => ['command' => 'REMOVE', 'is_open' => $remove_is_open]],
  770. ];
  771. foreach ($commandlist as $key => $value) {
  772. $this->createsendmsg($facility_id, $device_id_code, $value, [], $sys_user_id);
  773. }
  774. }
  775. /**
  776. * 数据间隔设置
  777. * 位置 心率 体温 血压 血氧
  778. *
  779. * @return void
  780. * @author wj
  781. * @date 2023-09-01
  782. */
  783. public function setdatainterval($facility_id, $device_id_code, $param = [], $sys_user_id)
  784. {
  785. Log::write($param, 'shouhuan');
  786. $cr_interval = $param['cr_interval'];
  787. $hrt_interval = $param['hrt_interval'];
  788. $wd_interval = $param['wd_interval'];
  789. $bld_interval = $param['bld_interval'];
  790. $ox_interval = $param['ox_interval'];
  791. $commandlist = [
  792. ['command' => 'UPLOAD', 'content_arr' => ['command' => 'UPLOAD', 'interval' => $cr_interval]],
  793. ['command' => 'HRTSTART', 'content_arr' => ['command' => 'HRTSTART', 'interval' => $hrt_interval]],
  794. ['command' => 'WDSTART', 'content_arr' => ['command' => 'WDSTART', 'interval' => $wd_interval]],
  795. ['command' => 'BLDSTART', 'content_arr' => ['command' => 'BLDSTART', 'interval' => $bld_interval]],
  796. ['command' => 'OXSTART', 'content_arr' => ['command' => 'OXSTART', 'interval' => $ox_interval]],
  797. ];
  798. foreach ($commandlist as $key => $value) {
  799. $this->createsendmsg($facility_id, $device_id_code, $value, $sys_user_id);
  800. }
  801. }
  802. /**
  803. * 关机
  804. *
  805. * @param [type] $facility_id
  806. * @param [type] $device_id_code
  807. * @param [type] $sys_user_id
  808. * @return void
  809. * @author wj
  810. * @date 2023-09-05
  811. */
  812. public function createpoweroffcommand($facility_id, $device_id_code, $sys_user_id)
  813. {
  814. $command = ['command' => 'POWEROFF', 'content_arr' => ['command' => 'POWEROFF']];
  815. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  816. }
  817. /**
  818. * 计步开关
  819. *
  820. * @param [type] $facility_id
  821. * @param [type] $device_id_code
  822. * @param [type] $sys_user_id
  823. * @return void
  824. * @author wj
  825. * @date 2023-09-05
  826. */
  827. public function createpedocommand($facility_id, $device_id_code, $is_open, $sys_user_id)
  828. {
  829. $command = ['command' => 'PEDO', 'content_arr' => ['command' => 'PEDO', 'is_open' => $is_open]];
  830. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  831. }
  832. /**
  833. * 闹钟
  834. *
  835. * @param [type] $facility_id
  836. * @param [type] $device_id_code
  837. * @param [type] $param
  838. * @param [type] $sys_user_id
  839. * @return void
  840. * @author wj
  841. * @date 2023-09-05
  842. */
  843. public function createremindcommand($facility_id, $device_id_code, $param, $sys_user_id)
  844. {
  845. Log::write($param, 'shouhuan');
  846. $command = ['command' => 'REMIND', 'content_arr' => ['command' => 'REMIND']];
  847. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  848. }
  849. /**
  850. * 静默时间
  851. *
  852. * @param [type] $facility_id
  853. * @param [type] $device_id_code
  854. * @param [type] $param
  855. * @param [type] $sys_user_id
  856. * @return void
  857. * @author wj
  858. * @date 2023-09-05
  859. */
  860. public function createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id)
  861. {
  862. Log::write($param, 'shouhuan');
  863. $command = ['command' => 'SILENCETIME2', 'content_arr' => ['command' => 'SILENCETIME2']];
  864. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  865. }
  866. /**
  867. * 开机关机时间
  868. *
  869. * @param [type] $facility_id
  870. * @param [type] $device_id_code
  871. * @param [type] $param
  872. * @param [type] $sys_user_id
  873. * @return void
  874. * @author wj
  875. * @date 2023-09-05
  876. */
  877. public function createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id)
  878. {
  879. Log::write($param, 'shouhuan');
  880. $is_open = $param['is_open'];
  881. $bootup_time = $param['bootup_time'];
  882. $shutdown_time = $param['shutdown_time'];
  883. $command = [
  884. 'command' => 'BOOTOFF',
  885. 'content_arr' => ['command' => 'BOOTOFF', 'is_open' => $is_open, 'bootup_time' => $bootup_time, 'shutdown_time' => $shutdown_time],
  886. ];
  887. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  888. }
  889. /**
  890. * 佩戴提醒
  891. *
  892. * @param [type] $facility_id
  893. * @param [type] $device_id_code
  894. * @param [type] $param
  895. * @param [type] $sys_user_id
  896. * @return void
  897. * @author wj
  898. * @date 2023-09-05
  899. */
  900. public function createremovecommand($facility_id, $device_id_code, $is_open, $sys_user_id)
  901. {
  902. $command = ['command' => 'REMOVE', 'content_arr' => ['command' => 'REMOVE', 'is_open' => $is_open]];
  903. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  904. }
  905. /**
  906. * 拨打电话
  907. *
  908. * @param [type] $facility_id
  909. * @param [type] $device_id_code
  910. * @param [type] $telno
  911. * @param [type] $sys_user_id
  912. * @return void
  913. * @author wj
  914. * @date 2023-09-15
  915. */
  916. public function createcallcommand($facility_id, $device_id_code, $telno, $sys_user_id)
  917. {
  918. $command = ['command' => 'CALL', 'content_arr' => ['command' => 'CALL', 'telno' => $telno]];
  919. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  920. }
  921. }