wang jun 1 year ago
parent
commit
7c1ce22b85
2 changed files with 29 additions and 11 deletions
  1. 26 10
      application/common/server/ShOneanalysis.php
  2. 3 1
      application/workerman/ShTcp.php

+ 26 - 10
application/common/server/ShOneanalysis.php

@@ -536,7 +536,7 @@ class ShOneanalysis
             'createtime' => date('Y-m-d H:i:s'),
         ];
         $id = $m_srq->insertData($data);
-        Log::write('id:' . $id, 'shouhuan');
+        //Log::write('id:' . $id, 'shouhuan');
         if (empty($id)) {
             return false;
         }
@@ -555,7 +555,7 @@ class ShOneanalysis
         $infoarr = $this->gettsendcommandinfo($command);
         if (!$infoarr) {
             Log::write("无对应命令数据2:" . $command, 'shouhuan');
-            Log::write($data, 'shouhuan');
+            Log::write($original_str, 'shouhuan');
             return false;
         }
         $data = $this->getdata($data, $data[0], $infoarr);
@@ -599,6 +599,7 @@ class ShOneanalysis
         $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);
@@ -626,18 +627,19 @@ class ShOneanalysis
         } else {
             $list = $m_srq->getList($where, '*', $page, $size, 'id asc');
             if (empty($list)) {
-                Log::write("手环接收信息队列-无数据", 'shouhuan');
+                //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');
+                //Log::write("手环接收信息队列-部分未修改", 'shouhuan');
+                $updatecount = empty($updatecount) ? 0 : (int) $updatecount;
                 Log::write("count:" . count($ids) . " update count:" . $updatecount, 'shouhuan');
             }
             if (empty($updatecount)) {
-                Log::write("手环接收信息队列-无修改数据", 'shouhuan');
+                //Log::write("手环接收信息队列-无修改数据", 'shouhuan');
                 return false;
             }
             return $list;
@@ -688,11 +690,13 @@ class ShOneanalysis
         $m_ssq = new ShoneSendQueueModel();
         $m_ssl = new ShoneSendListModel();
         $ssqid = $item['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')]);
+        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);
@@ -773,4 +777,16 @@ class ShOneanalysis
         }
         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);
+        }
+    }
 }

+ 3 - 1
application/workerman/ShTcp.php

@@ -38,6 +38,7 @@ class ShTcp extends Server
                             $list = $server_sa->getsendqueuelist($device_id_code, 1, $size);
                             foreach ($list as $key => $value) {
                                 $connection->send($value['msg']);
+                                $server_sa->showfortest($value['msg']);
                                 $server_sa->sendmsgsuccess($value);
                             }
                         }
@@ -94,10 +95,11 @@ class ShTcp extends Server
     }
     public function onMessage($connection, $data)
     {
-        Log::write($data, 'shouhuan');
+        //Log::write($data, 'shouhuan');
         $server_sa = new ShOneanalysis();
         $datas = (array) $server_sa->unpack($data);
         foreach ($datas as $key => $data) {
+            $server_sa->showfortest($data);
             try {
                 $result = $server_sa->savereceivequeue($data);
                 if (empty($result)) {