Browse Source

Merge remote-tracking branch 'origin/master'

gogs 1 year ago
parent
commit
4fa218c321

+ 16 - 1
app/Http/Controllers/Api/ScreenController.php

@@ -300,6 +300,11 @@ class ScreenController extends BaseController
 //        $end = isset($request['start_time']) ? $request['start_time'] : time();
 //        $end = isset($request['start_time']) ? $request['start_time'] : time();
         $key = DeviceSite::where('site',1)->wherein('title',['主缸压力','压力'])->groupBy('key')->pluck('key')->toArray();
         $key = DeviceSite::where('site',1)->wherein('title',['主缸压力','压力'])->groupBy('key')->pluck('key')->toArray();
         $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select(DB::raw("DATE_FORMAT(FROM_UNIXTIME(crt_time), '%Y-%m-%d %H:%i') as c"),'device_name','happening_data')->get()->toArray();
         $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select(DB::raw("DATE_FORMAT(FROM_UNIXTIME(crt_time), '%Y-%m-%d %H:%i') as c"),'device_name','happening_data')->get()->toArray();
+        if(empty($list)) {
+            $time = DeviceData::max('crt_time');
+            $s_time = $time-8000;
+            $list = DeviceData::where('crt_time','>=',$s_time)->wherein('dev_eui',$key)->select(DB::raw("DATE_FORMAT(FROM_UNIXTIME(crt_time), '%Y-%m-%d %H:%i') as c"),'device_name','happening_data')->get()->toArray();
+        }
 
 
         $list_key = [];
         $list_key = [];
         $device_key = [];
         $device_key = [];
@@ -314,7 +319,12 @@ class ScreenController extends BaseController
 //        die('ss');
 //        die('ss');
         $time_list = [];
         $time_list = [];
         $data_key = [];
         $data_key = [];
-        for ($i=$start;$i<time();$i= $i+60){
+        $count = time();
+        if(! empty($time)) {
+            $start = $s_time;
+            $count = $time;
+        }
+        for ($i=$start;$i<$count;$i= $i+60){
             $time_key = date('Y-m-d H:i',$i);
             $time_key = date('Y-m-d H:i',$i);
             $time_list[] = $time_key;
             $time_list[] = $time_key;
             foreach ($device_key as $v){
             foreach ($device_key as $v){
@@ -438,6 +448,11 @@ class ScreenController extends BaseController
 //        $end = isset($request['start_time']) ? $request['start_time'] : time();
 //        $end = isset($request['start_time']) ? $request['start_time'] : time();
         $key = DeviceSite::where('site',1)->wherein('title',['温度'])->groupBy('key')->pluck('key')->toArray();
         $key = DeviceSite::where('site',1)->wherein('title',['温度'])->groupBy('key')->pluck('key')->toArray();
         $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select(DB::raw('count(1) as count'),'device_name')->groupBy('dev_eui')->get()->toArray();
         $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select(DB::raw('count(1) as count'),'device_name')->groupBy('dev_eui')->get()->toArray();
+        if(empty($list)){
+            $time = DeviceData::max('crt_time');
+            $s_time = $time-100000;
+            $list = DeviceData::where('crt_time','>=',$s_time)->wherein('dev_eui',$key)->select(DB::raw('count(1) as count'),'device_name')->groupBy('dev_eui')->get()->toArray();
+        }
         foreach ($list as &$v){
         foreach ($list as &$v){
             $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
             $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
         }
         }

+ 410 - 18
app/Jobs/DoorDeviceJob.php

@@ -48,34 +48,101 @@ class DoorDeviceJob implements ShouldQueue
             $order_number = [];
             $order_number = [];
             foreach ($epc as $value){
             foreach ($epc as $value){
                 $str = @hex2bin($value);
                 $str = @hex2bin($value);
-                $str = ltrim($str, "\x00");
+                $str = ltrim($str, "\x00");// 代0字符串
+                $str = str_replace(chr(26), '', $str); //过滤CRTL-Z字符
                 if(! empty($str) && substr($str, 0, 2) === "BZ"){
                 if(! empty($str) && substr($str, 0, 2) === "BZ"){
                     if(! in_array($str, $order_number)) $order_number[] = $str; // 十六进制字符串转回原来字符串
                     if(! in_array($str, $order_number)) $order_number[] = $str; // 十六进制字符串转回原来字符串
                 }
                 }
-//                $order_number[] = hex2bin($value); //十六进制字符串转回 原来字符串
-            }
-            file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time())."原数据:".json_encode($epc) . "解析后:" . json_encode($order_number) .PHP_EOL.'start'.PHP_EOL,8);
-            if(empty($order_number)) {
-                file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time()).'start_end'.PHP_EOL,8);
-                return;
             }
             }
