Index.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\common\array2xml;
  5. use think\facade\Db;
  6. use think\facade\Cache;
  7. class Index extends BaseController
  8. {
  9. public function index()
  10. {
  11. phpinfo();
  12. }
  13. public function hello($name = 'ThinkPHP6')
  14. {
  15. return 'hello,' . $name;
  16. }
  17. public function getReport()
  18. {
  19. set_time_limit('600');
  20. libxml_disable_entity_loader(false);
  21. $opts = array(
  22. 'ssl' => array(
  23. 'verify_peer' => false
  24. ),
  25. 'https' => array(
  26. 'curl_verify_ssl_peer' => false,
  27. 'curl_verify_ssl_host' => false
  28. )
  29. );
  30. $streamContext = stream_context_create($opts);
  31. $client = new \SoapClient("http://192.168.0.207:10020/server.php?wsdl",
  32. array(
  33. 'stream_context' => $streamContext
  34. ));
  35. $data = [
  36. 'Barcode'=>'12203310010001'
  37. ]; //请求参数
  38. $a2x = new array2xml();
  39. $data = $a2x->toXml($data); //参数转xml
  40. try{
  41. $result = $client->getDiAnData($data); //请求获取接口
  42. }catch(\SoapFault $e){
  43. return $e->getMessage();
  44. }
  45. var_dump(htmlspecialchars($result));die;
  46. $obj = simplexml_load_string($result,"SimpleXMLElement", LIBXML_NOCDATA);
  47. $ins = json_encode($obj);
  48. $obj = json_decode($ins,true);
  49. var_dump($obj);die;
  50. }
  51. public function aa()
  52. {
  53. $conn = mysqli_connect('localhost','root','');
  54. $a = mysqli_select_db($conn,'tijianzhongxin');
  55. $sql = "select * from dianApiInfo where Barcode='12203020024872'";
  56. $result = mysqli_query($conn, $sql);
  57. $info = mysqli_fetch_row($result);
  58. if(!empty($info))
  59. {
  60. $return = [
  61. 'xml'=>$info[1],
  62. 'patientId'=>$info[2],
  63. 'barCode'=>$info[3]
  64. ];
  65. $a2x = new array2xml();
  66. $r = $a2x->toXml($return);
  67. return $r;
  68. }else{
  69. return '';
  70. }
  71. }
  72. }