From 8344dd16de2178d79a03a2277369875b55bbc8c2 Mon Sep 17 00:00:00 2001 From: yanzai Date: Fri, 28 Jun 2024 14:33:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=8D=AB=E8=BF=94=E5=9B=9E=E7=A9=BA?= =?UTF-8?q?=E4=B9=9F=E8=A7=86=E4=B8=BA=E6=97=A0=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Laravel/app/Lib/Yz.php | 42 ++++++++++--------- .../Admin/YeWu/AppointmentService.php | 11 +++-- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Laravel/app/Lib/Yz.php b/Laravel/app/Lib/Yz.php index b46a32b..7b12d15 100644 --- a/Laravel/app/Lib/Yz.php +++ b/Laravel/app/Lib/Yz.php @@ -63,29 +63,31 @@ class Yz{ $resdata = curl_exec($ch); - - - - - $result=""; - try { - if(curl_errno($ch)) { - $result=curl_error($ch); - // print curl_error($ch); - } else { - curl_close($ch); - - $res = explode('', $resdata)[1]; - $res = explode('', $res)[0]; - - $xmlObject = simplexml_load_string($res); - $jsonData = json_encode($xmlObject); - $result = json_decode($jsonData, true); + if(!$resdata==""){ + $result=""; + try { + if(curl_errno($ch)) { + $result=curl_error($ch); + // print curl_error($ch); + } else { + curl_close($ch); + + $res = explode('', $resdata)[1]; + $res = explode('', $res)[0]; + + $xmlObject = simplexml_load_string($res); + $jsonData = json_encode($xmlObject); + $result = json_decode($jsonData, true); + } + }catch (Exception $e) { + $result = $e->getMessage(); } - }catch (Exception $e) { - $result = $e->getMessage(); + }else{ + $result=$resdata; } + + LogService::CheckTableName(); date_default_timezone_set('PRC'); $table_name='zz_request_log_' . date('ym'); diff --git a/Laravel/app/Services/Admin/YeWu/AppointmentService.php b/Laravel/app/Services/Admin/YeWu/AppointmentService.php index ed1af3b..b50e2b7 100644 --- a/Laravel/app/Services/Admin/YeWu/AppointmentService.php +++ b/Laravel/app/Services/Admin/YeWu/AppointmentService.php @@ -99,7 +99,7 @@ class AppointmentService $result['msg']='已体检过'; $result['info']=$c; }else{ - + $gongwei= self::CheckGongWei($name,$id_card_num); if( $gongwei['status']===false) { $result['status'] = false; @@ -137,7 +137,7 @@ class AppointmentService $url = config('app.globals.GongWeiBaseUrl'); $res=\Yz::XmlHttp($SendData,$url); //如果没有返回queryCheckUp节点,返回异常 - if(!isset($res['queryCheckUp'])) { + if(!isset($res['queryCheckUp']) and $res!="") { $result['status']=false; $result['msg']='公卫接口异常'; $result['GongWeiinfo']=$res; @@ -159,7 +159,12 @@ class AppointmentService }else{ $result['status']=true; $result['msg']='公卫无记录'; - $result['GongWeiinfo']=$res['queryCheckUp']; + if( $res=="" or $res==null){ + $result['GongWeiinfo']="公卫返回空"; + }else{ + $result['GongWeiinfo']=$res['queryCheckUp']; + } + } return $result; }