|
@@ -48,7 +48,8 @@ class DoorDeviceJob implements ShouldQueue
|
|
|
$order_number = [];
|
|
|
foreach ($epc as $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(! in_array($str, $order_number)) $order_number[] = $str; // 十六进制字符串转回原来字符串
|
|
|
}
|
|
@@ -60,13 +61,19 @@ class DoorDeviceJob implements ShouldQueue
|
|
|
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;
|
|
|
+ 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);
|
|
|
}
|
|
|
- $this->completionOrders($dispatchList['data'],$type);
|
|
|
|
|
|
//输出信息 测试
|
|
|
$this->echoMessage(new ConsoleOutput());
|
|
@@ -75,6 +82,45 @@ class DoorDeviceJob implements ShouldQueue
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function productionReceipt($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.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::getTokenCs();
|