+            file_put_contents('record_door_data.txt',date("Y-m-d H:i:s",time())."原数据:".json_encode($epc) . "解析后:" . json_encode($order_number) .PHP_EOL.'start'.PHP_EOL,8);
+            if(empty($order_number)) return;
 
 
-            //获取包装单产品
-            $dispatchList = $this->getDispatchList($order_number);
-            if(empty($dispatchList) || empty($dispatchList['data'])) {
-                file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time()).'getlist_end'.PHP_EOL,8);
-                return;
-            }
-            $this->completionOrders($dispatchList['data'],$type);
+            $this->zs($type,$order_number);
 
 
             //输出信息 测试
             //输出信息 测试
             $this->echoMessage(new ConsoleOutput());
             $this->echoMessage(new ConsoleOutput());
         }catch (\Exception $exception){
         }catch (\Exception $exception){
-            file_put_contents('record_door_error.txt',date("Y-m-d H:i:s",time()).json_encode($this->data) . PHP_EOL.$exception->getMessage().PHP_EOL,8);
+            file_put_contents('record_door_error.txt',date("Y-m-d H:i:s",time()).json_encode($this->data) . PHP_EOL.$exception->getMessage()."line" . $exception->getLine().PHP_EOL,8);
         }
         }
     }
     }
 
 
-    public function getDispatchList($data){
+    //测试--------------------------------------
+    public function getDeviceStateCs($data){
+        if(empty($data)) return [];
+        list($status,$token) = ClearDataService::getTokenCs();
+        if(! $status) return [];
+
+        $site = $this->site;
+        $url = "http://121.36.142.167:7774/jbl/api/module-data/device/device/diy/machine_code_list";
+        $post = [
+            'machine_code_list' => $data,
+        ];
+        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
+        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
+
+        $curl = curl_init();
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => $url,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'POST',
+            CURLOPT_POSTFIELDS => $json,
+            CURLOPT_HTTPHEADER => $header,
+        ));
+        $response = curl_exec($curl);
+        curl_close($curl);
+
+        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getDoorState'.PHP_EOL,8);
+        $result = json_decode($response,true);
+        if(empty($result)) return false;
+        $first = $result[0];
+        return $first['status'];
+    }
+
+    public function productionReceiptCs($data){
+        list($status,$token) = ClearDataService::getTokenCs();
+        if(! $status) return;
+
+        $site = $this->site;
+        $url = "http://121.36.142.167:7774/jbl/api/module-data/box_orders/box_orders/diy/production_receipt";
+        $post = [
+            'defective_order_no_list' => $data,
+        ];
+        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
+        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
+
+        $curl = curl_init();
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => $url,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'POST',
+            CURLOPT_POSTFIELDS => $json,
+            CURLOPT_HTTPHEADER => $header,
+        ));
+        $response = curl_exec($curl);
+        curl_close($curl);
+
+        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'in_opt'.PHP_EOL,8);
+
+        $return = json_decode($response,true);
+        if(! empty($return['data'])){
+            $expire_time = 10;
+            $key = $this->device_id . InOutOptionService::OrderKeyQueueIn;
+            Redis::set($key, json_encode($return['data']));
+            Redis::expire($key, $expire_time);
+        }
+    }
+
+    public function getDispatchListCs($data){
         if(empty($data)) return [];
         if(empty($data)) return [];
         list($status,$token) = ClearDataService::getTokenCs();
         list($status,$token) = ClearDataService::getTokenCs();
         if(! $status) return [];
         if(! $status) return [];
@@ -104,12 +171,12 @@ class DoorDeviceJob implements ShouldQueue
         $response = curl_exec($curl);
         $response = curl_exec($curl);
         curl_close($curl);
         curl_close($curl);
 
 
-        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getlist'.PHP_EOL,8);
+        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getlist'.PHP_EOL,8);
 
 
         return json_decode($response,true);
         return json_decode($response,true);
     }
     }
 
 
