ShOneanalysis.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <?php
  2. namespace app\common\server;
  3. use app\common\model\FacilityModel;
  4. use app\common\model\ShoneReceiveInfoModel;
  5. use app\common\model\ShoneReceiveInfoRecode;
  6. use app\common\model\ShoneReceiveQueueModel;
  7. use app\common\model\ShoneSendListModel;
  8. use app\common\model\ShoneSendQueueModel;
  9. use think\facade\Log;
  10. /**
  11. * 手环字符串解析
  12. *
  13. * @author wj
  14. * @date 2023-08-11
  15. */
  16. class ShOneanalysis
  17. {
  18. private $num_scale = 16; //16进制
  19. /**
  20. * 校验长度
  21. *
  22. * @return void
  23. * @author wj
  24. * @date 2023-08-11
  25. */
  26. public function checklen($len, $str)
  27. {
  28. $strlen = mb_strlen($str);
  29. if ($len != $strlen) {
  30. return false;
  31. }
  32. return true;
  33. }
  34. /**
  35. * 获取信息
  36. *
  37. * @return void
  38. * @author wj
  39. * @date 2023-08-11
  40. */
  41. public function getline($str)
  42. {
  43. //[厂商*设备 ID*内容长度*内容]
  44. $preg = "/^\[(.*)\*(.*)\*(.*)\*(.*)\]$/";
  45. preg_match($preg, $str, $match);
  46. if (empty($match)) {
  47. throw new \Exception('解析失败:' . $str);
  48. }
  49. unset($match[0]);
  50. $data = array_values($match);
  51. $sandom_string = $data[0]; //厂商 随机字符串
  52. $device_id_code = $data[1]; //设置id编码
  53. $content_len = $data[2]; //内容长度
  54. $content_str = $data[3]; //内容字符串
  55. $content_len = $this->analysislen($content_len);
  56. $result = $this->checklen($content_len, $content_str);
  57. if (empty($result)) {
  58. throw new \Exception('内容位数错误');
  59. }
  60. $data = [
  61. 'device_id_code' => $device_id_code,
  62. 'content_len' => $content_len,
  63. 'content_str' => $content_str,
  64. ];
  65. return $data;
  66. }
  67. //KA,230814,0,0,96
  68. //WT,130823,160054,V,22.601242,N,113.8302765,E,0.00,0.0,29.2,0,70,96,0,0,00000000,1,1,460,0,8593,265807240,136,0,9999.0
  69. //ICCID,02203002080045057806
  70. public function getcommandcontent($content_str)
  71. {
  72. $content = explode(',', $content_str);
  73. return $content;
  74. }
  75. /**
  76. * 保存手环设备one信息
  77. *
  78. * @return void
  79. * @author wj
  80. * @date 2023-08-11
  81. */
  82. public function saveshouhuanoneinfo()
  83. {
  84. //保存时时
  85. //保存历史
  86. }
  87. //内容解析
  88. //解析长度
  89. public function analysislen($len)
  90. {
  91. //低位数在前
  92. $len = base_convert($len, 16, 10);
  93. return $len;
  94. }
  95. /**
  96. * 获取命令信息
  97. *
  98. * @param [type] $command
  99. * @return void
  100. * @author wj
  101. * @date 2023-08-11
  102. */
  103. public function getcommandinfo($command)
  104. {
  105. $command = strtoupper($command);
  106. $data = [
  107. 'LK' => [
  108. 'content' => [
  109. 'command' => 'LK',
  110. ],
  111. 'kind' => 'back',
  112. ],
  113. 'PING' => [
  114. 'content' => [
  115. 'command' => 'PING',
  116. 'isbind' => 1,
  117. ],
  118. 'kind' => 'back',
  119. ],
  120. 'KA' => [
  121. 'content' => [
  122. 'command' => 'KA',
  123. ],
  124. 'kind' => 'back',
  125. ],
  126. 'MONITOR' => [
  127. 'content' => [
  128. 'command' => 'MONITOR',
  129. 'telno' => '',
  130. ],
  131. 'kind' => 'send',
  132. ],
  133. 'SOS' => [
  134. 'content' => [
  135. 'command' => 'SOS',
  136. 'telno1' => '',
  137. 'telno2' => '',
  138. 'telno3' => '',
  139. ],
  140. 'kind' => 'send',
  141. ],
  142. 'VERNO' => [
  143. 'content' => [
  144. 'command' => 'VERNO',
  145. ],
  146. 'kind' => 'send',
  147. ],
  148. 'ZONE' => [
  149. 'content' => [
  150. 'command' => 'ZONE',
  151. 'zone' => '',
  152. ],
  153. 'kind' => 'send',
  154. ],
  155. 'POWEROFF' => [
  156. 'content' => [
  157. 'command' => 'POWEROFF',
  158. ],
  159. 'kind' => 'send',
  160. ],
  161. 'TEMP' => [
  162. 'content' => [
  163. 'command' => 'temp',
  164. ],
  165. 'kind' => 'back',
  166. ],
  167. 'BPHRT' => [
  168. 'content' => [
  169. 'command' => 'bphrt',
  170. ],
  171. 'kind' => 'back',
  172. ],
  173. 'HEART' => [
  174. 'content' => [
  175. 'command' => 'heart',
  176. ],
  177. 'kind' => 'back',
  178. ],
  179. 'BLOOD' => [
  180. 'content' => [
  181. 'command' => 'blood',
  182. ],
  183. 'kind' => 'back',
  184. ],
  185. ];
  186. if (!isset($data[$command])) {
  187. return false;
  188. }
  189. return $data[$command];
  190. }
  191. public function gettsendcommandinfo($command)
  192. {
  193. $command = strtoupper($command);
  194. $data = [
  195. 'WT' => [
  196. 'content' => [
  197. 'command' => 'WT',
  198. 'date' => '',
  199. 'time' => '',
  200. 'is_location' => '',
  201. 'gps_long' => '',
  202. 'gps_long_tag' => '',
  203. 'gps_lat' => '',
  204. 'gps_lat_tag' => '',
  205. 'speed' => '',
  206. 'direction' => '',
  207. 'poster' => '',
  208. 'direction' => '',
  209. 'gps_satellite_num' => '',
  210. 'gsm_signal_strength' => '',
  211. 'electric_quantity' => '',
  212. 'step_number' => '',
  213. 'roll_number' => '',
  214. 'terminal_status' => '',
  215. ],
  216. 'kind' => 'tsend',
  217. 'need_bacl' => 0,
  218. ],
  219. 'WG' => [
  220. 'content' => [
  221. 'command' => 'WT',
  222. 'date' => '',
  223. 'time' => '',
  224. 'is_location' => '',
  225. 'gps_long' => '',
  226. 'gps_long_tag' => '',
  227. 'gps_lat' => '',
  228. 'gps_lat_tag' => '',
  229. 'speed' => '',
  230. 'direction' => '',
  231. 'poster' => '',
  232. 'direction' => '',
  233. 'gps_satellite_num' => '',
  234. 'gsm_signal_strength' => '',
  235. 'electric_quantity' => '',
  236. 'step_number' => '',
  237. 'roll_number' => '',
  238. 'terminal_status' => '',
  239. ],
  240. 'kind' => 'tsend',
  241. 'need_bacl' => 0,
  242. ],
  243. 'KA' => [
  244. 'content' => [
  245. 'command' => 'KA',
  246. 'date' => '',
  247. 'step_number' => '',
  248. 'roll_number' => '',
  249. 'electric_quantity' => '',
  250. ],
  251. 'kind' => 'tsend',
  252. 'need_back' => 1,
  253. ],
  254. 'LK' => [
  255. 'content' => [
  256. 'command' => 'LK',
  257. ],
  258. 'kind' => 'tsend',
  259. 'need_back' => 1,
  260. ],
  261. 'MONITOR' => [
  262. 'content' => [
  263. 'command' => 'MONITOR',
  264. ],
  265. 'kind' => 'tback',
  266. ],
  267. 'SOS3' => [
  268. 'content' => [
  269. 'command' => 'SOS',
  270. ],
  271. 'kind' => 'tback',
  272. ],
  273. 'VERNO' => [
  274. 'content' => [
  275. 'command' => 'VERNO',
  276. 'version' => '',
  277. ],
  278. 'kind' => 'tback',
  279. ],
  280. 'TEMP' => [
  281. 'content' => [
  282. 'command' => 'temp',
  283. 'temp' => '',
  284. ],
  285. 'kind' => 'tsend',
  286. 'need_back' => 1,
  287. ],
  288. 'BPHRT' => [
  289. 'content' => [
  290. 'command' => 'bphrt',
  291. 'blood_height_pressure' => '',
  292. 'blood_low_pressure' => '',
  293. 'heart_rate' => '',
  294. 'height' => '',
  295. 'gender' => '',
  296. 'age' => '',
  297. 'weight' => '',
  298. ],
  299. 'kind' => 'tsend',
  300. 'need_back' => 1,
  301. ],
  302. 'HEART' => [
  303. 'content' => [
  304. 'command' => 'heart',
  305. 'heart_rate' => '',
  306. ],
  307. 'kind' => 'tsend',
  308. 'need_back' => 1,
  309. ],
  310. 'BLOOD' => [
  311. 'content' => [
  312. 'command' => 'blood',
  313. 'blood_height_pressure' => '',
  314. 'blood_low_pressure' => '',
  315. ],
  316. 'kind' => 'tsend',
  317. 'need_back' => 1,
  318. ],
  319. ];
  320. if (!isset($data[$command])) {
  321. return false;
  322. }
  323. return $data[$command];
  324. }
  325. /**
  326. * 获取回复权重
  327. *
  328. * @param [type] $command
  329. * @return void
  330. * @author wj
  331. * @date 2023-08-11
  332. */
  333. public function getsendweight($command)
  334. {
  335. $weight = -1;
  336. switch ($command) {
  337. case 'POWEROFF':
  338. //关机
  339. $weight = 99;
  340. break;
  341. case 'RESET':
  342. //重启
  343. $weight = 98;
  344. break;
  345. case 'LK':
  346. case 'PING':
  347. case 'KA':
  348. case 'AL':
  349. case 'UD2';
  350. $weight = 1;
  351. break;
  352. case 'UPLOAD':
  353. case 'MONITOR':
  354. case 'SOS':
  355. case 'LANG':
  356. case 'ZONE':
  357. case 'CENTER':
  358. case 'SOSSMS':
  359. case 'REMOVE':
  360. case 'REMOVESMS':
  361. case 'VERNO':
  362. case 'CR':
  363. case 'SILENCETIME2':
  364. case 'WALKTIME':
  365. case 'SLEEPTIME':
  366. case 'FIND':
  367. case 'REMIND':
  368. case 'SCHEDULE':
  369. case 'PHB':
  370. case 'PHBX':
  371. case 'DPHBX':
  372. case 'MESSAGE':
  373. case 'FACTORY':
  374. case 'PROFILE':
  375. case 'BTEMP2':
  376. case 'BODYTEMP':
  377. case 'BTWARNSET':
  378. case 'APPLOCK':
  379. case 'HRTSTART':
  380. case 'BPHRT':
  381. case 'LSSET':
  382. $weight = 0;
  383. break;
  384. default:
  385. $weight = -1;
  386. break;
  387. }
  388. if ($weight < 0) {
  389. //不需设置 发送信息
  390. return false;
  391. }
  392. return $weight;
  393. }
  394. /**
  395. * 获取设别表id
  396. *
  397. * @return void
  398. * @author wj
  399. * @date 2023-08-11
  400. */
  401. public function getfacilityid($device_id_code)
  402. {
  403. $m_f = new FacilityModel();
  404. $where = ['code' => $device_id_code, 'status' => 1];
  405. $finfo = $m_f->getInfo($where, ['id']);
  406. if (empty($finfo)) {
  407. throw new \Exception("设备信息错误:" . $device_id_code);
  408. }
  409. $id = $finfo['id'];
  410. return $id;
  411. }
  412. /**
  413. * 创建发送信息
  414. *
  415. * @param [type] $data
  416. * @param [type] $command
  417. * @return void
  418. * @author wj
  419. * @date 2023-08-14
  420. */
  421. public function createbacksendmsg($facility_id, $device_id_code, $data, $command)
  422. {
  423. $infoarr = $this->gettsendcommandinfo($command);
  424. if (!$infoarr) {
  425. throw new \Exception("无对应命令数据1:" . $command);
  426. }
  427. $data = $this->getdata($data, $command, $infoarr);
  428. $info_content = $data['info_content'];
  429. $need_back = isset($data['need_back']) && $data['need_back'] ? true : false;
  430. if ($need_back) {
  431. $infoarr = $this->getcommandinfo($command);
  432. $data = $this->getdata($data, $command, $infoarr);
  433. $info_content = $data['info_content'];
  434. $weight = $this->getsendweight($command);
  435. $content = implode(',', $info_content);
  436. $msgdata = [
  437. 0 => '3G',
  438. 'device_id_code' => $device_id_code,
  439. 'len' => str_pad(dechex(mb_strlen($content)), 4, "0", STR_PAD_LEFT),
  440. 'content' => $content,
  441. ];
  442. $msg = '[' . implode('*', $msgdata) . ']';
  443. $sslInsertData = [
  444. 'facility_id' => $facility_id,
  445. 'device_id_code' => $device_id_code,
  446. 'send_msg' => $msg,
  447. 'send_time' => date('Y-m-d H:i:s'),
  448. 'send_weight' => $weight,
  449. ];
  450. $m_ssl = new ShoneSendListModel();
  451. $sslid = $m_ssl->insertData($sslInsertData);
  452. if (empty($sslid)) {
  453. throw new \Exception("发送数据添加失败");
  454. }
  455. $data = [
  456. 'msg' => $msg,
  457. 'weight' => $weight,
  458. 'createtime' => date('Y-m-d H:i:s'),
  459. 'device_id_code' => $device_id_code,
  460. 'list_id' => $sslid,
  461. ];
  462. $m_ssq = new ShoneSendQueueModel();
  463. $id = $m_ssq->insertData($data);
  464. if (empty($id)) {
  465. throw new \Exception("发送队列数据添加失败");
  466. }
  467. return $data;
  468. }
  469. return false;
  470. }
  471. /**
  472. * 获取数据值
  473. *
  474. * @param [type] $data
  475. * @param [type] $command
  476. * @return void
  477. * @author wj
  478. * @date 2023-08-14
  479. */
  480. public function getdata($data, $command, $infoarr)
  481. {
  482. $info_content = $infoarr['content'];
  483. foreach (array_keys($info_content) as $key => $value) {
  484. if (empty($info_content[$value])) {
  485. if (isset($data[$key])) {
  486. $info_content[$value] = $data[$key];
  487. }
  488. }
  489. }
  490. if (isset($info_content['time'])) {
  491. $time = $info_content['time'];
  492. $info_content['time'] = $this->gettime($time);
  493. }
  494. if (isset($info_content['date'])) {
  495. $date = $info_content['date'];
  496. $info_content['date'] = $this->getdate($date);
  497. }
  498. $infoarr['info_content'] = $info_content;
  499. return $infoarr;
  500. }
  501. /**
  502. * 保存接收信息队列
  503. *
  504. * @param [type] $data
  505. * @return void
  506. * @author wj
  507. * @date 2023-08-14
  508. */
  509. public function savereceivequeue($data)
  510. {
  511. $m_srq = new ShoneReceiveQueueModel();
  512. $data = [
  513. 'msg' => $data,
  514. 'createtime' => date('Y-m-d H:i:s'),
  515. ];
  516. $id = $m_srq->insertData($data);
  517. Log::write('id:' . $id, 'shouhuan');
  518. if (empty($id)) {
  519. return false;
  520. }
  521. return true;
  522. }
  523. /**
  524. * 保存手环信息
  525. *
  526. * @return void
  527. * @author wj
  528. * @date 2023-08-14
  529. */
  530. public function saveshinfo($facility_id, $device_id_code, $data, $original_str)
  531. {
  532. $command = $data[0];
  533. $infoarr = $this->gettsendcommandinfo($command);
  534. if (!$infoarr) {
  535. throw new \Exception("无对应命令数据2:" . $command);
  536. }
  537. $data = $this->getdata($data, $data[0], $infoarr);
  538. $m_sri = new ShoneReceiveInfoModel();
  539. $m_srir = new ShoneReceiveInfoRecode();
  540. $data = $data['info_content'];
  541. $data['facility_id'] = $facility_id;
  542. $data['device_id_code'] = $device_id_code;
  543. //$m_sri处理
  544. $sriwhere = [
  545. 'facility_id' => $facility_id,
  546. 'device_id_code' => $device_id_code,
  547. ];
  548. $sriinfo = $m_sri->getInfo($sriwhere);
  549. unset($data['command']);
  550. if (empty($sriinfo)) {
  551. $sriinsertData = $data;
  552. $sriinsertData['createtime'] = date('Y-m-d H:i:s');
  553. $sriid = $m_sri->insertData($sriinsertData);
  554. if (empty($sriid)) {
  555. throw new \Exception("设备信息添加失败:" . $device_id_code);
  556. }
  557. } else {
  558. unset($data['device_id_code']);
  559. unset($data['facility_id']);
  560. $sriid = $sriinfo['id'];
  561. $sriupdateData = $data;
  562. $sriupdateData['updatetime'] = date('Y-m-d H:i:s');
  563. $row = $m_sri->updateinfo(['id' => $sriid], $sriupdateData);
  564. if (empty($row)) {
  565. throw new \Exception("设备信息修改失败:" . $device_id_code);
  566. }
  567. }
  568. //m_srir处理
  569. $data['original_str'] = $original_str;
  570. $sririnsertData = $data;
  571. $sririnsertData['facility_id'] = $facility_id;
  572. $sririnsertData['device_id_code'] = $device_id_code;
  573. $sririnsertData['createtime'] = date('Y-m-d H:i:s');
  574. $sririd = $m_srir->insertData($sririnsertData);
  575. if (empty($sririd)) {
  576. throw new \Exception("设备历史信息添加失败:" . $device_id_code);
  577. }
  578. }
  579. /**
  580. * 获取接收信息队列列表
  581. *
  582. * @param [type] $page
  583. * @param [type] $size
  584. * @return void
  585. * @author wj
  586. * @date 2023-08-14
  587. */
  588. public function getreceivequeuelist($page = null, $size = null)
  589. {
  590. $m_srq = new ShoneReceiveQueueModel();
  591. $where = ['status' => 0];
  592. $size = empty($size) ? 20 : $size;
  593. if (empty($page)) {
  594. $count = $m_srq->getList($where, 'count');
  595. $totalpage = ceil($count / $size);
  596. $data = ['totalpage' => $totalpage, 'size' => $size];
  597. return $data;
  598. } else {
  599. $list = $m_srq->getList($where, '*', $page, $size, 'id asc');
  600. if (empty($list)) {
  601. Log::write("手环接收信息队列-无数据", 'shouhuan');
  602. return false;
  603. }
  604. $list = $list->toArray();
  605. $ids = array_column($list, 'id');
  606. $updatecount = $m_srq->updateinfo(['id' => ['in', $ids], 'status' => 0], ['status' => 1]);
  607. if ($updatecount != count($ids)) {
  608. Log::write("手环接收信息队列-部分未修改", 'shouhuan');
  609. Log::write("count:" . count($ids) . " update count:" . $updatecount, 'shouhuan');
  610. }
  611. if (empty($updatecount)) {
  612. Log::write("手环接收信息队列-无修改数据", 'shouhuan');
  613. return false;
  614. }
  615. return $list;
  616. }
  617. }
  618. /**
  619. * 获取发送信息队列列表
  620. *
  621. * @param [type] $page
  622. * @param [type] $size
  623. * @return void
  624. * @author wj
  625. * @date 2023-08-14
  626. */
  627. public function getsendqueuelist($device_id_code, $page = null, $size = null)
  628. {
  629. $m_ssq = new ShoneSendQueueModel();
  630. $where = ['status' => 0, 'device_id_code' => $device_id_code];
  631. $size = empty($size) ? 20 : $size;
  632. if (empty($page)) {
  633. $count = $m_ssq->getList($where, 'count');
  634. $totalpage = ceil($count / $size);
  635. $data = ['totalpage' => $totalpage, 'size' => $size];
  636. return $data;
  637. } else {
  638. $list = $m_ssq->getList($where, '*', $page, $size, 'id asc,weight desc');
  639. if (empty($list)) {
  640. Log::write("手环发送信息队列-无数据", 'shouhuan');
  641. return false;
  642. }
  643. $list = $list->toArray();
  644. $ids = array_column($list, 'id');
  645. $updatecount = $m_ssq->updateinfo(['id' => ['in', $ids], 'status' => 0], ['status' => 1]);
  646. if ($updatecount != count($ids)) {
  647. Log::write("手环发送信息队列-部分未修改", 'shouhuan');
  648. Log::write("count:" . count($ids) . " update count:" . $updatecount, 'shouhuan');
  649. }
  650. if (empty($updatecount)) {
  651. Log::write("手环发送信息队列-无修改数据", 'shouhuan');
  652. return false;
  653. }
  654. return $list;
  655. }
  656. }
  657. public function sendmsgsuccess($item)
  658. {
  659. $m_ssq = new ShoneSendQueueModel();
  660. $m_ssl = new ShoneSendListModel();
  661. $ssqid = $item['id'];
  662. $list_id = $item['list_id'];
  663. $sslwhere = ['id' => $list_id, 'is_send' => 0];
  664. $sslinfo = $m_ssl->getInfo($sslwhere);
  665. if ($sslinfo) {
  666. $row = $m_ssl->updateinfo(['id' => $sslinfo['id']], ['is_send' => 1, 'send_time' => date('Y-m-d H:i:s')]);
  667. }
  668. $ssqwhere = ['id' => $ssqid];
  669. $ssqinfo = $m_ssq->getInfo($ssqwhere);
  670. if ($ssqinfo) {
  671. $m_ssq->deleteinfobyid($ssqid);
  672. }
  673. }
  674. public function receivemsgsuccess($item)
  675. {
  676. $m_srq = new ShoneReceiveQueueModel();
  677. $srqid = $item['id'];
  678. $srqwhere = ['id' => $srqid, 'status' => 1];
  679. $srqinfo = $m_srq->getInfo($srqwhere);
  680. if ($srqinfo) {
  681. $m_srq->deleteinfobyid($srqid);
  682. }
  683. }
  684. /**
  685. * 日期解析
  686. *
  687. * @return void
  688. * @author wj
  689. * @date 2023-08-15
  690. */
  691. public function getdate($date)
  692. {
  693. $day = substr($date, 0, 2);
  694. $month = substr($date, 2, 2);
  695. $year = substr($date, 4, 2);
  696. $year1 = date('Y');
  697. $year1 = substr($year1, 0, 2);
  698. $year = $year1 . $year;
  699. $day = $year . '-' . $month . '-' . $day;
  700. return $day;
  701. }
  702. public function gettime($time)
  703. {
  704. $hour = substr($time, 0, 2);
  705. $minute = substr($time, 2, 2);
  706. $second = substr($time, 4, 2);
  707. $time = $hour . ':' . $minute . ':' . $second;
  708. return $time;
  709. }
  710. /**
  711. * 初始化手环接收信息解析
  712. *
  713. * @return void
  714. * @author wj
  715. * @date 2023-08-15
  716. */
  717. public function initanalysisShoneReceiveMsg()
  718. {
  719. $m_srq = new ShoneReceiveQueueModel();
  720. $where = ['status' => 1];
  721. $m_srq->updateinfo($where, ['status' => 0]);
  722. }
  723. /**
  724. * 拆包
  725. *
  726. * @return void
  727. * @author wj
  728. * @date 2023-08-15
  729. */
  730. public function unpack($data)
  731. {
  732. $arr = explode("][", $data);
  733. foreach ($arr as $key => $value) {
  734. $regex = "/^[^[].*$/";
  735. preg_match($regex, $value, $mc0);
  736. $regex = "/^.*[^]]$/";
  737. preg_match($regex, $value, $mc1);
  738. if ($mc0) {
  739. $arr[$key] = '[' . $value;
  740. }
  741. if ($mc1) {
  742. $arr[$key] = $value . "]";
  743. }
  744. }
  745. return $arr;
  746. }
  747. }