|
@@ -150,12 +150,150 @@ class TestController extends BaseController
|
|
|
return hex2bin($sHexData);
|
|
|
}
|
|
|
|
|
|
+ //跳板------------------------------------------
|
|
|
+ public function testdwy(Request $request){
|
|
|
+ $data = $request->all();
|
|
|
+
|
|
|
+ $url = $data['url'];
|
|
|
+ $post = $data['post'];
|
|
|
+ $header = $data['header'];
|
|
|
+
|
|
|
+ if(empty($post)){
|
|
|
+ $json = json_encode((object)$post);
|
|
|
+ }else{
|
|
|
+ $json = json_encode($post);
|
|
|
+ }
|
|
|
+ // $json = str_replace('"workflowSearchBean":{}','"workflowSearchBean":[]',json_encode($post));
|
|
|
+ $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',$json);
|
|
|
+ $json = str_replace('"loginBindingParameters":[]','"loginBindingParameters":{}',$json);
|
|
|
+
|
|
|
+ Log::channel('apiDwy')->info('POST入参:', ["api" => $url , "param" => $json ,"header" => $header]);
|
|
|
+
|
|
|
+ $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,
|
|
|
+ CURLOPT_SSL_VERIFYPEER =>false,
|
|
|
+ ));
|
|
|
+ $response = curl_exec($curl);
|
|
|
+ if ($response === false) {
|
|
|
+ // 获取错误号
|
|
|
+ $errorNumber = curl_errno($curl);
|
|
|
+ // 获取错误信息
|
|
|
+ $errorMessage = curl_error($curl);
|
|
|
+ $message = "cURL Error #{$errorNumber}: {$errorMessage}";
|
|
|
+ Log::channel('apiDwy')->info('POST结果:', ["message" => $message]);
|
|
|
+ // return [false, "cURL Error #{$errorNumber}: {$errorMessage}"];
|
|
|
+ }
|
|
|
+ curl_close($curl);
|
|
|
+ $return = json_decode($response,true);
|
|
|
|
|
|
+ Log::channel('apiDwy')->info('POST结果:', ["message" => $return]);
|
|
|
|
|
|
+ return $this->json_return(200,'', $return);
|
|
|
+ }
|
|
|
|
|
|
+ public function testdwyget(Request $request){
|
|
|
+ $data = $request->all();
|
|
|
+
|
|
|
+ $url = $data['url'];
|
|
|
+ $str = "api/module-data/production_orders/production_orders/diy/production_manage";
|
|
|
+ if (strpos($data['url'], $str) !== false) $url = "https://clouddevice.qingyaokeji.com/api/newsczt";
|
|
|
+ $str = "api/module-data/production_orders/production_orders/diy/device";
|
|
|
+ if (strpos($data['url'], $str) !== false) $url = "https://clouddevice.qingyaokeji.com/api/newdjg";
|
|
|
+ $header = $data['header'];
|
|
|
+
|
|
|
+ $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 => 'GET',
|
|
|
+ CURLOPT_HTTPHEADER => $header,
|
|
|
+ ));
|
|
|
+ $response = curl_exec($curl);
|
|
|
+ curl_close($curl);
|
|
|
+ return $this->json_return(200,'',json_decode($response,true));
|
|
|
+ }
|
|
|
|
|
|
+ public function testdwyput(Request $request){
|
|
|
+ $data = $request->all();
|
|
|
+
|
|
|
+ $url = $data['url'];
|
|
|
+ $post = $data['post'];
|
|
|
+ $header = $data['header'];
|
|
|
+
|
|
|
+ $json = str_replace('"workflowSearchBean":{}','"workflowSearchBean":[]',json_encode($post));
|
|
|
+ $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
|
|
|
+
|
|
|
+ Log::channel('apiDwy')->info('PUT入参:', ["api" => $url , "param" => $json ,"header" => $header]);
|
|
|
+
|
|
|
+ $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 => 'PUT',
|
|
|
+ CURLOPT_POSTFIELDS => $json,
|
|
|
+ CURLOPT_HTTPHEADER => $header,
|
|
|
+ ));
|
|
|
+ $response = curl_exec($curl);
|
|
|
+ if ($response === false) {
|
|
|
+ // 获取错误号
|
|
|
+ $errorNumber = curl_errno($curl);
|
|
|
+ // 获取错误信息
|
|
|
+ $errorMessage = curl_error($curl);
|
|
|
+ $message = "cURL Error #{$errorNumber}: {$errorMessage}";
|
|
|
+ Log::channel('apiDwy')->info('PUT结果:', ["message" => $message]);
|
|
|
+ // return [false, "cURL Error #{$errorNumber}: {$errorMessage}"];
|
|
|
+ }
|
|
|
+ curl_close($curl);
|
|
|
+ $return = json_decode($response,true);
|
|
|
|
|
|
+ Log::channel('apiDwy')->info('PUT结果:', ["message" => $return]);
|
|
|
|
|
|
+ return $this->json_return(200,'', $return);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ public function testdwydel(Request $request){
|
|
|
+ $data = $request->all();
|
|
|
+
|
|
|
+ $url = $data['url'];
|
|
|
+ $header = $data['header'];
|
|
|
+
|
|
|
+ $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 => 'DELETE',
|
|
|
+ CURLOPT_HTTPHEADER => $header,
|
|
|
+ ));
|
|
|
+ $response = curl_exec($curl);
|
|
|
+ curl_close($curl);
|
|
|
+ return $this->json_return(200,'',json_decode($response,true));
|
|
|
+ }
|
|
|
+ //跳板------------------------------------------
|
|
|
}
|