-    public function completionOrders($data,$type){
+    public function completionOrdersCs($data,$type){
         list($status,$token) = ClearDataService::getTokenCs();
         list($status,$token) = ClearDataService::getTokenCs();
         if(! $status) return;
         if(! $status) return;
 
 
@@ -154,8 +221,13 @@ class DoorDeviceJob implements ShouldQueue
             $url = 'http://121.36.142.167:7774/jbl/api/module-data/picking_out/picking_out';
             $url = 'http://121.36.142.167:7774/jbl/api/module-data/picking_out/picking_out';
             $dynamicFormId = "473763313217908736";
             $dynamicFormId = "473763313217908736";
             $showModelId = "473771977253269504";
             $showModelId = "473771977253269504";
+            $item = 0;
+            $site_b = $site_b_show = "";
             foreach ($data as $value){
             foreach ($data as $value){
                 if(empty($value['box_orders']['delivery_status'])){
                 if(empty($value['box_orders']['delivery_status'])){
+                    $item = $item + 1;
+                    if(empty($site_b)) $site_b = $value['site'];
+                    if(empty($site_b_show)) $site_b_show = $value['site_show'];
                     $main_dtl[] = [
                     $main_dtl[] = [
                         "product_code"=> $value['brand_code'],
                         "product_code"=> $value['brand_code'],
                         "product_title"=> $value['product_title'],
                         "product_title"=> $value['product_title'],
@@ -167,6 +239,20 @@ class DoorDeviceJob implements ShouldQueue
                         "color_code"=> $value['color_code'],
                         "color_code"=> $value['color_code'],
                         "color_code_two"=> $value['color_code_two'],
                         "color_code_two"=> $value['color_code_two'],
                         "in_num"=> $value['box_num'],
                         "in_num"=> $value['box_num'],
+                        "bus_type" => "BOX",
+                        "bus_type_show" => "包装明细",
+                        "bus_id" => $value['box_orders']['id'],
+                        "bus_no" => $value['box_orders']['defective_order_no'],
+                        "item_num" => $item,
+                        "bus_item_no" => $value['item_num'],
+                        "bus_item_id" => $value['id'],
+                        "order_no" => $value['order_no'],
+                        "customer_no" => $value['customer_no'],
+                        "customer_name" => $value['customer_name'],
+                        "dealer_no" => $value['dealer_no'],
+                        "dealer_name" => $value['dealer_name'],
+                        "site" => $value['site'],
+                        "site_show" => $value['site_show'],
                     ];
                     ];
                     if(! in_array($value['box_orders']['defective_order_no'], $orderNo)) $orderNo[] = $value['box_orders']['defective_order_no'];
                     if(! in_array($value['box_orders']['defective_order_no'], $orderNo)) $orderNo[] = $value['box_orders']['defective_order_no'];
                 }
                 }
@@ -178,6 +264,10 @@ class DoorDeviceJob implements ShouldQueue
                     'box_title' => 'WH05001',
                     'box_title' => 'WH05001',
                     'out_time' => gmdate("Y-m-d\TH:i:s.000\Z"),
                     'out_time' => gmdate("Y-m-d\TH:i:s.000\Z"),
                     'status' => "NOT_APPROVED",
                     'status' => "NOT_APPROVED",
+                    'in_out_type_show' => "通道门成品出库",
+                    'box_title_show' => "成品仓",
+                    "site" => $site_b,
+                    "site_show" => $site_b_show
                 ],
                 ],
                 'picking_out_product' => $main_dtl
                 'picking_out_product' => $main_dtl
             ];
             ];
@@ -194,6 +284,284 @@ class DoorDeviceJob implements ShouldQueue
             ];
             ];
         }
         }
         //组织数据------
         //组织数据------
