cqpCow 11 maanden geleden
bovenliggende
commit
f60528de6e
4 gewijzigde bestanden met toevoegingen van 116 en 3 verwijderingen
  1. 20 0
      app/Http/Controllers/Api/JRFIDController.php
  2. 88 3
      app/Service/JRFIDServerService.php
  3. 4 0
      config/j_rfid.php
  4. 4 0
      routes/api.php

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

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

+ 88 - 3
app/Service/JRFIDServerService.php

@@ -88,7 +88,7 @@ class JRFIDServerService extends Service
 
         $rsaService = new RsaEncryptionService();
         $dataToEncrypt = [
-            'id' => [$data['id']],
+            'id' => $data['id'],
             'type' => $data['type'],
         ];
         $encryptedData = $rsaService->encrypt(json_encode($dataToEncrypt));
@@ -98,14 +98,60 @@ class JRFIDServerService extends Service
             'body' => $encryptedData,
         ];
 
-        list($status,$result) = $this->post_helper($url,json_encode($post),['Content-Type:application/json']);
+        list($status,$result) = $this->post_helper($url,json_encode($post),['Content-Type:application/json'],62);
         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 = $this->clearPrintData($data, $result);
 
         return [true, $result];
     }
 
+    public function clearPrintData($data,$result){
+        //分页参数
+        $size = $data['size'] ?? 10;
+        $number = $data['number'] ?? 1;
+
+        if(empty($result['furn_pro_flow_dt_a'])) return [];
+        $furn_pro_flow_dt_a = $result['furn_pro_flow_dt_a'];
+
+        //排序
+        usort($furn_pro_flow_dt_a, function($a, $b) {
+            return $b['id'] - $a['id'];
+        });
+
+        //总数
+        $total = count($furn_pro_flow_dt_a);
+        // 计算总页数
+        $totalPages = ceil($total / $size);
+        // 确保请求的页码在有效范围内
+        $page = $number;
+        // 计算当前页的起始索引
+        $offset = ($page - 1) * $size;
+        //切片数据以获取当前页的数据
+        $currentPageData = array_slice($furn_pro_flow_dt_a, $offset, $size);
+
+        if(empty($currentPageData)) return [];
+        unset($result['furn_pro_flow_dt_a']);
+
+        foreach ($furn_pro_flow_dt_a as $key => $value){
+            foreach ($result['furn_pro_flow_dt_assem'] as $v1){
+                if($v1['main_table_id'] == $value['id']){
+                    foreach ($result['furn_pro_flow_dt_comp'] as $v2){
+                        if($v2['main_table_id'] == $v1['id']) {dd(22);
+                            $v1['furn_pro_flow_dt_comp'][] = $v2;
+                        }
+                    }
+                    $furn_pro_flow_dt_a[$key]['furn_pro_flow_dt_assem'][] = $v1;
+                }
+            }
+        }
+
+        dd($furn_pro_flow_dt_a, 1);
+    }
+
     public function getTeam($data,$param){
         if(empty($data['site'])) return [false, '站点不能为空'];
 
@@ -115,15 +161,54 @@ class JRFIDServerService extends Service
                 'field' => 'site',
                 'option' => 'LIKE_ANYWHERE',
                 'values' => [$data['site']]
+            ],
+            [
+                'field' => 'is_used',
+                'option' => 'IN',
+                'values' => ['1']
             ]
         ];
+        $post['size'] = $data['size'] ?? 6;
+        $post['number'] = ($data['number'] ?? 1) - 1;
 
         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'] ?? []];
+        return [true, $result];
+    }
+
+    public function completionOrders($data,$param){
+        if(empty($data['exe_pro_flow_dtl_sub_c'])) return [false, '数据不能为空'];
+
+        $url = config("j_rfid.completion_orders");
+        $post['data'] = [
+            'exe_pro_flow_dtl_sub_c' => $data['exe_pro_flow_dtl_sub_c'],
+        ];
+
+        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['message']];
+
+        return [true, $result];
+    }
+
+    public function qualityOrders($data,$param){
+        if(empty($data['exe_pro_flow_dtl_sub_c'])) return [false, '数据不能为空'];
+
+        $url = config("j_rfid.quality_orders");
+        $post['data'] = [
+            'exe_pro_flow_dtl_sub_c' => $data['exe_pro_flow_dtl_sub_c'],
+        ];
+
+        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['message']];
+
+        return [true, $result];
     }
 
     public function post_helper($url, $data, $header = [], $timeout = 20){

+ 4 - 0
config/j_rfid.php

@@ -17,4 +17,8 @@ return [
     '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',
+    //完工
+    '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',
 ];

+ 4 - 0
routes/api.php

@@ -29,4 +29,8 @@ Route::group(['middleware'=> ['CheckJRFIDLogin']],function ($route){
     $route->any('getProduceByContract', 'Api\JRFIDController@getProduceByContract');
     //获取班组
     $route->any('getTeam', 'Api\JRFIDController@getTeam');
+    //完工
+    $route->any('completionOrders', 'Api\JRFIDController@completionOrders');
+    //质检
+    $route->any('qualityOrders', 'Api\JRFIDController@qualityOrders');
 });