Index.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\common\array2xml;
  5. use think\facade\Config;
  6. use think\facade\Db;
  7. use think\facade\Cache;
  8. class Index extends BaseController
  9. {
  10. public function index()
  11. {
  12. phpinfo();
  13. }
  14. public function hello($name = 'ThinkPHP6')
  15. {
  16. return 'hello,' . $name;
  17. }
  18. public function getReport()
  19. {
  20. $code = $_REQUEST['code'];
  21. $type = $_REQUEST['type'];
  22. libxml_disable_entity_loader(false);
  23. $client = new \SoapClient("http://report.dalabs.cn/RasClientDetail.asmx?wsdl");
  24. $data = [
  25. 'ClientID'=>Config::get('app')['dian']['ClientID'],
  26. 'ClientGUID'=>Config::get('app')['dian']['ClientGUID'],
  27. 'hospBarcode'=>$code,
  28. 'SelectType'=>$type
  29. ]; //请求参数
  30. Db::table('api_log')->insert(['type'=>1,'barcode'=>$code]);
  31. try{
  32. $result = $client->GetDetailDataByHospBarcode3($data); //请求获取接口
  33. Db::table('api_log')->insert(['type'=>2,'barcode'=>$code]);
  34. $data = ((array)$result)['GetDetailDataByHospBarcode3Result'];
  35. $obj = simplexml_load_string("<data>".$data."</data>","SimpleXMLElement", LIBXML_NOCDATA);
  36. if($obj)
  37. {
  38. $info = json_decode(json_encode($obj),true);
  39. $returnCode = $info['Error']['Code'];
  40. if($returnCode !== '0')
  41. {
  42. return '报告获取失败!迪安回传信息:'.$info['Error']['Descript'];
  43. }
  44. }
  45. $report = json_encode($obj);
  46. DB::table('dianapiinfo')->where('Barcode',$code)->update(['result_xml'=>$report]);
  47. return 'success';
  48. }catch(\SoapFault $e){
  49. return $e->getMessage();
  50. }
  51. }
  52. public function aa()
  53. {
  54. $a = new \SimpleXMLElement();
  55. ;die;
  56. libxml_disable_entity_loader(false);
  57. $client = new \SoapClient("http://112.103.134.89:10020/server.php?wsdl");
  58. $data = [
  59. 'Barcode'=>'12203310010001'
  60. ]; //请求参数
  61. $a2x = new array2xml();
  62. $data = $a2x->toXml($data); //参数转xml
  63. try{
  64. $result = $client->getDiAnData($data); //请求获取接口
  65. }catch(\SoapFault $e){
  66. return $e->getMessage();
  67. }
  68. var_dump(htmlspecialchars($result));die;
  69. $obj = simplexml_load_string($result,"SimpleXMLElement", LIBXML_NOCDATA);
  70. $ins = json_encode($obj);
  71. $obj = json_decode($ins,true);
  72. var_dump($obj);die;
  73. }
  74. }