From 440b436c76b21f1629292fa7924f91a7958e6a5b Mon Sep 17 00:00:00 2001 From: yanzai Date: Tue, 26 Nov 2024 09:11:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E5=8A=A8=E9=A2=84?= =?UTF-8?q?=E7=BA=A6=EF=BC=8C=E5=AE=8C=E5=96=84=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Laravel/app/Lib/Yz.php | 29 ++++++++-- .../Services/Admin/YeWu/PlanListService.php | 55 ++++++++++++++++++- .../app/Services/Xml/ShenQingDanService.php | 17 +++++- YiJi-admin/index.html | 2 +- YiJi-admin/src/views/Index.vue | 8 ++- YiJi-admin/src/views/YeWu/MainList.vue | 23 ++++---- 6 files changed, 111 insertions(+), 23 deletions(-) diff --git a/Laravel/app/Lib/Yz.php b/Laravel/app/Lib/Yz.php index 12ee1cd..b1e5efa 100644 --- a/Laravel/app/Lib/Yz.php +++ b/Laravel/app/Lib/Yz.php @@ -10,13 +10,13 @@ class Yz{ $result=array(); $result['status']='no'; $result['msg']=$msg; - return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE); + return $result; } public static function echoError1($msg){ $result=array(); $result['status']=false; $result['msg']=$msg; - return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE); + return $result; } public static function Return($status,$msg,$data=[]){ @@ -38,18 +38,35 @@ class Yz{ 'Body' => [ 'ResultCode' => $code, 'ResultContent' => $msg, - 'SuccessIDList' => null, // 或者使用空数组 [] + 'SuccessIDList' => [1,2,4], // 或者使用空数组 [] ], ], ]; // 将数据转换为 XML $xml = simplexml_load_string('' . ""); - array_walk_recursive($data, function($value, $key) use ($xml) { - $child = $xml->addChild($key, $value); - }); +// array_walk_recursive($data, function($value, $key) use ($xml) { +// $child = $xml->addChild($key, $value); +// }); + + // 递归添加数据到 XML + self::addNode($xml, $data); $xmlString = $xml->asXML(); // 设置响应头为 XML 并返回 return response($xmlString)->header('Content-Type', 'text/xml'); } + + private static function addNode(SimpleXMLElement $xml, array $data) + { + foreach ($data as $key => $value) { + if (is_array($value)) { + // 如果值是一个数组,则创建一个新节点并递归调用 + $node = $xml->addChild($key); + self::addNode($node, $value); + } else { + // 否则直接添加节点 + $xml->addChild($key, $value); + } + } + } } diff --git a/Laravel/app/Services/Admin/YeWu/PlanListService.php b/Laravel/app/Services/Admin/YeWu/PlanListService.php index e86b9f7..cf50163 100644 --- a/Laravel/app/Services/Admin/YeWu/PlanListService.php +++ b/Laravel/app/Services/Admin/YeWu/PlanListService.php @@ -212,7 +212,7 @@ WHERE $enableCheckTime = $date;//到此时间后可进行预约 $plan_dateTime = $planInfo->date . ' ' . $planInfo->end_time; $plan_dateTime = new DateTime($plan_dateTime); - if ($plan_dateTime < $enableCheckTime) return \Yz::echoError1($item->item_name . " 已设置只能预约医嘱开具后" . $item->check_begin_time . "分钟后的时间,请预约" . $enableCheckTime->format("Y-m-d H:i:s") . "之后的时间"); + if ($plan_dateTime < $enableCheckTime and $item->check_begin_time>0) return \Yz::echoError1($item->item_name . " 已设置只能预约医嘱开具后" . $item->check_begin_time . "分钟后的时间,请预约" . $enableCheckTime->format("Y-m-d H:i:s") . "之后的时间"); //检测是否空腹 $configs = DB::table('configs')->where('label', '开启空腹')->first(); @@ -333,6 +333,59 @@ WHERE } + public function AutoYuYue($regnum,$entrustids,$episodeid,$appointment_type) + { + $dateRange=config('app.globals.可用号源查询范围'); +// $regnum = request('regnum'); +// $entrustids = request('entrustid'); +// $episodeid = request('episodeid'); +// $appointment_type = request('appointment_type'); //预约类型 + $TodayDateTime = date("Y-m-d H:i:s"); + + + $startDate = new DateTime(); + // 设定结束日期为当前日期加7天 + $endDate = new DateTime(); + $endDate->modify('+' . $dateRange . ' day'); + // 循环遍历每一天 + $currentDate = $startDate; + $enable_plan=false; + while ($currentDate <= $endDate) { + $nowdate = $currentDate->format('Y-m-d'); + $s = $this->GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_type, $nowdate); + + if ($s['status']) { + $list = $s['data']['plan_list']; + if (count($list) > 0) { + foreach ($list as $k => $v) { + if($v->count-$v->used_count>0 and $TodayDateTime< $v->date.' '.$v->end_reservation_time){ + $enable_plan=$v; + break; + } + } + if(!!$enable_plan){ + break; + } + } + } + + // 每次循环增加一天 + $currentDate->modify('+1 day'); + } + if(!!$enable_plan){ + $mainlistids=DB::table('s_list')->whereIn('entrust_id',$entrustids)->pluck('id')->toArray(); + $yuyue=$this->YuYue($enable_plan->id, $appointment_type, $mainlistids, 1); + if($yuyue['status']==false){ + return \Yz::echoError1($yuyue['msg']); + } + if($yuyue['status']===true){ + return \Yz::Return(true,"预约成功",['entrust_id'=>$entrustids,'date'=>$enable_plan->date,'begin_time'=>$enable_plan->begin_time,'end_time'=>$enable_plan->end_time]); + } + + }else{ + return \Yz::echoError1('最近'.$dateRange.'日无可用号源'); + } + } public function CancelYuYue($MainListId, $reg_num) { diff --git a/Laravel/app/Services/Xml/ShenQingDanService.php b/Laravel/app/Services/Xml/ShenQingDanService.php index f1da0d2..c3fb410 100644 --- a/Laravel/app/Services/Xml/ShenQingDanService.php +++ b/Laravel/app/Services/Xml/ShenQingDanService.php @@ -2,6 +2,8 @@ namespace App\Services\Xml; +use App\Http\Controllers\API\Admin\YeWu\PlanListController; +use App\Services\Admin\YeWu\PlanListService; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; @@ -18,6 +20,7 @@ class ShenQingDanService $orderList = array($orderList); } $insert_count = 0;//成功插入数量 + $yuyueInfo=false;//自动预约信息 DB::beginTransaction(); foreach ($orderList as $key => $order) { $patient_type = null; @@ -71,6 +74,17 @@ class ShenQingDanService $insertListId = DB::table('s_list')->insertGetId($params); if ($insertListId) { + if(config('app.globals.自动预约')==1){ + $planser=new PlanListService(); + $yuyue= $planser->AutoYuYue($params['reg_num'],[$params['entrust_id']],$params['episodeid'],1); + if($yuyue['status']==false){ + DB::rollBack(); + return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], -1, '自动预约失败,'.$yuyue['msg'].',推送失败'); + } + if($yuyue['status']===true){ + $yuyueInfo[]=$yuyue['data']; + } + } $data = [ 'list_id' => $insertListId, 'reg_num' => $Body["PATPatientInfo"]["PATPatientID"], @@ -95,7 +109,8 @@ class ShenQingDanService } if (count($orderList) == $insert_count) { DB::commit(); - return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], 0, '成功'); + + return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], 0, ['SendStatus'=>true,"YuyueInfo"=>$yuyueInfo]); } else { DB::rollBack(); return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], -1, '失败'); diff --git a/YiJi-admin/index.html b/YiJi-admin/index.html index 117ccc1..4ce383c 100644 --- a/YiJi-admin/index.html +++ b/YiJi-admin/index.html @@ -4,7 +4,7 @@ - 测试医院-医技预约 + 演示医院-医技预约
diff --git a/YiJi-admin/src/views/Index.vue b/YiJi-admin/src/views/Index.vue index 99dda72..522fbce 100644 --- a/YiJi-admin/src/views/Index.vue +++ b/YiJi-admin/src/views/Index.vue @@ -6,7 +6,7 @@ @@ -54,7 +54,7 @@ - + @@ -199,12 +199,16 @@ watch(()=>router.currentRoute.value,(newVal,oldVal)=>{ console.log(route.path) let BingQu=[2]; //跳转住院主工作列表 let QiTa=[3]; //跳转普通主工作列表 + let Guanli=[1,5];//管理员 if(QiTa.includes(res.info[0].group) && route.path=='/dashboard'){ window.location.href = "./#/yewu/mainList" } if(BingQu.includes(res.info[0].group) && route.path=='/dashboard'){ window.location.href = "./#/yewu/MainList_ZhuYuan" } + if(Guanli.includes(res.info[0].group) && route.path=='/dashboard'){ + window.location.href = "./#/yewu/departmentResources" + } }) } let configInfo=ref(''); diff --git a/YiJi-admin/src/views/YeWu/MainList.vue b/YiJi-admin/src/views/YeWu/MainList.vue index 3db0901..5b71282 100644 --- a/YiJi-admin/src/views/YeWu/MainList.vue +++ b/YiJi-admin/src/views/YeWu/MainList.vue @@ -112,6 +112,16 @@ v-if="scope.row.period_begin_time && scope.row.period_end_time ">{{scope.row.period_begin_time.substring(0, 5)}}~{{scope.row.period_end_time.substring(0, 5)}} + + + + - - - -