getEnableTime.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. function SoapToXml($xml)
  3. {
  4. //api测试先关闭
  5. $startStr=strrpos($xml,"<![CDATA[");
  6. $endStr=strpos($xml,"]]>");
  7. $xml=substr($xml,$startStr,$endStr-$startStr);
  8. $xml = str_replace("<![CDATA[>","",$xml);
  9. $xml = str_replace("<![CDATA[","",$xml);
  10. $xml = str_replace("]]]]>","",$xml);
  11. $xml = str_replace("]]>","",$xml);
  12. $xml = str_replace("<ILLEGAL VALUE>","",$xml);
  13. return $xml;
  14. }
  15. date_default_timezone_set('PRC');
  16. $callback = isset($_GET['callback']) ? trim($_GET['callback']) : '';
  17. //==============获得前台请求==============
  18. $req['HospitalId'] = $_GET['hospitalId'];
  19. $req['startDate'] = $_GET['startDate'];
  20. $req['endDate'] = $_GET['endDate'];
  21. $req['deptId'] = $_GET['deptId'];
  22. if (isset($_GET['doctorId'])) {
  23. $req['doctorId'] = $_GET['doctorId'];
  24. }
  25. $day = $_GET['day']?$_GET['day']:1;
  26. $arr = array();
  27. $TradeCode = "1004";
  28. $ExtOrgCode = "南方医务通";
  29. $ExtUserID = "NFYWT";
  30. $ClientType ="";
  31. $HospitalId =$req['HospitalId'];
  32. $DeptType = "";
  33. $SessType = "";
  34. $StartDate = $req['startDate'];
  35. $EndDate = date('Y-m-d',(strtotime($req['startDate'])+$day*3600*24));
  36. $RBASSessionCode = "";
  37. $ServiceCode = "";
  38. $StopScheduleFlag = "";
  39. $DepartmentCode = $req['deptId'];
  40. $DoctorCode= empty($req['doctorId'])?'':$req['doctorId'];
  41. $callback = isset($_GET['callback']) ? trim($_GET['callback']) : '';
  42. $SearchCode = "";
  43. $postData = "<Request><HospitalId>$HospitalId</HospitalId><ExtOrgCode>$ExtOrgCode</ExtOrgCode><ExtUserID>$ExtUserID</ExtUserID><ClientType>$ClientType</ClientType><TradeCode>$TradeCode</TradeCode><DeptType>$DeptType</DeptType><DoctorCode>$DoctorCode</DoctorCode><SessType>$SessType</SessType><StartDate>$StartDate</StartDate><EndDate>$EndDate</EndDate><RBASSessionCode>$RBASSessionCode</RBASSessionCode><ServiceCode>$ServiceCode</ServiceCode><StopScheduleFlag>$StopScheduleFlag</StopScheduleFlag><DepartmentCode>$DepartmentCode</DepartmentCode><SearchCode>$SearchCode</SearchCode></Request>";
  44. $postData = str_replace(' ','%20',$postData);
  45. $wsdl = "http://yygh1.dept.nfyy.com/csp/oep/DHC.OEP.BS.OEPSTANWebService.cls?soap_method=QuerySchedule&Input=";
  46. $result = file_get_contents($wsdl.$postData);
  47. $res = SoapToXml($result);
  48. $res = simplexml_load_string($res);
  49. $res = json_encode($res);
  50. $res = json_decode($res,true);
  51. $times = array();
  52. for($i = $day-1; $i >=0;$i--) {
  53. $time = date('Y-m-d',strtotime($req['startDate'])+$i*3600*24);
  54. $times[$i]['time'] = $time;
  55. $times[$i]['count'] = 0;
  56. }
  57. if (isset($res['Schedules']['Schedule'])) {
  58. foreach ($res['Schedules']['Schedule'] as $k => $v ) {
  59. foreach ($times as $index => $time) {
  60. if ($time['time'] == $v ['ServiceDate']) {
  61. $times[$index]['count'] = intval($times[$index]['count']) + 1;
  62. break;
  63. }
  64. }
  65. }
  66. } else {
  67. $arr[0]['msg'] = '请求出错';
  68. $arr[0]['time'] = $StartDate;
  69. echo $callback . '(' . json_encode($arr) .')';exit;
  70. }
  71. foreach ($times as $k => $v) {
  72. if (intval($v['count']) == 0) {
  73. $arr[$k][$v['time']]= false;
  74. } else {
  75. $arr[$k][$v['time']]= true;
  76. }
  77. }
  78. echo $callback . '(' . json_encode($arr) .')';exit;
  79. ?>