wang jun 1 year ago
parent
commit
3a3055dca3
2 changed files with 19 additions and 8 deletions
  1. 13 3
      application/common/server/ShOneanalysis.php
  2. 6 5
      application/workerman/ShTcp.php

+ 13 - 3
application/common/server/ShOneanalysis.php

@@ -350,11 +350,11 @@ class ShOneanalysis
     {
         $infoarr = $this->gettsendcommandinfo($command);
         if (!$infoarr) {
-            throw new \Exception("无对应命令数据:" . $command);
+            throw new \Exception("无对应命令数据1:" . $command);
         }
         $data = $this->getdata($data, $command, $infoarr);
         $info_content = $data['info_content'];
-        $need_back = $data['need_back'];
+        $need_back = isset($data['need_back']) && $data['need_back'] ? true : false;
         if ($need_back) {
             $infoarr = $this->getcommandinfo($command);
             $data = $this->getdata($data, $command, $infoarr);
@@ -452,7 +452,7 @@ class ShOneanalysis
         $command = $data[0];
         $infoarr = $this->gettsendcommandinfo($command);
         if (!$infoarr) {
-            throw new \Exception("无对应命令数据:" . $command);
+            throw new \Exception("无对应命令数据2:" . $command);
         }
         $data = $this->getdata($data, $data[0], $infoarr);
         $m_sri = new ShoneReceiveInfoModel();
@@ -592,4 +592,14 @@ class ShOneanalysis
             $m_ssq->deleteinfobyid($ssqid);
         }
     }
+    public function receivemsgsuccess($item)
+    {
+        $m_srq = new ShoneReceiveQueueModel();
+        $srqid = $item['id'];
+        $srqwhere = ['id' => $srqid, 'is_send' => 0];
+        $srqinfo = $m_srq->getInfo($srqwhere);
+        if ($srqinfo) {
+            $m_srq->deleteinfobyid($srqid);
+        }
+    }
 }

+ 6 - 5
application/workerman/ShTcp.php

@@ -8,8 +8,8 @@ use Workerman\Lib\Timer;
 
 class ShTcp extends Server
 {
-    //protected $socket = 'tcp://0.0.0.0:21444';
-    protected $socket = 'tcp://0.0.0.0:9501';
+    protected $socket = 'tcp://0.0.0.0:21444';
+    //protected $socket = 'tcp://0.0.0.0:9501';
 
     protected function init()
     {
@@ -36,6 +36,7 @@ class ShTcp extends Server
                         for ($page = 1; $page <= $totalpage; $page++) {
                             $list = $server_sa->getsendqueuelist($device_id_code, 1, $size);
                             foreach ($list as $key => $value) {
+                                var_dump('send sq:' . $value['id']);
                                 $connection->send(json_encode($value['msg']));
                                 $server_sa->sendmsgsuccess($value);
                             }
@@ -70,9 +71,9 @@ class ShTcp extends Server
         if (empty($result)) {
             Log::write("手环接收信息队列,数据保存失败", 'shouhuan');
         }
-        //$line = $server_sa->getline($data);
-        //$this->device_id_code = $line['device_id_code'];
-        $this->device_id_code = "358800006072996";
+        $line = $server_sa->getline($data);
+        $this->device_id_code = $line['device_id_code'];
+        //$this->device_id_code = "358800006072996";
     }
 
     public function onClose($connection)