Index.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. try{
  31. $result = $client->GetDetailDataByHospBarcode3($data); //请求获取接口
  32. $data = ((array)$result)['GetDetailDataByHospBarcode3Result'];
  33. $obj = simplexml_load_string("<data>".$data."</data>","SimpleXMLElement", LIBXML_NOCDATA);
  34. if($obj)
  35. {
  36. $info = json_decode(json_encode($obj),true);
  37. $code = $info['Error']['Code'];
  38. if($code !== '0')
  39. {
  40. return '报告获取失败!迪安回传信息:'.$info['Error']['Descript'];
  41. }
  42. }
  43. $report = json_encode($obj);
  44. DB::table('dianapiinfo')->where('Barcode',$code)->update(['result_xml'=>$report]);
  45. return 'success';
  46. }catch(\SoapFault $e){
  47. return $e->getMessage();
  48. }
  49. }
  50. public function aa()
  51. {
  52. $a = new \SimpleXMLElement();
  53. ;die;
  54. libxml_disable_entity_loader(false);
  55. $client = new \SoapClient("http://112.103.134.89:10020/server.php?wsdl");
  56. $data = [
  57. 'Barcode'=>'12203310010001'
  58. ]; //请求参数
  59. $a2x = new array2xml();
  60. $data = $a2x->toXml($data); //参数转xml
  61. try{
  62. $result = $client->getDiAnData($data); //请求获取接口
  63. }catch(\SoapFault $e){
  64. return $e->getMessage();
  65. }
  66. var_dump(htmlspecialchars($result));die;
  67. $obj = simplexml_load_string($result,"SimpleXMLElement", LIBXML_NOCDATA);
  68. $ins = json_encode($obj);
  69. $obj = json_decode($ins,true);
  70. var_dump($obj);die;
  71. }
  72. }