|
@@ -53,27 +53,11 @@ class DoorDeviceJob implements ShouldQueue
|
|
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;
|
|
|
|
|
|
- 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->zs($type,$order_number);
|
|
|
|
|
|
//输出信息 测试
|
|
//输出信息 测试
|
|
$this->echoMessage(new ConsoleOutput());
|
|
$this->echoMessage(new ConsoleOutput());
|
|
@@ -82,6 +66,43 @@ class DoorDeviceJob implements ShouldQueue
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //测试--------------------------------------
|
|
|
|
+ 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){
|
|
public function productionReceiptCs($data){
|
|
list($status,$token) = ClearDataService::getTokenCs();
|
|
list($status,$token) = ClearDataService::getTokenCs();
|
|
if(! $status) return;
|
|
if(! $status) return;
|
|
@@ -110,7 +131,7 @@ 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.'in_opt'.PHP_EOL,8);
|
|
|
|
|
|
+ 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);
|
|
$return = json_decode($response,true);
|
|
if(! empty($return['data'])){
|
|
if(! empty($return['data'])){
|
|
@@ -150,7 +171,7 @@ 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);
|
|
}
|
|
}
|
|
@@ -240,7 +261,7 @@ class DoorDeviceJob implements ShouldQueue
|
|
];
|
|
];
|
|
}
|
|
}
|
|
//组织数据------
|
|
//组织数据------
|
|
- 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_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}"];
|
|
$header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
|
|
|
|
|
|
@@ -268,7 +289,69 @@ class DoorDeviceJob implements ShouldQueue
|
|
Redis::expire($key, $expire_time);
|
|
Redis::expire($key, $expire_time);
|
|
}
|
|
}
|
|
|
|
|
|
- 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_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.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){
|
|
public function productionReceipt($data){
|
|
@@ -460,6 +543,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);
|