ShouhuanCommand.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  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. $weight = 0;
  187. break;
  188. default:
  189. $weight = -1;
  190. break;
  191. }
  192. if ($weight < 0) {
  193. //不需设置 发送信息
  194. return false;
  195. }
  196. return $weight;
  197. }
  198. /**
  199. * 获取平台发送命令信息
  200. *
  201. * @param [type] $command
  202. * @return void
  203. * @author wj
  204. * @date 2023-08-11
  205. */
  206. public function getsendcommandinfo($command)
  207. {
  208. $command = strtoupper($command);
  209. $data = [
  210. //平台发送
  211. //时区
  212. 'ZONE' => [
  213. 'content' => [
  214. 'command' => 'ZONE',
  215. 'zone' => '',
  216. ],
  217. 'kind' => 'send',
  218. 'need_back' => 1,
  219. ],
  220. //位置发送间隔
  221. 'UPLOAD' => [
  222. 'content' => [
  223. 'command' => 'UPLOAD',
  224. 'interval' => '',
  225. ],
  226. 'kind' => 'send',
  227. 'need_back' => 1,
  228. ],
  229. //心率上传间隔
  230. 'HRTSTART' => [
  231. 'content' => [
  232. 'command' => 'hrtstart',
  233. 'interval' => '',
  234. ],
  235. 'kind' => 'send',
  236. 'need_back' => 1,
  237. ],
  238. //体温上传间隔
  239. 'WDSTART' => [
  240. 'content' => [
  241. 'command' => 'wdstart',
  242. 'interval' => '',
  243. ],
  244. 'kind' => 'send',
  245. 'need_back' => 1,
  246. ],
  247. //血压上传频率
  248. 'BLDSTART' => [
  249. 'content' => [
  250. 'command' => 'bldstart',
  251. 'interval' => '',
  252. ],
  253. 'kind' => 'send',
  254. 'need_back' => 1,
  255. ],
  256. //血氧上传频率
  257. 'OXSTART' => [
  258. 'content' => [
  259. 'command' => 'oxstart',
  260. 'interval' => '',
  261. ],
  262. 'kind' => 'send',
  263. 'need_back' => 1,
  264. ],
  265. //立即定位
  266. 'CR' => [
  267. 'content' => [
  268. 'command' => 'CR',
  269. ],
  270. 'kind' => 'send',
  271. 'need_back' => 1,
  272. ],
  273. 'SLEEPTIME' => [
  274. 'content' => [
  275. 'command' => 'CR',
  276. ],
  277. 'kind' => 'send',
  278. 'content_custom' => true,
  279. 'need_back' => 1,
  280. ],
  281. 'FALLDOWN' => [
  282. 'content' => [
  283. 'command' => 'FALLDOWN',
  284. 'is_open' => '',
  285. ],
  286. 'kind' => 'send',
  287. 'need_back' => 1,
  288. ],
  289. 'FACTORY' => [
  290. 'content' => [
  291. 'command' => 'FACTORY',
  292. ],
  293. 'kind' => 'send',
  294. 'need_back' => 1,
  295. ],
  296. 'SOS' => [
  297. 'content' => [
  298. 'command' => 'SOS',
  299. ],
  300. 'kind' => 'send',
  301. 'content_custom' => true,
  302. 'need_back' => 1,
  303. ],
  304. 'VERNO' => [
  305. 'content' => [
  306. 'command' => 'VERNO',
  307. ],
  308. 'kind' => 'send',
  309. 'need_back' => 1,
  310. ],
  311. 'LOWBAT' => [
  312. 'content' => [
  313. 'command' => 'LOWBAT',
  314. 'is_open' => '',
  315. ],
  316. 'kind' => 'send',
  317. 'need_back' => 1,
  318. ],
  319. 'POWEROFF' => [
  320. 'content' => [
  321. 'command' => 'POWEROFF',
  322. ],
  323. 'kind' => 'send',
  324. 'need_back' => 1,
  325. ],
  326. 'LSSET' => [
  327. 'content' => [
  328. 'command' => 'LSSET',
  329. 'content_custom' => true,
  330. ],
  331. 'kind' => 'send',
  332. 'need_back' => 1,
  333. ],
  334. 'PEDO' => [
  335. 'content' => [
  336. 'command' => 'PEDO',
  337. 'is_open' => '',
  338. ],
  339. 'kind' => 'send',
  340. 'need_back' => 1,
  341. ],
  342. 'PHL' => [
  343. 'content' => [
  344. 'command' => 'PHL',
  345. ],
  346. 'kind' => 'send',
  347. 'content_custom' => true,
  348. 'need_back' => 1,
  349. ],
  350. 'REMIND' => [
  351. 'content' => [
  352. 'command' => 'REMIND',
  353. ],
  354. 'kind' => 'send',
  355. 'content_custom' => true,
  356. 'need_back' => 1,
  357. ],
  358. 'SILENCETIME2' => [
  359. 'content' => [
  360. 'command' => 'SILENCETIME2',
  361. ],
  362. 'kind' => 'send',
  363. 'content_custom' => true,
  364. 'need_back' => 1,
  365. ],
  366. 'BOOTOFF' => [
  367. 'content' => [
  368. 'command' => 'BOOTOFF',
  369. 'is_open' => '',
  370. 'bootup_time' => '',
  371. 'shutdown_time' => '',
  372. ],
  373. 'kind' => 'send',
  374. 'need_back' => 1,
  375. ],
  376. 'REMOVE' => [
  377. 'content' => [
  378. 'command' => 'REMOVE',
  379. 'is_open' => '',
  380. ],
  381. 'kind' => 'send',
  382. 'need_back' => 1,
  383. ],
  384. //平台回复
  385. 'LK' => [
  386. 'content' => [
  387. 'command' => 'LK',
  388. ],
  389. 'kind' => 'back',
  390. ],
  391. 'PING' => [
  392. 'content' => [
  393. 'command' => 'PING',
  394. 'isbind' => 1,
  395. ],
  396. 'kind' => 'back',
  397. ],
  398. 'KA' => [
  399. 'content' => [
  400. 'command' => 'KA',
  401. ],
  402. 'kind' => 'back',
  403. ],
  404. 'TEMP' => [
  405. 'content' => [
  406. 'command' => 'temp',
  407. ],
  408. 'kind' => 'back',
  409. ],
  410. 'BPHRT' => [
  411. 'content' => [
  412. 'command' => 'bphrt',
  413. ],
  414. 'kind' => 'back',
  415. ],
  416. 'HEART' => [
  417. 'content' => [
  418. 'command' => 'heart',
  419. ],
  420. 'kind' => 'back',
  421. ],
  422. 'BLOOD' => [
  423. 'content' => [
  424. 'command' => 'blood',
  425. ],
  426. 'kind' => 'back',
  427. ],
  428. 'OXYGEN' => [
  429. 'content' => [
  430. 'command' => 'oxygen',
  431. ],
  432. 'kind' => 'back',
  433. ],
  434. 'AL' => [
  435. 'content' => [
  436. 'command' => 'AL',
  437. ],
  438. 'kind' => 'back',
  439. ],
  440. ];
  441. if (!isset($data[$command])) {
  442. return false;
  443. }
  444. return $data[$command];
  445. }
  446. /**
  447. * 创建sos电话设置命令
  448. * 最多三个电话
  449. *
  450. * @return void
  451. * @author wj
  452. * @date 2023-08-21
  453. */
  454. public function getSOSCommandinfo($param)
  455. {
  456. if (count($param) <= 0) {
  457. throw new \Exception("未设置电话");
  458. }
  459. if (count($param) > 3) {
  460. throw new \Exception("设置电话数量过多");
  461. }
  462. foreach ($param as $key => $value) {
  463. //判断是否为手机号
  464. //暂不处理
  465. }
  466. $info = implode(",", $param);
  467. return $info;
  468. }
  469. /**
  470. * 设置跌倒灵敏度命令
  471. * [3G*358800006072996*0009*LSSET,3+6]
  472. *
  473. * @return void
  474. * @author wj
  475. * @date 2023-08-21
  476. */
  477. public function getLSSETCommandinfo($param)
  478. {
  479. if (2 != count($param)) {
  480. throw new \Exception("LSSET参数错误");
  481. }
  482. foreach ($param as $key => $value) {
  483. if (!is_numeric($value)) {
  484. throw new \Exception("LSSET参数错误:" . $value);
  485. }
  486. }
  487. $info = $param[0] . "+" . $param[1];
  488. return $info;
  489. }
  490. /**
  491. * 设置电话本
  492. * 最多10条
  493. *[{telno=>'',name=>''}]
  494. * @param [type] $param
  495. * @return void
  496. * @author wj
  497. * @date 2023-08-21
  498. */
  499. public function getPHLCommandinfo($param)
  500. {
  501. if (50 < count($param)) {
  502. throw new \Exception("PHL参数错误");
  503. }
  504. $usedata = [];
  505. foreach ($param as $key => $value) {
  506. $telno = $value['telno'];
  507. $name = $value['name'];
  508. //电话号码
  509. if (20 < mb_strlen($telno)) {
  510. throw new \Exception("PHL电话号码错误:" . $telno);
  511. }
  512. $name = $this->srtingToUnicode($name);
  513. $usedata[] = $telno;
  514. $usedata[] = $name;
  515. }
  516. $info = implode(",", $usedata);
  517. return $info;
  518. }
  519. /**
  520. * 设置电话本
  521. * 最多10条
  522. *{[time=>'',isopen=>'','type'=>'','weeks'=>[]]}
  523. * weeks 数组 每个1到7 周日到周六
  524. * 最多设置三个
  525. * @param [type] $param
  526. * @return void
  527. * @author wj
  528. * @date 2023-08-21
  529. */
  530. /*
  531. 08:10-1-1:闹钟时间 8:10,打开,响铃一次
  532. 08:10-1-2:闹钟时间 8:10,打开,每天响铃
  533. 08:10-1-3-0111110:闹钟时间 8:10,打开,自定义周一至周五打开
  534. 最左边是周日,最右边是周六,即 0111110 的顺序是:周日,周一,周二,周三,周四,周五,周
  535. 六(1 为打开,0 为关闭),其中周一至周五打开闹钟
  536. */
  537. public function getREMINDCommandinfo($param)
  538. {
  539. if (empty($param)) {
  540. throw new \Exception("REMINDC参数错误");
  541. }
  542. $usedata = [];
  543. foreach ($param as $key => $value) {
  544. if (3 > count($value)) {
  545. throw new \Exception("REMINDC参数错误");
  546. }
  547. $useweeks = ["0", "0", "0", "0", "0", "0", "0"];
  548. $time = $this->formattime($value['time'], 'H:i');
  549. $isopen = $value['isopen'];
  550. $type = $value['type'];
  551. $weeks = $value['weeks'];
  552. if (3 == $type) {
  553. foreach ($weeks as $wkey => $wvalue) {
  554. if ($wvalue >= 1 && $wvalue <= 7) {
  555. $useweeks[$wvalue - 1] = '1';
  556. }
  557. }
  558. $useweeks = implode("", $useweeks);
  559. $type = $useweeks;
  560. }
  561. $usedata[] = $time . "-" . $isopen . "-" . $type;
  562. }
  563. $usedata = implode(",", $usedata);
  564. return $usedata;
  565. }
  566. /**
  567. * 静默时间段测试
  568. *{[starttime=>'',endtime=>'',isopen=>'',weeks=>[]]}
  569. * weeks 数组 每个1到7 周日到周六
  570. * 最多设置三个
  571. *
  572. * @return void
  573. * @author wj
  574. * @date 2023-08-21
  575. */
  576. /*
  577. [DW*334588000000156*0038*SILENCETIME2,7:30-21:10-1-0111110,7:30-21:10-1-0111110,7:
  578. 30-21:10-0-0111110]
  579. 设置上课禁用时间段范围,拦截终端的任何来电。格式为“起始时间-结束时间-自定义星期几”, 比
  580. 如上面的 7:30-21:00-0111110,则表示周一到周五 7:30 到 21:00 之间上课禁用生效,起始时间
  581. 默认大于结束时间。
  582. 总开关:0 为关,1 为开
  583. 关于自定义星期几的规则:最左边是周日,最右边是周六,即 0111110 的顺序是:周日,周一,周
  584. 二,周三,周四,周五,周六(1 为打开,0 为关闭),所以上面的意思是周一至周五打开上课禁
  585. 用。
  586. */
  587. public function getSILENCETIME2Commandinfo($param)
  588. {
  589. if (empty($param)) {
  590. throw new \Exception("SILENCETIME2参数错误");
  591. }
  592. $usedata = [];
  593. foreach ($param as $key => $value) {
  594. if (4 > count($value)) {
  595. throw new \Exception("SILENCETIME2参数错误");
  596. }
  597. $useweeks = ["0", "0", "0", "0", "0", "0", "0"];
  598. //未比较时间大小
  599. $starttime = $this->formattime($value['starttime'], 'H:i');
  600. $endtime = $this->formattime($value['endtime'], 'H:i');
  601. $isopen = $value['isopen'];
  602. $weeks = $value['weeks'];
  603. foreach ($weeks as $wkey => $wvalue) {
  604. if ($wvalue >= 1 && $wvalue <= 7) {
  605. $useweeks[$wvalue - 1] = '1';
  606. }
  607. }
  608. $useweeks = implode("", $useweeks);
  609. $usedata[] = $starttime . "-" . $endtime . "-" . $isopen . "-" . $useweeks;
  610. }
  611. $usedata = implode(",", $usedata);
  612. return $usedata;
  613. }
  614. /**
  615. * 睡眠时间段设置
  616. *{starttime=>'',endtime=>''}
  617. *
  618. * @return void
  619. * @author wj
  620. * @date 2023-08-21
  621. */
  622. public function getSLEEPTIMECommandinfo($param)
  623. {
  624. if (2 > count($param)) {
  625. throw new \Exception("SLEEPTIME参数错误");
  626. }
  627. $starttime = $this->formattime($param['starttime'], 'H:i');
  628. $endtime = $this->formattime($param['endtime'], 'H:i');
  629. $usedata = $starttime . "-" . $endtime;
  630. return $usedata;
  631. }
  632. public function formattime($time, $format)
  633. {
  634. $time = strtotime($time);
  635. $time = date($format, $time);
  636. return $time;
  637. }
  638. /**
  639. * unicode 编码
  640. *
  641. * @param [type] $str
  642. * @return void
  643. * @author wj
  644. * @date 2023-08-21
  645. */
  646. public function srtingToUnicode($str)
  647. {
  648. $unicode = '';
  649. $arr = mb_str_split($str); //适配中文
  650. foreach ($arr as $key => $value) {
  651. $char = bin2hex(iconv('UTF-8', 'UCS-2BE', $value));
  652. $char = str_pad($char, 4, '0', STR_PAD_LEFT);
  653. $arr[$key] = $char;
  654. }
  655. $unicode = implode("", $arr);
  656. return $unicode;
  657. }
  658. //设置 低电报警开关
  659. public function createlowbatcommand($facility_id, $device_id_code, $is_open, $sys_user_id)
  660. {
  661. $command = ['command' => 'LOWBAT', 'content_arr' => ['command' => 'LOWBAT', 'is_open' => $is_open]];
  662. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  663. }
  664. //设置 跌倒报警开关
  665. public function createfalldowncommand($facility_id, $device_id_code, $param, $sys_user_id)
  666. {
  667. $command = ['command' => 'FALLDOWN', 'content_arr' => ['command' => 'FALLDOWN', 'is_open' => $param['is_open']]];
  668. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  669. $lssetparam = [];
  670. switch ($param['lsset_type']) {
  671. case '1':
  672. $lssetparam = [3, 6];
  673. break;
  674. case '2':
  675. $lssetparam = [6, 9];
  676. break;
  677. case '3':
  678. $lssetparam = [9, 12];
  679. break;
  680. }
  681. $command = ['command' => 'LSSET', 'content_arr' => ['command' => 'LSSET']];
  682. $this->createsendmsg($facility_id, $device_id_code, $command, $lssetparam, $sys_user_id);
  683. }
  684. /**
  685. * 睡眠时间段设置
  686. *
  687. * @return void
  688. * @author wj
  689. * @date 2023-08-29
  690. */
  691. public function createsleeptimecommand($facility_id, $device_id_code, $param, $sys_user_id)
  692. {
  693. $command = ['command' => 'SLEEPTIME', 'content_arr' => ['command' => 'SLEEPTIME']];
  694. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  695. }
  696. /**
  697. * 立即定位
  698. *
  699. * @return void
  700. * @author wj
  701. * @date 2023-08-29
  702. */
  703. public function createcrcommand($facility_id, $device_id_code, $sys_user_id)
  704. {
  705. $command = ['command' => 'CR', 'content_arr' => ['command' => 'CR']];
  706. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  707. }
  708. /**
  709. * 设置警报电话
  710. *
  711. * @param [type] $facility_id
  712. * @param [type] $device_id_code
  713. * @param [type] $param
  714. * @return void
  715. * @author wj
  716. * @date 2023-08-29
  717. */
  718. public function createsoscommand($facility_id, $device_id_code, $param, $sys_user_id)
  719. {
  720. $command = ['command' => 'SOS', 'content_arr' => ['command' => 'SOS']];
  721. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  722. }
  723. /**
  724. * 设置电话本
  725. *
  726. * @param [type] $arr
  727. * @return void
  728. * @author wj
  729. * @date 2023-08-29
  730. */
  731. public function createphlcommand($facility_id, $device_id_code, $param, $sys_user_id)
  732. {
  733. $command = ['command' => 'PHL', 'content_arr' => ['command' => 'PHL']];
  734. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  735. }
  736. //设备初始化
  737. public function facilityinit($facility_id, $device_id_code, $param, $sys_user_id)
  738. {
  739. $zone = $param['zone'];
  740. $upload_interval = $param['upload_interval'];
  741. $fd_is_open = $param['fd_is_open'];
  742. $lowbat_is_open = $param['lowbat_is_open'];
  743. $pedo_is_open = $param['pedo_is_open'];
  744. $remove_is_open = $param['remove_is_open'];
  745. $commandlist = [
  746. ['command' => 'ZONE', 'content_arr' => ['command' => 'ZONE', 'zone' => $zone]],
  747. ['command' => 'UPLOAD', 'content_arr' => ['command' => 'UPLOAD', 'interval' => $upload_interval]],
  748. ['command' => 'CR', 'content_arr' => ['command' => 'CR']],
  749. ['command' => 'FALLDOWN', 'content_arr' => ['command' => 'FALLDOWN', 'is_open' => $fd_is_open]],
  750. ['command' => 'VERNO', 'content_arr' => ['command' => 'VERNO']],
  751. ['command' => 'LOWBAT', 'content_arr' => ['command' => 'LOWBAT', 'is_open' => $lowbat_is_open]],
  752. ['command' => 'PEDO', 'content_arr' => ['command' => 'PEDO', 'is_open' => $pedo_is_open]],
  753. ['command' => 'REMOVE', 'content_arr' => ['command' => 'REMOVE', 'is_open' => $remove_is_open]],
  754. ];
  755. foreach ($commandlist as $key => $value) {
  756. $this->createsendmsg($facility_id, $device_id_code, $value, [], $sys_user_id);
  757. }
  758. }
  759. /**
  760. * 数据间隔设置
  761. * 位置 心率 体温 血压 血氧
  762. *
  763. * @return void
  764. * @author wj
  765. * @date 2023-09-01
  766. */
  767. public function setdatainterval($facility_id, $device_id_code, $param = [], $sys_user_id)
  768. {
  769. $cr_interval = $param['cr_interval'];
  770. $hrt_interval = $param['hrt_interval'];
  771. $wd_interval = $param['wd_interval'];
  772. $bld_interval = $param['bld_interval'];
  773. $ox_interval = $param['ox_interval'];
  774. $commandlist = [
  775. ['command' => 'UPLOAD', 'content_arr' => ['command' => 'UPLOAD', 'interval' => $cr_interval]],
  776. ['command' => 'HRTSTART', 'content_arr' => ['command' => 'HRTSTART', 'interval' => $hrt_interval]],
  777. ['command' => 'WDSTART', 'content_arr' => ['command' => 'WDSTART', 'interval' => $wd_interval]],
  778. ['command' => 'BLDSTART', 'content_arr' => ['command' => 'BLDSTART', 'interval' => $bld_interval]],
  779. ['command' => 'OXSTART', 'content_arr' => ['command' => 'OXSTART', 'interval' => $ox_interval]],
  780. ];
  781. foreach ($commandlist as $key => $value) {
  782. $this->createsendmsg($facility_id, $device_id_code, $value, $sys_user_id);
  783. }
  784. }
  785. /**
  786. * 关机
  787. *
  788. * @param [type] $facility_id
  789. * @param [type] $device_id_code
  790. * @param [type] $sys_user_id
  791. * @return void
  792. * @author wj
  793. * @date 2023-09-05
  794. */
  795. public function createpoweroffcommand($facility_id, $device_id_code, $sys_user_id)
  796. {
  797. $command = ['command' => 'POWEROFF', 'content_arr' => ['command' => 'POWEROFF']];
  798. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  799. }
  800. /**
  801. * 计步开关
  802. *
  803. * @param [type] $facility_id
  804. * @param [type] $device_id_code
  805. * @param [type] $sys_user_id
  806. * @return void
  807. * @author wj
  808. * @date 2023-09-05
  809. */
  810. public function createpedocommand($facility_id, $device_id_code, $is_open, $sys_user_id)
  811. {
  812. $command = ['command' => 'PEDO', 'content_arr' => ['command' => 'PEDO', 'is_open' => $is_open]];
  813. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  814. }
  815. /**
  816. * 闹钟
  817. *
  818. * @param [type] $facility_id
  819. * @param [type] $device_id_code
  820. * @param [type] $param
  821. * @param [type] $sys_user_id
  822. * @return void
  823. * @author wj
  824. * @date 2023-09-05
  825. */
  826. public function createremindcommand($facility_id, $device_id_code, $param, $sys_user_id)
  827. {
  828. $command = ['command' => 'REMIND', 'content_arr' => ['command' => 'REMIND']];
  829. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  830. }
  831. /**
  832. * 静默时间
  833. *
  834. * @param [type] $facility_id
  835. * @param [type] $device_id_code
  836. * @param [type] $param
  837. * @param [type] $sys_user_id
  838. * @return void
  839. * @author wj
  840. * @date 2023-09-05
  841. */
  842. public function createsilencetime2command($facility_id, $device_id_code, $param, $sys_user_id)
  843. {
  844. $command = ['command' => 'SILENCETIME2', 'content_arr' => ['command' => 'SILENCETIME2']];
  845. $this->createsendmsg($facility_id, $device_id_code, $command, $param, $sys_user_id);
  846. }
  847. /**
  848. * 开机关机时间
  849. *
  850. * @param [type] $facility_id
  851. * @param [type] $device_id_code
  852. * @param [type] $param
  853. * @param [type] $sys_user_id
  854. * @return void
  855. * @author wj
  856. * @date 2023-09-05
  857. */
  858. public function createbootoffcommand($facility_id, $device_id_code, $param, $sys_user_id)
  859. {
  860. $is_open = $param['is_open'];
  861. $bootup_time = $param['bootup_time'];
  862. $shutdown_time = $param['shutdown_time'];
  863. $command = [
  864. 'command' => 'BOOTOFF',
  865. 'content_arr' => ['command' => 'BOOTOFF', 'is_open' => $is_open, 'bootup_time' => $bootup_time, 'shutdown_time' => $shutdown_time],
  866. ];
  867. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  868. }
  869. /**
  870. * 佩戴提醒
  871. *
  872. * @param [type] $facility_id
  873. * @param [type] $device_id_code
  874. * @param [type] $param
  875. * @param [type] $sys_user_id
  876. * @return void
  877. * @author wj
  878. * @date 2023-09-05
  879. */
  880. public function createremovecommand($facility_id, $device_id_code, $is_open, $sys_user_id)
  881. {
  882. $command = ['command' => 'REMOVE', 'content_arr' => ['command' => 'REMOVE', 'is_open' => $is_open]];
  883. $this->createsendmsg($facility_id, $device_id_code, $command, [], $sys_user_id);
  884. }
  885. }