Ver Fonte

打印机添加

shish há 5 anos atrás
pai
commit
2fc7f7ffcc
1 ficheiros alterados com 27 adições e 2 exclusões
  1. 27 2
      common/components/printUtil.php

+ 27 - 2
common/components/printUtil.php

@@ -69,10 +69,35 @@ class printUtil
         $client = new \HttpClient(self::IP, self::PORT);
         if (!$client->post(self::PATH, $msgInfo)) {
             return false;
-        } else {
-            $client->getContent();
+        }
+        $content = $client->getContent();
+        $respond = json_decode($content, true);
+        if (isset($respond['data']['ok']) && !empty($respond['data']['ok'])) {
+            return true;
+        }
+        $no = $respond['data']['no'][0] ?? '';
+        if (strstr($no, "已被添加过")) {
             return true;
         }
+        return false;
+    }
+
+    //查询打印机状态 shish 20210714
+    public function queryPrinterStatus($sn)
+    {
+        $time = time();         //请求时间
+        $msgInfo = array(
+            'user' => $this->user,
+            'stime' => $time,
+            'sig' => $this->signature($time),
+            'apiname' => 'Open_queryPrinterStatus',
+            'sn' => $sn
+        );
+        $client = new \HttpClient(self::IP, self::PORT);
+        if (!$client->post(self::PATH, $msgInfo)) {
+            echo 'error';
+        }
+        $client->getContent();
     }
 
 }