+        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . json_encode($post) .PHP_EOL.'post'.PHP_EOL,8);
+
+        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
+
+        $curl = curl_init();
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => $url,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'POST',
+            CURLOPT_POSTFIELDS => json_encode($post),
+            CURLOPT_HTTPHEADER => $header,
+        ));
+        $response = curl_exec($curl);
+        curl_close($curl);
+
+        $result = json_decode($response,true);
+        if(! empty($result['createdDate'])) {
+            $expire_time = 10;
+            $key = $device_id . $opt;
+            Redis::set($key, json_encode($orderNo));
+            Redis::expire($key, $expire_time);
+        }
+
+        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'create'.PHP_EOL,8);
+    }
+
+    public function cs($type,$order_number){
+        //获取是否开启通道门
+        $bool = $this->getDeviceStateCs([$this->device_id]);
+        if(! $bool) {
+            file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time()).'door_not_open'.PHP_EOL,8);
+            return;
+        }
+
+        if($type == 1){
+            //入库
+            $this->productionReceiptCs($order_number);
+        }else{
+            //出库
+            //获取包装单产品
+            $dispatchList = $this->getDispatchListCs($order_number);
+            if(empty($dispatchList) || empty($dispatchList['data'])) {
+                file_put_contents('record_door_result_cs.txt',date("Y-m-d H:i:s",time()).'getlist_end'.PHP_EOL,8);
+                return;
+            }
+            $this->completionOrdersCs($dispatchList['data'],$type);
+        }
+    }
+    //测试--------------------------------------
+
+
+    //正式--------------------------------------
+    public function getDeviceState($data){
+        if(empty($data)) return [];
+        list($status,$token) = ClearDataService::getToken();
+        if(! $status) return [];
+
+        $site = $this->site;
+        $url = "http://122.112.250.253:7774/jbl/api/module-data/device/device/diy/machine_code_list";
+        $post = [
+            'machine_code_list' => $data,
+        ];
+        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
+        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
+
+        $curl = curl_init();
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => $url,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'POST',
+            CURLOPT_POSTFIELDS => $json,
+            CURLOPT_HTTPHEADER => $header,
+        ));
+        $response = curl_exec($curl);
+        curl_close($curl);
+
+        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getDoorState'.PHP_EOL,8);
+        $result = json_decode($response,true);
+        if(empty($result)) return false;
+        $first = $result[0];
+        return $first['status'];
+    }
+
+    public function productionReceipt($data){
+        list($status,$token) = ClearDataService::getToken();
+        if(! $status) return;
+
+        $site = $this->site;
+        $url = "http://122.112.250.253:7774/jbl/api/module-data/box_orders/box_orders/diy/production_receipt";
+        $post = [
+            'defective_order_no_list' => $data,
+        ];
+        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
+        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
+
+        $curl = curl_init();
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => $url,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'POST',
+            CURLOPT_POSTFIELDS => $json,
+            CURLOPT_HTTPHEADER => $header,
+        ));
+        $response = curl_exec($curl);
+        curl_close($curl);
+
+        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'in_opt'.PHP_EOL,8);
+
+        $return = json_decode($response,true);
+        if(! empty($return['data'])){
+            $expire_time = 10;
+            $key = $this->device_id . InOutOptionService::OrderKeyQueueIn;
+            Redis::set($key, json_encode($return['data']));
+            Redis::expire($key, $expire_time);
+        }
+    }
+
+    public function getDispatchList($data){
+        if(empty($data)) return [];
+        list($status,$token) = ClearDataService::getToken();
+        if(! $status) return [];
+
+        $site = $this->site;
+        $url = "http://122.112.250.253:7774/jbl/api/module-data/box_orders/box_orders/diy/defective_order_no_list";
+        $post = [
+            'defective_order_no_list' => $data,
+        ];
+        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
+        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
+
+        $curl = curl_init();
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => $url,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'POST',
+            CURLOPT_POSTFIELDS => $json,
+            CURLOPT_HTTPHEADER => $header,
+        ));
+        $response = curl_exec($curl);
+        curl_close($curl);
+
+        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getlist'.PHP_EOL,8);
+
+        return json_decode($response,true);
+    }
+
+    public function completionOrders($data,$type){
+        list($status,$token) = ClearDataService::getToken();
+        if(! $status) return;
+
+        $site = $this->site;
+        $device_id = $this->device_id;
+        //组织数据
+        $main_dtl = $orderNo = [];
+        if($type == 1){
+            $opt = InOutOptionService::OrderKeyQueueIn;
+            $url = 'http://122.112.250.253:7774/jbl/api/module-data/production_receipt/production_receipt';
+            $dynamicFormId = "473758926009479168";
+            $showModelId = "473761325902147584";
+            foreach ($data as $value){
+                if(empty($value['box_orders']['delivery_status'])){
+                    $main_dtl[] = [
+                        "product_code"=> $value['brand_code'],
+                        "product_title"=> $value['product_title'],
+                        "product_size"=> $value['product_size'],
+                        "color"=> $value['color'],
+                        "color_two"=> $value['color_two'],
+                        "product_unit_title"=> $value['product_unit_title'],
+                        "product_unit"=> $value['product_unit'],
+                        "color_code"=> $value['color_code'],
+                        "color_code_two"=> $value['color_code_two'],
+                        "in_num"=> $value['box_num'],
+                    ];
+                    if(! in_array($value['box_orders']['defective_order_no'], $orderNo)) $orderNo[] = $value['box_orders']['defective_order_no'];
+                }
+            }
+            $datas = [
+                'production_receipt' => [
+                    'production_receipt_no' => null,
+                    'in_out_type' => 'RK007',
+                    'box_title' => 'WH05001',
+                    'in_time' => gmdate("Y-m-d\TH:i:s.000\Z"),
+                    'status' => "NOT_APPROVED",
+                ],
+                'production_receipt_dtl' => $main_dtl
+            ];
+        }else{
+            $opt = InOutOptionService::OrderKeyQueueOut;
+            $url = 'http://122.112.250.253:7774/jbl/api/module-data/picking_out/picking_out';
+            $dynamicFormId = "473763313217908736";
+            $showModelId = "473771977253269504";
+            $item = 0;
+            $site_b = $site_b_show = "";
+            foreach ($data as $value){
+                if(empty($value['box_orders']['delivery_status'])){
+                    $item = $item + 1;
+                    if(empty($site_b)) $site_b = $value['site'];
+                    if(empty($site_b_show)) $site_b_show = $value['site_show'];
+                    $main_dtl[] = [
+                        "product_code"=> $value['brand_code'],
+                        "product_title"=> $value['product_title'],
+                        "product_size"=> $value['product_size'],
+                        "color"=> $value['color'],
+                        "color_two"=> $value['color_two'],
+                        "product_unit_title"=> $value['product_unit_title'],
+                        "product_unit"=> $value['product_unit'],
+                        "color_code"=> $value['color_code'],
+                        "color_code_two"=> $value['color_code_two'],
+                        "in_num"=> $value['box_num'],
+                        "bus_type" => "BOX",
+                        "bus_type_show" => "包装明细",
+                        "bus_id" => $value['box_orders']['id'],
+                        "bus_no" => $value['box_orders']['defective_order_no'],
+                        "item_num" => $item,
+                        "bus_item_no" => $value['item_num'],
+                        "bus_item_id" => $value['id'],
+                        "order_no" => $value['order_no'],
+                        "customer_no" => $value['customer_no'],
+                        "customer_name" => $value['customer_name'],
+                        "dealer_no" => $value['dealer_no'],
+                        "dealer_name" => $value['dealer_name'],
+                        "site" => $value['site'],
+                        "site_show" => $value['site_show'],
+                    ];
+                    if(! in_array($value['box_orders']['defective_order_no'], $orderNo)) $orderNo[] = $value['box_orders']['defective_order_no'];
+                }
+            }
+            $datas = [
+                'picking_out' => [
+                    'picking_out_no' => null,
+                    'in_out_type' => 'CK010',
+                    'box_title' => 'WH05001',
+                    'out_time' => gmdate("Y-m-d\TH:i:s.000\Z"),
+                    'status' => "NOT_APPROVED",
+                    'in_out_type_show' => "通道门成品出库",
+                    'box_title_show' => "成品仓",
+                    "site" => $site_b,
+                    "site_show" => $site_b_show
+                ],
+                'picking_out_product' => $main_dtl
+            ];
+        }
+
+        if(! empty($main_dtl)){
+            //有产品
+            $post = [
+                "bizTypeEk" => "LOWCODE",
+                "bizId" => -1,
+                "data" => $datas,
+                "dynamicFormId" => $dynamicFormId,
+                "showModelId" => $showModelId
+            ];
+        }else{
+            file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . "no_products" .PHP_EOL.'post'.PHP_EOL,8);
+            return;
+        }
+
+        //组织数据------
         file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . json_encode($post) .PHP_EOL.'post'.PHP_EOL,8);
         file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . json_encode($post) .PHP_EOL.'post'.PHP_EOL,8);
 
 
         $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
         $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
