getPdf('12206060840002'); // phpinfo(); } public function hello($name = 'ThinkPHP6') { return 'hello,' . $name; } public function getReport() { $code = $_REQUEST['code']; $type = $_REQUEST['type']; libxml_disable_entity_loader(false); // $client = new \SoapClient("http://report.dalabs.cn/RasClientDetail.asmx?wsdl"); $client = new \SoapClient("http://115.238.253.166/RasClientDetail.asmx?wsdl"); $data = [ 'ClientID'=>Config::get('app')['dian']['ClientID'], 'ClientGUID'=>Config::get('app')['dian']['ClientGUID'], 'hospBarcode'=>$code, 'SelectType'=>$type ]; //请求参数 Db::table('api_log')->insert(['type'=>1,'barcode'=>$code]); try{ $result = $client->GetDetailDataByHospBarcode3($data); //请求获取接口 Db::table('api_log')->insert(['type'=>2,'barcode'=>$code]); $data = ((array)$result)['GetDetailDataByHospBarcode3Result']; $obj = simplexml_load_string("".$data."","SimpleXMLElement", LIBXML_NOCDATA); if($obj) { $info = json_decode(json_encode($obj),true); $returnCode = $info['Error']['Code']; if($returnCode !== '0') { return '报告获取失败!迪安回传信息:'.$info['Error']['Descript']; } } $report = json_encode($obj); DB::table('dianapiinfo')->where('Barcode',$code)->update(['result_xml'=>$report]); $this->getPdf($code); return 'success'; }catch(\SoapFault $e){ return $e->getMessage(); } } public function getPdf($code) { $type = 1; libxml_disable_entity_loader(false); $client = new \SoapClient("https://r.dalabs.cn/ReportService.asmx?wsdl"); // $data = [ // 'ClientID'=>Config::get('app')['dian']['ClientID'], // 'Key'=>Config::get('app')['dian']['ClientGUID'], // 'PageNO'=>1, // 'Condition'=>[ // 'ClinicID'=>$code, // 'StartDate'=>'', // 'EndDate'=>'' // ], // 'Model'=>1 // ]; //请求参数 try{ // $a2x = new array2xml(); // $data = $a2x->toXml($data); // var_dump(htmlspecialchars($data)); // var_dump($data); $result = $client->QueryReports2(array('ReqInfo'=>[ 'PageNo'=>1, 'ClientID'=>Config::get('app')['dian']['ClientID'], 'Key'=>Config::get('app')['dian']['ClientGUID'], 'Condition'=>[ 'ClinicID'=>$code, 'StartDate'=>'', 'EndDate'=>'' ]])); //请求获取接口 Db::table('dianapiinfo')->where('Barcode',$code)->update(['pdf_xml'=>json_encode($result)]); $data = ((array)$result)['QueryReports2Result']; $info = json_decode(json_encode($data),true); var_dump($info); Db::table('api_log')->insert(['type'=>4,'barcode'=>$code,'data'=>json_encode($result)]); if($info) { $returnCode = $info['ResultCode']; var_dump($returnCode); if($returnCode <= 0) { return '报告PDF获取失败!迪安回传信息:'.$info['ResultMsg']; } if(isset($info['Datas']['Report']['ClinicID'])) { $pdf = $info['Datas']['Report']['PdfReportUrl']; $name = $info['Datas']['Report']['ClinicID']; $this->downImgRar($pdf,$name,'pdf',$info['Datas']['Report']['ClinicID']); }else{ foreach ($info['Datas']['Report'] as $k=>$v) { $pdf = $v['PDFREPORTURL']; var_dump($pdf);die; $name = $v['BARCODE'].'_'.($k+1); $this->downImgRar($pdf,$name,'pdf',$v['BARCODE']); } } } return 'success'; }catch(\SoapFault $e){ return $e->getMessage(); } } function downImgRar($url,$rename,$ext,$barCode){ switch ($ext) { case 'png': case 'jpg': //下载图片 $file_path = '/images/'; break; case 'pdf': //下载PDF $file_path = '/pdf/'; break; case 'zip': case 'rar': //下载压缩包 $file_path = '/rar/'; break; default: $file_path = '/files/'; break; } var_dump(1); $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); $rawdata=curl_exec ($ch); curl_close ($ch); // 使用中文文件名需要转码 file_put_contents($_SERVER['DOCUMENT_ROOT'].$file_path.$rename.'.'.$ext,$rawdata); var_dump(2); // 返回路径 $path = $_SERVER['DOCUMENT_ROOT'].$file_path.$rename.".".$ext; $ins = ['type'=>$ext,'url'=>$path,'barcode'=>$barCode]; var_dump(3); Db::table('annex')->insert($ins); $patientId = Db::table('dianapiinfo')->where('Barcode',$barCode)->value('patientId'); var_dump(4); Db::table('phy_lis_reports')->where('patientId',$patientId)->update(['is_report_url'=>1]); return 'success'; } }