|
@@ -1,792 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-namespace app\common\server;
|
|
|
-
|
|
|
-use app\common\model\FacilityModel;
|
|
|
-use app\common\model\ShoneReceiveInfoModel;
|
|
|
-use app\common\model\ShoneReceiveInfoRecode;
|
|
|
-use app\common\model\ShoneReceiveQueueModel;
|
|
|
-use app\common\model\ShoneSendListModel;
|
|
|
-use app\common\model\ShoneSendQueueModel;
|
|
|
-use think\facade\Log;
|
|
|
-
|
|
|
-/**
|
|
|
- * 手环字符串解析
|
|
|
- *
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-11
|
|
|
- */
|
|
|
-class ShOneanalysis
|
|
|
-{
|
|
|
- private $num_scale = 16; //16进制
|
|
|
- /**
|
|
|
- * 校验长度
|
|
|
- *
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-11
|
|
|
- */
|
|
|
- public function checklen($len, $str)
|
|
|
- {
|
|
|
- $strlen = mb_strlen($str);
|
|
|
- if ($len != $strlen) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取信息
|
|
|
- *
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-11
|
|
|
- */
|
|
|
- public function getline($str)
|
|
|
- {
|
|
|
- //[厂商*设备 ID*内容长度*内容]
|
|
|
- $preg = "/^\[(.*)\*(.*)\*(.*)\*(.*)\]$/";
|
|
|
- preg_match($preg, $str, $match);
|
|
|
- if (empty($match)) {
|
|
|
- throw new \Exception('解析失败:' . $str);
|
|
|
- }
|
|
|
- unset($match[0]);
|
|
|
- $data = array_values($match);
|
|
|
- $sandom_string = $data[0]; //厂商 随机字符串
|
|
|
- $device_id_code = $data[1]; //设置id编码
|
|
|
- $content_len = $data[2]; //内容长度
|
|
|
- $content_str = $data[3]; //内容字符串
|
|
|
- $content_len = $this->analysislen($content_len);
|
|
|
- $result = $this->checklen($content_len, $content_str);
|
|
|
- if (empty($result)) {
|
|
|
- throw new \Exception('内容位数错误');
|
|
|
- }
|
|
|
- $data = [
|
|
|
- 'device_id_code' => $device_id_code,
|
|
|
- 'content_len' => $content_len,
|
|
|
- 'content_str' => $content_str,
|
|
|
- ];
|
|
|
- return $data;
|
|
|
- }
|
|
|
- //KA,230814,0,0,96
|
|
|
- //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
|
|
|
- //ICCID,02203002080045057806
|
|
|
- public function getcommandcontent($content_str)
|
|
|
- {
|
|
|
- $content = explode(',', $content_str);
|
|
|
- return $content;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存手环设备one信息
|
|
|
- *
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-11
|
|
|
- */
|
|
|
- public function saveshouhuanoneinfo()
|
|
|
- {
|
|
|
- //保存时时
|
|
|
- //保存历史
|
|
|
- }
|
|
|
- //内容解析
|
|
|
- //解析长度
|
|
|
- public function analysislen($len)
|
|
|
- {
|
|
|
- //低位数在前
|
|
|
- $len = base_convert($len, 16, 10);
|
|
|
- return $len;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取命令信息
|
|
|
- *
|
|
|
- * @param [type] $command
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-11
|
|
|
- */
|
|
|
- public function getcommandinfo($command)
|
|
|
- {
|
|
|
- $command = strtoupper($command);
|
|
|
- $data = [
|
|
|
- 'LK' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'LK',
|
|
|
- ],
|
|
|
- 'kind' => 'back',
|
|
|
- ],
|
|
|
- 'PING' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'PING',
|
|
|
- 'isbind' => 1,
|
|
|
- ],
|
|
|
- 'kind' => 'back',
|
|
|
- ],
|
|
|
- 'KA' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'KA',
|
|
|
- ],
|
|
|
- 'kind' => 'back',
|
|
|
- ],
|
|
|
- 'MONITOR' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'MONITOR',
|
|
|
- 'telno' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'send',
|
|
|
- ],
|
|
|
- 'SOS' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'SOS',
|
|
|
- 'telno1' => '',
|
|
|
- 'telno2' => '',
|
|
|
- 'telno3' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'send',
|
|
|
- ],
|
|
|
- 'VERNO' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'VERNO',
|
|
|
- ],
|
|
|
- 'kind' => 'send',
|
|
|
- ],
|
|
|
- 'ZONE' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'ZONE',
|
|
|
- 'zone' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'send',
|
|
|
- ],
|
|
|
- 'POWEROFF' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'POWEROFF',
|
|
|
- ],
|
|
|
- 'kind' => 'send',
|
|
|
- ],
|
|
|
- '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',
|
|
|
- ],
|
|
|
- ];
|
|
|
- if (!isset($data[$command])) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return $data[$command];
|
|
|
- }
|
|
|
-
|
|
|
- public function gettsendcommandinfo($command)
|
|
|
- {
|
|
|
- $command = strtoupper($command);
|
|
|
- $data = [
|
|
|
- 'WT' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'WT',
|
|
|
- 'date' => '',
|
|
|
- 'time' => '',
|
|
|
- 'is_location' => '',
|
|
|
- 'gps_long' => '',
|
|
|
- 'gps_long_tag' => '',
|
|
|
- 'gps_lat' => '',
|
|
|
- 'gps_lat_tag' => '',
|
|
|
- 'speed' => '',
|
|
|
- 'direction' => '',
|
|
|
- 'poster' => '',
|
|
|
- 'direction' => '',
|
|
|
- 'gps_satellite_num' => '',
|
|
|
- 'gsm_signal_strength' => '',
|
|
|
- 'electric_quantity' => '',
|
|
|
- 'step_number' => '',
|
|
|
- 'roll_number' => '',
|
|
|
- 'terminal_status' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_bacl' => 0,
|
|
|
- ],
|
|
|
- 'WG' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'WT',
|
|
|
- 'date' => '',
|
|
|
- 'time' => '',
|
|
|
- 'is_location' => '',
|
|
|
- 'gps_long' => '',
|
|
|
- 'gps_long_tag' => '',
|
|
|
- 'gps_lat' => '',
|
|
|
- 'gps_lat_tag' => '',
|
|
|
- 'speed' => '',
|
|
|
- 'direction' => '',
|
|
|
- 'poster' => '',
|
|
|
- 'direction' => '',
|
|
|
- 'gps_satellite_num' => '',
|
|
|
- 'gsm_signal_strength' => '',
|
|
|
- 'electric_quantity' => '',
|
|
|
- 'step_number' => '',
|
|
|
- 'roll_number' => '',
|
|
|
- 'terminal_status' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_bacl' => 0,
|
|
|
- ],
|
|
|
- 'KA' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'KA',
|
|
|
- 'date' => '',
|
|
|
- 'step_number' => '',
|
|
|
- 'roll_number' => '',
|
|
|
- 'electric_quantity' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_back' => 1,
|
|
|
- ],
|
|
|
- 'LK' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'LK',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_back' => 1,
|
|
|
- ],
|
|
|
- 'MONITOR' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'MONITOR',
|
|
|
- ],
|
|
|
- 'kind' => 'tback',
|
|
|
- ],
|
|
|
- 'SOS3' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'SOS',
|
|
|
- ],
|
|
|
- 'kind' => 'tback',
|
|
|
- ],
|
|
|
- 'VERNO' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'VERNO',
|
|
|
- 'version' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tback',
|
|
|
- ],
|
|
|
- 'TEMP' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'temp',
|
|
|
- 'temp' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_back' => 1,
|
|
|
- ],
|
|
|
- 'BPHRT' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'bphrt',
|
|
|
- 'blood_height_pressure' => '',
|
|
|
- 'blood_low_pressure' => '',
|
|
|
- 'heart_rate' => '',
|
|
|
- 'height' => '',
|
|
|
- 'gender' => '',
|
|
|
- 'age' => '',
|
|
|
- 'weight' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_back' => 1,
|
|
|
- ],
|
|
|
- 'HEART' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'heart',
|
|
|
- 'heart_rate' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_back' => 1,
|
|
|
- ],
|
|
|
- 'BLOOD' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'blood',
|
|
|
- 'blood_height_pressure' => '',
|
|
|
- 'blood_low_pressure' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_back' => 1,
|
|
|
- ],
|
|
|
- 'OXYGEN' => [
|
|
|
- 'content' => [
|
|
|
- 'command' => 'oxygen',
|
|
|
- 'oxygen' => '',
|
|
|
- ],
|
|
|
- 'kind' => 'tsend',
|
|
|
- 'need_back' => 1,
|
|
|
- ],
|
|
|
- ];
|
|
|
- if (!isset($data[$command])) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return $data[$command];
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取回复权重
|
|
|
- *
|
|
|
- * @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 'LK':
|
|
|
- case 'PING':
|
|
|
- case 'KA':
|
|
|
- case 'AL':
|
|
|
- case 'UD2';
|
|
|
- $weight = 1;
|
|
|
- break;
|
|
|
- case 'UPLOAD':
|
|
|
- case 'MONITOR':
|
|
|
- case 'SOS':
|
|
|
- case 'LANG':
|
|
|
- case 'ZONE':
|
|
|
- case 'CENTER':
|
|
|
- case 'SOSSMS':
|
|
|
- case 'REMOVE':
|
|
|
- case 'REMOVESMS':
|
|
|
- case 'VERNO':
|
|
|
- case 'CR':
|
|
|
- case 'SILENCETIME2':
|
|
|
- case 'WALKTIME':
|
|
|
- case 'SLEEPTIME':
|
|
|
- case 'FIND':
|
|
|
- case 'REMIND':
|
|
|
- case 'SCHEDULE':
|
|
|
- case 'PHB':
|
|
|
- case 'PHBX':
|
|
|
- case 'DPHBX':
|
|
|
- case 'MESSAGE':
|
|
|
- case 'FACTORY':
|
|
|
- case 'PROFILE':
|
|
|
- case 'BTEMP2':
|
|
|
- case 'BODYTEMP':
|
|
|
- case 'BTWARNSET':
|
|
|
- case 'APPLOCK':
|
|
|
- case 'HRTSTART':
|
|
|
- case 'BPHRT':
|
|
|
- case 'LSSET':
|
|
|
- $weight = 0;
|
|
|
- break;
|
|
|
- default:
|
|
|
- $weight = -1;
|
|
|
- break;
|
|
|
- }
|
|
|
- if ($weight < 0) {
|
|
|
- //不需设置 发送信息
|
|
|
- return false;
|
|
|
- }
|
|
|
- return $weight;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取设别表id
|
|
|
- *
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-11
|
|
|
- */
|
|
|
- public function getfacilityid($device_id_code)
|
|
|
- {
|
|
|
- $m_f = new FacilityModel();
|
|
|
- $where = ['code' => $device_id_code, 'status' => 1];
|
|
|
- $finfo = $m_f->getInfo($where, ['id']);
|
|
|
- if (empty($finfo)) {
|
|
|
- throw new \Exception("设备信息错误:" . $device_id_code);
|
|
|
- return false;
|
|
|
- }
|
|
|
- $id = $finfo['id'];
|
|
|
- return $id;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 创建发送信息
|
|
|
- *
|
|
|
- * @param [type] $data
|
|
|
- * @param [type] $command
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-14
|
|
|
- */
|
|
|
- public function createbacksendmsg($facility_id, $device_id_code, $data, $command)
|
|
|
- {
|
|
|
- $infoarr = $this->gettsendcommandinfo($command);
|
|
|
- if (!$infoarr) {
|
|
|
- Log::write("无对应命令数据1:" . $command, 'shouhuan');
|
|
|
- Log::write($data, 'shouhuan');
|
|
|
- return false;
|
|
|
- }
|
|
|
- $data = $this->getdata($data, $command, $infoarr);
|
|
|
- $info_content = $data['info_content'];
|
|
|
- $need_back = isset($data['need_back']) && $data['need_back'] ? true : false;
|
|
|
- if ($need_back) {
|
|
|
- $infoarr = $this->getcommandinfo($command);
|
|
|
- $data = $this->getdata($data, $command, $infoarr);
|
|
|
- $info_content = $data['info_content'];
|
|
|
- $weight = $this->getsendweight($command);
|
|
|
- $content = implode(',', $info_content);
|
|
|
- $msgdata = [
|
|
|
- 0 => '3G',
|
|
|
- 'device_id_code' => $device_id_code,
|
|
|
- 'len' => str_pad(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,
|
|
|
- 'send_msg' => $msg,
|
|
|
- 'send_time' => date('Y-m-d H:i:s'),
|
|
|
- 'send_weight' => $weight,
|
|
|
- ];
|
|
|
- $m_ssl = new ShoneSendListModel();
|
|
|
- $sslid = $m_ssl->insertData($sslInsertData);
|
|
|
- if (empty($sslid)) {
|
|
|
- throw new \Exception("发送数据添加失败");
|
|
|
- }
|
|
|
- $data = [
|
|
|
- 'msg' => $msg,
|
|
|
- 'weight' => $weight,
|
|
|
- 'createtime' => date('Y-m-d H:i:s'),
|
|
|
- 'device_id_code' => $device_id_code,
|
|
|
- 'list_id' => $sslid,
|
|
|
- ];
|
|
|
- $m_ssq = new ShoneSendQueueModel();
|
|
|
- $id = $m_ssq->insertData($data);
|
|
|
- if (empty($id)) {
|
|
|
- throw new \Exception("发送队列数据添加失败");
|
|
|
- }
|
|
|
- return $data;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取数据值
|
|
|
- *
|
|
|
- * @param [type] $data
|
|
|
- * @param [type] $command
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-14
|
|
|
- */
|
|
|
- public function getdata($data, $command, $infoarr)
|
|
|
- {
|
|
|
- $info_content = $infoarr['content'];
|
|
|
- foreach (array_keys($info_content) as $key => $value) {
|
|
|
- if (empty($info_content[$value])) {
|
|
|
- if (isset($data[$key])) {
|
|
|
- $info_content[$value] = $data[$key];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (isset($info_content['time'])) {
|
|
|
- $time = $info_content['time'];
|
|
|
- $info_content['time'] = $this->gettime($time);
|
|
|
- }
|
|
|
- if (isset($info_content['date'])) {
|
|
|
- $date = $info_content['date'];
|
|
|
- $info_content['date'] = $this->getdate($date);
|
|
|
- }
|
|
|
- $infoarr['info_content'] = $info_content;
|
|
|
- return $infoarr;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 保存接收信息队列
|
|
|
- *
|
|
|
- * @param [type] $data
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-14
|
|
|
- */
|
|
|
- public function savereceivequeue($data)
|
|
|
- {
|
|
|
- $m_srq = new ShoneReceiveQueueModel();
|
|
|
- $data = [
|
|
|
- 'msg' => $data,
|
|
|
- 'createtime' => date('Y-m-d H:i:s'),
|
|
|
- ];
|
|
|
- $id = $m_srq->insertData($data);
|
|
|
- //Log::write('id:' . $id, 'shouhuan');
|
|
|
- if (empty($id)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 保存手环信息
|
|
|
- *
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-14
|
|
|
- */
|
|
|
- public function saveshinfo($facility_id, $device_id_code, $data, $original_str)
|
|
|
- {
|
|
|
- $command = $data[0];
|
|
|
- $infoarr = $this->gettsendcommandinfo($command);
|
|
|
- if (!$infoarr) {
|
|
|
- Log::write("无对应命令数据2:" . $command, 'shouhuan');
|
|
|
- Log::write($original_str, 'shouhuan');
|
|
|
- return false;
|
|
|
- }
|
|
|
- $data = $this->getdata($data, $data[0], $infoarr);
|
|
|
- $m_sri = new ShoneReceiveInfoModel();
|
|
|
- $m_srir = new ShoneReceiveInfoRecode();
|
|
|
- $data = $data['info_content'];
|
|
|
- $data['facility_id'] = $facility_id;
|
|
|
- $data['device_id_code'] = $device_id_code;
|
|
|
-
|
|
|
- //$m_sri处理
|
|
|
- $sriwhere = [
|
|
|
- 'facility_id' => $facility_id,
|
|
|
- 'device_id_code' => $device_id_code,
|
|
|
- ];
|
|
|
- $sriinfo = $m_sri->getInfo($sriwhere);
|
|
|
- unset($data['command']);
|
|
|
- if (empty($sriinfo)) {
|
|
|
- $sriinsertData = $data;
|
|
|
- $sriinsertData['createtime'] = date('Y-m-d H:i:s');
|
|
|
- $sriinsertData = $m_sri->formatinfo($sriinsertData);
|
|
|
- $sriid = $m_sri->insertData($sriinsertData);
|
|
|
- if (empty($sriid)) {
|
|
|
- throw new \Exception("设备信息添加失败:" . $device_id_code);
|
|
|
- }
|
|
|
- } else {
|
|
|
- unset($data['device_id_code']);
|
|
|
- unset($data['facility_id']);
|
|
|
- $sriid = $sriinfo['id'];
|
|
|
- $sriupdateData = $data;
|
|
|
- $sriupdateData['updatetime'] = date('Y-m-d H:i:s');
|
|
|
- $sriupdateData = $m_sri->formatinfo($sriupdateData);
|
|
|
- $row = $m_sri->updateinfo(['id' => $sriid], $sriupdateData);
|
|
|
- if (empty($row)) {
|
|
|
- throw new \Exception("设备信息修改失败:" . $device_id_code);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //m_srir处理
|
|
|
- $data['original_str'] = $original_str;
|
|
|
- $sririnsertData = $data;
|
|
|
- $sririnsertData['facility_id'] = $facility_id;
|
|
|
- $sririnsertData['device_id_code'] = $device_id_code;
|
|
|
- $sririnsertData['createtime'] = date('Y-m-d H:i:s');
|
|
|
- $sririnsertData['command'] = $command;
|
|
|
- $sririd = $m_srir->insertData($sririnsertData);
|
|
|
- if (empty($sririd)) {
|
|
|
- throw new \Exception("设备历史信息添加失败:" . $device_id_code);
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取接收信息队列列表
|
|
|
- *
|
|
|
- * @param [type] $page
|
|
|
- * @param [type] $size
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-14
|
|
|
- */
|
|
|
- public function getreceivequeuelist($page = null, $size = null)
|
|
|
- {
|
|
|
- $m_srq = new ShoneReceiveQueueModel();
|
|
|
- $where = ['status' => 0];
|
|
|
- $size = empty($size) ? 20 : $size;
|
|
|
- if (empty($page)) {
|
|
|
- $count = $m_srq->getList($where, 'count');
|
|
|
- $totalpage = ceil($count / $size);
|
|
|
- $data = ['totalpage' => $totalpage, 'size' => $size];
|
|
|
- return $data;
|
|
|
- } else {
|
|
|
- $list = $m_srq->getList($where, '*', $page, $size, 'id asc');
|
|
|
- if (empty($list)) {
|
|
|
- //Log::write("手环接收信息队列-无数据", 'shouhuan');
|
|
|
- return false;
|
|
|
- }
|
|
|
- $list = $list->toArray();
|
|
|
- $ids = array_column($list, 'id');
|
|
|
- $updatecount = $m_srq->updateinfo(['id' => ['in', $ids], 'status' => 0], ['status' => 1]);
|
|
|
- if ($updatecount != count($ids)) {
|
|
|
- //Log::write("手环接收信息队列-部分未修改", 'shouhuan');
|
|
|
- $updatecount = empty($updatecount) ? 0 : (int) $updatecount;
|
|
|
- Log::write("count:" . count($ids) . " update count:" . $updatecount, 'shouhuan');
|
|
|
- }
|
|
|
- if (empty($updatecount)) {
|
|
|
- //Log::write("手环接收信息队列-无修改数据", 'shouhuan');
|
|
|
- return false;
|
|
|
- }
|
|
|
- return $list;
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取发送信息队列列表
|
|
|
- *
|
|
|
- * @param [type] $page
|
|
|
- * @param [type] $size
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-14
|
|
|
- */
|
|
|
- public function getsendqueuelist($device_id_code, $page = null, $size = null)
|
|
|
- {
|
|
|
- $m_ssq = new ShoneSendQueueModel();
|
|
|
- $where = ['status' => 0, 'device_id_code' => $device_id_code];
|
|
|
- $size = empty($size) ? 20 : $size;
|
|
|
- if (empty($page)) {
|
|
|
- $count = $m_ssq->getList($where, 'count');
|
|
|
- $totalpage = ceil($count / $size);
|
|
|
- $data = ['totalpage' => $totalpage, 'size' => $size];
|
|
|
- return $data;
|
|
|
- } else {
|
|
|
- $list = $m_ssq->getList($where, '*', $page, $size, 'id asc,weight desc');
|
|
|
- if (empty($list)) {
|
|
|
- Log::write("手环发送信息队列-无数据", 'shouhuan');
|
|
|
- return false;
|
|
|
- }
|
|
|
- $list = $list->toArray();
|
|
|
- $ids = array_column($list, 'id');
|
|
|
- $updatecount = $m_ssq->updateinfo(['id' => ['in', $ids], 'status' => 0], ['status' => 1]);
|
|
|
- if ($updatecount != count($ids)) {
|
|
|
- Log::write("手环发送信息队列-部分未修改", 'shouhuan');
|
|
|
- Log::write("count:" . count($ids) . " update count:" . $updatecount, 'shouhuan');
|
|
|
- }
|
|
|
- if (empty($updatecount)) {
|
|
|
- Log::write("手环发送信息队列-无修改数据", 'shouhuan');
|
|
|
- return false;
|
|
|
- }
|
|
|
- return $list;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function sendmsgsuccess($item)
|
|
|
- {
|
|
|
- $m_ssq = new ShoneSendQueueModel();
|
|
|
- $m_ssl = new ShoneSendListModel();
|
|
|
- $ssqid = $item['id'];
|
|
|
- if ($item['list_id']) {
|
|
|
- $list_id = $item['list_id'];
|
|
|
- $sslwhere = ['id' => $list_id, 'is_send' => 0];
|
|
|
- $sslinfo = $m_ssl->getInfo($sslwhere);
|
|
|
- if ($sslinfo) {
|
|
|
- $row = $m_ssl->updateinfo(['id' => $sslinfo['id']], ['is_send' => 1, 'send_time' => date('Y-m-d H:i:s')]);
|
|
|
- }
|
|
|
- }
|
|
|
- $ssqwhere = ['id' => $ssqid];
|
|
|
- $ssqinfo = $m_ssq->getInfo($ssqwhere);
|
|
|
- if ($ssqinfo) {
|
|
|
- $m_ssq->deleteinfobyid($ssqid);
|
|
|
- }
|
|
|
- }
|
|
|
- public function receivemsgsuccess($item)
|
|
|
- {
|
|
|
- $m_srq = new ShoneReceiveQueueModel();
|
|
|
- $srqid = $item['id'];
|
|
|
- $srqwhere = ['id' => $srqid, 'status' => 1];
|
|
|
- $srqinfo = $m_srq->getInfo($srqwhere);
|
|
|
- if ($srqinfo) {
|
|
|
- $m_srq->deleteinfobyid($srqid);
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 日期解析
|
|
|
- *
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-15
|
|
|
- */
|
|
|
- public function getdate($date)
|
|
|
- {
|
|
|
- $day = substr($date, 0, 2);
|
|
|
- $month = substr($date, 2, 2);
|
|
|
- $year = substr($date, 4, 2);
|
|
|
- $year1 = date('Y');
|
|
|
- $year2 = substr($year1, 0, 2);
|
|
|
- $year = $year2 . $year;
|
|
|
- if ($year != $year1) {
|
|
|
- $day = date('Y-m-d');
|
|
|
- } else {
|
|
|
- $day = $year . '-' . $month . '-' . $day;
|
|
|
- }
|
|
|
- return $day;
|
|
|
- }
|
|
|
- public function gettime($time)
|
|
|
- {
|
|
|
- $hour = substr($time, 0, 2);
|
|
|
- $minute = substr($time, 2, 2);
|
|
|
- $second = substr($time, 4, 2);
|
|
|
- $time = $hour . ':' . $minute . ':' . $second;
|
|
|
- return $time;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 初始化手环接收信息解析
|
|
|
- *
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-15
|
|
|
- */
|
|
|
- public function initanalysisShoneReceiveMsg()
|
|
|
- {
|
|
|
- $m_srq = new ShoneReceiveQueueModel();
|
|
|
- $where = ['status' => 1];
|
|
|
- $m_srq->updateinfo($where, ['status' => 0]);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 拆包
|
|
|
- *
|
|
|
- * @return void
|
|
|
- * @author wj
|
|
|
- * @date 2023-08-15
|
|
|
- */
|
|
|
- public function unpack($data)
|
|
|
- {
|
|
|
- $arr = explode("][", $data);
|
|
|
- foreach ($arr as $key => $value) {
|
|
|
- if ($value[0] !== "[") {
|
|
|
- $arr[$key] = '[' . $value;
|
|
|
- }
|
|
|
- if ($value[mb_strlen($value) - 1] !== "]") {
|
|
|
- $arr[$key] .= "]";
|
|
|
- }
|
|
|
- }
|
|
|
- return $arr;
|
|
|
- }
|
|
|
-
|
|
|
- public function showfortest($data)
|
|
|
- {
|
|
|
- $strdata = $this->getline($data);
|
|
|
- $content = $strdata['content_str'];
|
|
|
- $content = $this->getcommandcontent($content);
|
|
|
- $command = $content[0];
|
|
|
- $showcommands = ['SOS', 'CR', 'UPLOAD', 'SLEEPTIME'];
|
|
|
- if (in_array($command, $showcommands)) {
|
|
|
- var_dump($data);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|