@@ -225,6 +593,30 @@ class DoorDeviceJob implements ShouldQueue
         file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'create'.PHP_EOL,8);
         file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'create'.PHP_EOL,8);
     }
     }
 
 
+    public function zs($type,$order_number){
+        //获取是否开启通道门
+        $bool = $this->getDeviceState([$this->device_id]);
+        if(! $bool) {
+            file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time()).'door_not_open'.PHP_EOL,8);
+            return;
+        }
+
+        if($type == 1){
+            //入库
+            $this->productionReceipt($order_number);
+        }else{
+            //出库
+            //获取包装单产品
+            $dispatchList = $this->getDispatchList($order_number);
+            if(empty($dispatchList) || empty($dispatchList['data'])) {
+                file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time()).'getlist_end'.PHP_EOL,8);
+                return;
+            }
+            $this->completionOrders($dispatchList['data'],$type);
+        }
+    }
+    //正式--------------------------------------
+
     protected function echoMessage(OutputInterface $output)
     protected function echoMessage(OutputInterface $output)
     {
     {
         $output->writeln($this->data);
         $output->writeln($this->data);

+ 8 - 2
app/Service/InOutOptionService.php

@@ -59,6 +59,7 @@ class InOutOptionService extends Service
                 if(! in_array($order_it, $tmp)){
                 if(! in_array($order_it, $tmp)){
                     $str = @hex2bin($order['epc']);
                     $str = @hex2bin($order['epc']);
                     $str = ltrim($str, "\x00");
                     $str = ltrim($str, "\x00");
+                    $str = str_replace(chr(26), '', $str); //过滤CRTL-Z字符
                     if(! empty($str) && substr($str, 0, 2) === "BZ"){
                     if(! empty($str) && substr($str, 0, 2) === "BZ"){
                         $order['epc'] = $str;
                         $order['epc'] = $str;
                         $order['site'] = $site;
                         $order['site'] = $site;
@@ -76,8 +77,9 @@ class InOutOptionService extends Service
         if(! empty($res)){
         if(! empty($res)){
             $return  = json_decode($res,true);
             $return  = json_decode($res,true);
             foreach ($return as $value){
             foreach ($return as $value){
+                $str = str_replace(chr(26), '', $value); //过滤CRTL-Z字符
                 $result[] = [
                 $result[] = [
-                    'epc' => $value,
+                    'epc' => $str,
                     'direction' => '1',
                     'direction' => '1',
                 ];
                 ];
             }
             }
@@ -111,7 +113,11 @@ class InOutOptionService extends Service
             if(Redis::exists($key)) Redis::del($key);
             if(Redis::exists($key)) Redis::del($key);
         }else{
         }else{
             //通道门处在发货出库屏 设置55秒过期  前端50秒请求一次 更新标识时间
             //通道门处在发货出库屏 设置55秒过期  前端50秒请求一次 更新标识时间
-            if (Redis::setnx($key, 1)) Redis::expire($key, 55); //多少秒后过期
+            if (Redis::setnx($key, 1)) {
+                Redis::expire($key, 55); //多少秒后过期
+            }else{
+                Redis::expire($key, 55); //多少秒后过期
+            }
         }
         }
     }
     }
 }
 }