cqpCow 11 mesiacov pred
rodič
commit
3d309315bc

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

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

+ 26 - 6
app/Service/JRFIDServerService.php

@@ -88,26 +88,46 @@ class JRFIDServerService extends Service
 
         $rsaService = new RsaEncryptionService();
         $dataToEncrypt = [
-            'id' => $data['id'],
+            'id' => [$data['id']],
             'type' => $data['type'],
         ];
         $encryptedData = $rsaService->encrypt(json_encode($dataToEncrypt));
 
         $url = config("j_rfid.get_print_data");
         $post = [
-            'encrypted_data' => $encryptedData,
+            '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['msg']];
+        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];
 
         return [true, $result];
     }
 
+    public function getTeam($data,$param){
+        if(empty($data['site'])) return [false, '站点不能为空'];
+
+        $url = config("j_rfid.get_team");
+        $post['rules'] = [
+            [
+                'field' => 'site',
+                'option' => 'LIKE_ANYWHERE',
+                'values' => [$data['site']]
+            ]
+        ];
+
+        list($status,$result) = $this->post_helper($url,json_encode($post),$param['header']);
+        if(! $status) return [false, $result];
+
+        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];
+
+        return [true, $result['content'] ?? []];
+    }
+
     public function post_helper($url, $data, $header = [], $timeout = 20){
-        file_put_contents('jrfid_record.txt',date('Y-m-d H:i:s') . "请求参数:" . $data . PHP_EOL . "请求头部:" . json_encode($header) . PHP_EOL,8);
+        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();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch,  CURLOPT_RETURNTRANSFER, true);
@@ -130,7 +150,7 @@ class JRFIDServerService extends Service
         }
         curl_close($ch);
 
-        file_put_contents('jrfid_record.txt',date('Y-m-d H:i:s') . "返回结果:" . $r . PHP_EOL,8);
+        file_put_contents('jrfid_record.txt',date('Y-m-d H:i:s') . PHP_EOL . "返回结果:" . $r . PHP_EOL,8);
         return [true, json_decode($r, true)];
     }
 
@@ -159,7 +179,7 @@ class JRFIDServerService extends Service
         }
 
         curl_close($ch);
-        file_put_contents('jrfid_record.txt',date('Y-m-d H:i:s') . "GET返回结果:" . $r . PHP_EOL,8);
+        file_put_contents('jrfid_record.txt',date('Y-m-d H:i:s') . PHP_EOL . "GET返回结果:" . $r . PHP_EOL,8);
         return [true, json_decode($r, true)];
     }
 }

+ 3 - 1
config/j_rfid.php

@@ -14,5 +14,7 @@ return [
     //生产订单查询接口
     'get_produce_by_contract' => 'https://gzy.qingyaokeji.com/api/module-data/produce_order/produce_order/diy/get_produce_by_contract',
     //打印数据获取接口
-    'get_print_data' => 'https://gzy.qingyaokeji.com/api/module-data/produce_order/produce_order/diy/get_produce_by_contract',
+    'get_print_data' => 'https://gzy.qingyaokeji.com/api/module-data/process_flow/process_flow/diy/get_process_data',
+    //班组查询
+    'get_team' => 'https://gzy.qingyaokeji.com/api/module-data/teams_group_list/page',
 ];

+ 2 - 0
routes/api.php

@@ -27,4 +27,6 @@ Route::group(['middleware'=> ['CheckJRFIDLogin']],function ($route){
     $route->any('getFlowByProduce', 'Api\JRFIDController@getFlowByProduce');
     //生产订单
     $route->any('getProduceByContract', 'Api\JRFIDController@getProduceByContract');
+    //获取班组
+    $route->any('getTeam', 'Api\JRFIDController@getTeam');
 });