cqpCow преди 11 месеца
родител
ревизия
111a355a25
променени са 4 файла, в които са добавени 41 реда и са изтрити 1 реда
  1. 10 0
      app/Http/Controllers/Api/JRFIDController.php
  2. 28 1
      app/Service/JRFIDServerService.php
  3. 2 0
      config/j_rfid.php
  4. 1 0
      routes/api.php

+ 10 - 0
app/Http/Controllers/Api/JRFIDController.php

@@ -75,4 +75,14 @@ class JRFIDController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function screenPrint(Request $request){
+        list($bool, $data) = (new JRFIDServerService())->screenPrint($request->all());
+
+        if($bool){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 28 - 1
app/Service/JRFIDServerService.php

@@ -98,7 +98,7 @@ class JRFIDServerService extends Service
             'body' => $encryptedData,
         ];
 
-        list($status,$result) = $this->post_helper($url,json_encode($post),['Content-Type:application/json'],62);
+        list($status,$result) = $this->post_helper($url,json_encode($post),['Content-Type:application/json']);
         if(! $status) return [false, $result];
 
         if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];
@@ -211,6 +211,33 @@ class JRFIDServerService extends Service
         return [true, $result];
     }
 
+    public function screenPrint($data){
+        if(empty($data['id'])) return [false, '数据ID不能为空'];
+        if(empty($data['type'])) return [false, 'TYPE不能为空'];
+        if(empty($data['print_type'])) return [false, 'PRINTTYPE不能为空'];
+
+        $rsaService = new RsaEncryptionService();
+        $dataToEncrypt = [
+            'id' => $data['id'],
+            'type' => $data['type'],
+            'print_type' => $data['print_type']
+        ];
+        $encryptedData = $rsaService->encrypt(json_encode($dataToEncrypt));
+
+        $url = config("j_rfid.screen_print");
+        $post = [
+            'body' => $encryptedData,
+        ];
+
+        list($status,$result) = $this->post_helper($url,json_encode($post),['Content-Type:application/json']);
+        if(! $status) return [false, $result];
+
+        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];
+        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];
+
+        return [true, $result];
+    }
+
     public function post_helper($url, $data, $header = [], $timeout = 20){
         file_put_contents('jrfid_record.txt',date('Y-m-d H:i:s') . PHP_EOL. "请求API:" . $url . PHP_EOL . "请求参数:" .  $data . PHP_EOL . "请求头部:" . json_encode($header) . PHP_EOL,8);
         $ch = curl_init();

+ 2 - 0
config/j_rfid.php

@@ -21,4 +21,6 @@ return [
     'completion_orders' => 'https://gzy.qingyaokeji.com/api/module-data/process_flow/process_flow/diy/completion_orders',
     //质检
     'quality_orders' => 'https://gzy.qingyaokeji.com/api/module-data/process_flow/process_flow/diy/quality_orders',
+    //打印
+    'screen_print' => 'https://gzy.qingyaokeji.com/api/module-data/furn_process_flow_dt/process_flow_dt/diy/screen_print',
 ];

+ 1 - 0
routes/api.php

@@ -21,6 +21,7 @@ Route::any('login', 'Api\LoginController@login');
 //站点获取
 Route::any('getSite', 'Api\JRFIDController@getSite');
 Route::any('getPrintData', 'Api\JRFIDController@getPrintData');
+Route::any('screenPrint', 'Api\JRFIDController@screenPrint');
 
 Route::group(['middleware'=> ['CheckJRFIDLogin']],function ($route){
     //工艺流程单