Index.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. libxml_disable_entity_loader(false);
  20. $client = new \SoapClient("http://112.103.134.89:10020/server.php?wsdl");
  21. $data = [
  22. 'Barcode'=>'12203310010001'
  23. ]; //请求参数
  24. $a2x = new array2xml();
  25. $data = $a2x->toXml($data); //参数转xml
  26. try{
  27. $result = $client->getDiAnData($data); //请求获取接口
  28. }catch(\SoapFault $e){
  29. return $e->getMessage();
  30. }
  31. var_dump(htmlspecialchars($result));die;
  32. $obj = simplexml_load_string($result,"SimpleXMLElement", LIBXML_NOCDATA);
  33. $ins = json_encode($obj);
  34. $obj = json_decode($ins,true);
  35. var_dump($obj);die;
  36. }
  37. public function aa()
  38. {
  39. $conn = mysqli_connect('localhost','root','');
  40. $a = mysqli_select_db($conn,'tijianzhongxin');
  41. $sql = "select * from dianApiInfo where Barcode='12203020024872'";
  42. $result = mysqli_query($conn, $sql);
  43. $info = mysqli_fetch_row($result);
  44. var_dump($info);die;
  45. if(!empty($info))
  46. {
  47. $return = [
  48. 'xml'=>$info[1],
  49. 'patientId'=>$info[2],
  50. 'barCode'=>$info[3]
  51. ];
  52. $a2x = new array2xml();
  53. $r = $a2x->toXml($return);
  54. return $r;
  55. }else{
  56. return '';
  57. }
  58. }
  59. }