diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/SignInController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/SignInController.php new file mode 100644 index 0000000..e626669 --- /dev/null +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/SignInController.php @@ -0,0 +1,191 @@ +get('userid');//中间件产生的参数 + date_default_timezone_set('PRC'); + $MainListIds = request('MainListIds'); + if(empty($MainListIds)) return \Yz::echoError1('id参数不能为空'); + $mainInfos=DB::table('s_list as a') + ->select('a.*','b.period_begin_time','b.period_end_time') + ->leftJoin('s_period as b','a.reservation_time','=','b.id') + ->whereIn('a.id',$MainListIds)->where(['a.is_del'=>0])->get(); + //遍历判断所有要预约的医嘱是否符合条件 + foreach ($mainInfos as $key=>$mainInfo){ + //判断状态 + if($mainInfo->list_status<>1) return \Yz::echoError1($mainInfo->entrust.' 不是预约状态,不可签到'); + if($mainInfo->is_pay<>1) return \Yz::echoError1($mainInfo->entrust.' 未支付,不可签到'); + if($mainInfo->is_nullify<>0) return \Yz::echoError1($mainInfo->entrust.' 已作废,不可签到'); + //判断时间,当前判断只要是当天就可签到 + $now=date('Y-m-d'); + //判断是否过期 + if($mainInfo->reservation_date<$now) return \Yz::echoError1($mainInfo->entrust.' 预约已过期'); + //判断是否是预约的时间 + if($mainInfo->reservation_date<>$now) return \Yz::echoError1($mainInfo->entrust.' 未到预约时间,请于'.$mainInfo->reservation_date.'签到'); + //获取检查项目类名 + $type=DB::table('s_check_item as a') + ->select('a.*','b.item_class_name') + ->leftJoin('s_check_item_class as b','a.item_class_id','=','b.id') + ->where(['a.item_code'=>$mainInfo->entrust_code])->first(); + if(!$type) return \Yz::echoError1($mainInfo->entrust.' 获取分类失败,不可签到'); + $mainInfo->entrust_type=$type->item_class_name; + //获取预约的检查室 + $checkroom=DB::table('s_department_resources')->where(['id'=>$mainInfo->reservation_sources])->first(); + if(!$checkroom) return \Yz::echoError1($mainInfo->entrust.' 未获取到检查室信息,不可签到'); + $mainInfo->reservation_sources_name=$checkroom->department_resources_name; + } + //如果以上都通过,调用盈谷接口进行签到 + $success_item=[]; + $fail_item=[]; + foreach ($mainInfos as $key=>$mainInfo){ + if($mainInfo->patient_type==2){ + $mainInfo->patient_type=3; + }elseif ($mainInfo->patient_type==3){ + $mainInfo->patient_type=2; + } + $data=[ + 'hisId'=>$mainInfo->reg_num, + 'yizhuId'=>$mainInfo->entrust_id, + 'isAppt'=>'Y', + 'appointmentTime'=>$mainInfo->reservation_date.' '.$mainInfo->period_begin_time, + 'isStudyGroupRegistration'=>null, + 'enrolDoctorName'=>'测试医生', + 'enrolDoctorCode'=>'ddddd', + 'admIdIss'=>$mainInfo->patient_type, + 'patientName'=>$mainInfo->user_name, + 'accessionNo'=>$mainInfo->app_num, + 'modalityName'=> $mainInfo->entrust_type, + 'videoRoomName'=> $mainInfo->reservation_sources_name, + ]; + + $yg_signin= self::YG_SignIn('/insertRegisterInfo',$data); + if($yg_signin['status']==true){ + //盈谷返回成功,更新本地状态 + $u=DB::table('s_list')->where(['id'=>$mainInfo->id])->update([ + 'list_status'=>2 + ]); + if($u){ + $success_item[]=$mainInfo->entrust; + //记录日志 + $data = [ + 'list_id' => $mainInfo->id, + 'reg_num' => $mainInfo->reg_num, + 'new_status' => 2, + 'create_user' => $userid, + 'note' => '登记', + 'data' => null,//原始数据 + ]; + $insertLog = DB::table('s_list_log')->insert($data); + }else{ + $fail_item[]=$mainInfo->entrust.' 签到失败:记录未更新'; + // return \Yz::echoError1($mainInfo->entrust.' 签到失败:记录未更新'); + } + + }else{ + $fail_item[]=$mainInfo->entrust.' 调用检查系统签到接口失败:'.$yg_signin['msg']; + // return \Yz::echoError1($mainInfo->entrust.' 调用检查系统签到接口失败:'.$yg_signin['msg']); + } + } + + return \Yz::Return(true,'操作完成',['success'=>$success_item,'fail'=>$fail_item]); + + + } + //盈谷签到 + public function YG_SignIn($url,$data) + { + $baseUrl=config('app.globals.YingGuBaseUrl'); + $data=json_encode($data,JSON_UNESCAPED_UNICODE); + $r=\Tools::Post($baseUrl.$url,$data,'盈谷签到'); + + if (!json_decode($r, true)) { + return ['status'=>false,'msg'=>"解析检查系统'签到接口'数据出错"]; + } + $res = json_decode($r, true); + if($res['isSuccess']==true){ + return ['status'=>true,'']; + }else{ + return ['status'=>false,'msg'=>$res['resultMsg']]; + } + } + + //取消签到 + public function CancelSign(Request $request) + { + $userid = $request->get('userid');//中间件产生的参数 + date_default_timezone_set('PRC'); + $MainListIds = request('MainListIds'); + if(empty($MainListIds)) return \Yz::echoError1('id参数不能为空'); + $mainInfos=DB::table('s_list as a') + ->select('a.*','b.period_begin_time','b.period_end_time') + ->leftJoin('s_period as b','a.reservation_time','=','b.id') + ->whereIn('a.id',$MainListIds)->where(['a.is_del'=>0])->get(); + //遍历判断所有要预约的医嘱是否符合条件 + foreach ($mainInfos as $key=>$mainInfo) { + //判断状态 + if ($mainInfo->list_status <> 2) return \Yz::echoError1($mainInfo->entrust . ' 不是 已签到 状态,不可取消签到'); + if ($mainInfo->is_pay <> 1) return \Yz::echoError1($mainInfo->entrust . ' 未支付,不可取消签到'); + if ($mainInfo->is_nullify <> 0) return \Yz::echoError1($mainInfo->entrust . ' 已作废,不可取消签到'); + } + //如果以上都通过,调用盈谷接口进行取消签到 + $success_item=[]; + $fail_item=[]; + foreach ($mainInfos as $key=>$mainInfo) { + $data=[ + 'yizhuId'=>$mainInfo->entrust_id, + 'hisId '=>$mainInfo->reg_num + ]; + $yg_cancelsign= self::YG_CancelSign('/deleteRegisterInfo',$data); + if($yg_cancelsign['status']==true){ + //盈谷返回成功,更新本地状态 + $u=DB::table('s_list')->where(['id'=>$mainInfo->id])->update([ + 'list_status'=>1 + ]); + if($u){ + $success_item[]=$mainInfo->entrust; + //记录日志 + $data = [ + 'list_id' => $mainInfo->id, + 'reg_num' => $mainInfo->reg_num, + 'new_status' => 2, + 'create_user' => $userid, + 'note' => '取消登记', + 'data' => null,//原始数据 + ]; + $insertLog = DB::table('s_list_log')->insert($data); + }else{ + $fail_item[]=$mainInfo->entrust.' 取消签到失败:记录未更新'; + } + }else{ + $fail_item[]=$mainInfo->entrust.' 调用检查系统删除签到接口失败:'.$yg_cancelsign['msg']; + } + } + return \Yz::Return(true,'操作完成',['success'=>$success_item,'fail'=>$fail_item]); + } + //调用盈谷取消接口 + public function YG_CancelSign($url,$data) + { + $baseUrl=config('app.globals.YingGuBaseUrl'); + $data=json_encode($data,JSON_UNESCAPED_UNICODE); + $r=\Tools::Post($baseUrl.$url,$data,'盈谷删除签到'); + + if (!json_decode($r, true)) { + return ['status'=>false,'msg'=>"解析检查系统'删除签到接口'数据出错"]; + } + $res = json_decode($r, true); + if($res['isSuccess']==true){ + return ['status'=>true,'']; + }else{ + return ['status'=>false,'msg'=>$res['resultMsg']]; + } + } +} diff --git a/Laravel/app/Http/Middleware/XmlLog.php b/Laravel/app/Http/Middleware/XmlLog.php index ceff44d..bb96f1a 100644 --- a/Laravel/app/Http/Middleware/XmlLog.php +++ b/Laravel/app/Http/Middleware/XmlLog.php @@ -21,20 +21,27 @@ class XmlLog date_default_timezone_set('PRC'); // dd($request->getContent()); - $routers=[ - "接收申请单"=>'/api/v1/T/CreateEntrustRecordXml', + $actions=[ + "接收申请单"=>'T0002', + "申请单状态变更"=>'T0003', + "检查完成通知"=>'MES0006' ]; Log::info($request->getContent()); $insertid=0; $data=[ - 'mark'=>array_search($request->getPathInfo(), $routers), + 'mark'=>null, 'ip'=>"", 'request_header'=>$request->header(), 'post_data'=>$request->getContent(), 'get_data'=>[], 'request_url'=>$request->getPathInfo() ]; + preg_match('/(.*?)<\/action>/', $request->getContent(), $matches); + if (!empty($matches)) { + $data['mark']= array_search($matches[1], $actions); + } + $insertid= self::RequestLog($data,$insertid); $response= $next($request); diff --git a/Laravel/app/Lib/Tools.php b/Laravel/app/Lib/Tools.php index 45c8f8e..c4ba79b 100644 --- a/Laravel/app/Lib/Tools.php +++ b/Laravel/app/Lib/Tools.php @@ -1,4 +1,8 @@ $url, + 'post_data'=>$data_string, + ]; + $log_id=self::RequestLog($data,0,$mark); + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json; charset=utf-8', + 'Content-Length: ' . strlen($data_string) + ]); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string); + $r = curl_exec($curl); + curl_close($curl); + // $r='{"resultMsg":"登记成功1111","resultCode":"0","resultDatas":[{"queueNo":"16","checkNo":"2108180032","videoRoom":"超声影像室","isStudyGroupRegistration":"N","imageNo":"p2108180029","currentNum":1},{"queueNo":"17","checkNo":"2108180033","videoRoom":"超声影像室","isStudyGroupRegistration":"N","imageNo":"p2108180029","currentNum":2},{"queueNo":"18","checkNo":"2108180034","videoRoom":"超声影像室","isStudyGroupRegistration":"N","imageNo":"p2108180029","currentNum":3}],"isSuccess":true}'; + + $data=[ + 'response_data'=>$r + ]; + self::RequestLog($data,$log_id); + + + + + return $r; + } + public static function RequestLog($arr,$id,$mark='') + { //记录请求日志 + date_default_timezone_set('PRC'); + LogService::CheckTableName(); + $table_name = 'zz_request_log_' . date('ym'); + $response_data = isset($arr['response_data']) ? self::JsonEncode($arr['response_data']) : ''; + $header_data = isset($arr['request_header']) ?self::JsonEncode($arr['request_header']):''; + $post_data = isset($arr['post_data'])?self::JsonEncode($arr['post_data']):''; + $get_data = isset($arr['get_data'])?self::JsonEncode($arr['get_data'], JSON_UNESCAPED_UNICODE):''; + $milliseconds = round(microtime(true) * 1000); + $date = date("Y-m-d H:i:s", $milliseconds / 1000); + $formatted_date = sprintf("%s.%03d", $date, $milliseconds % 1000); + + // $i=DB::insert("insert into ".$table_name." (request_ip, response_data,header_data,post_data,get_data,request_url,create_time,update_time) + // values (?,?,?,?,?,?,?,?)",[$arr['ip'],$response_data,$header_data,$post_data,$get_data,$arr['request_url'],$formatted_date,$formatted_date]); + // var_dump($i); + if ($id > 0) { + return DB::table($table_name)->where('id', $id)->update([ + 'response_data' => $response_data, + ]); + } else { + return DB::table($table_name)->insertGetId([ + 'mark'=>$mark, + 'request_ip' => '127.0.0.1', + 'response_data' => $response_data, + 'header_data' => $header_data, + 'post_data' => $post_data, + 'get_data' => $get_data, + 'request_url' => $arr['request_url'], + 'create_time' => $formatted_date, + 'update_time' => $formatted_date + ]); + } + } + public static function JsonEncode($data){ //格式化数据,转json + $post_data =$data; + $post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE); + $str_len = mb_strlen($post_data); + $str_size = $str_len / 1024; + if ($str_size > 40) $post_data = '{"data":"Row size too large"}'; + return $post_data; + } } diff --git a/Laravel/app/Services/Xml/ShenQingDanService.php b/Laravel/app/Services/Xml/ShenQingDanService.php index 7373aa9..4315beb 100644 --- a/Laravel/app/Services/Xml/ShenQingDanService.php +++ b/Laravel/app/Services/Xml/ShenQingDanService.php @@ -50,12 +50,14 @@ class ShenQingDanService 'RISRAcceptDeptCode' => $order["RISRAcceptDeptCode"] ? $order["RISRAcceptDeptCode"] : null, //接收科室代码 'warddesc' => $Body["PATAdmInfo"]["PAADMAdmWardDesc"] ? $Body["PATAdmInfo"]["PAADMAdmWardDesc"] : null, //病区 'beddesc' => $Body["PATAdmInfo"]["PAADMCurBedNo"] ? $Body["PATAdmInfo"]["PAADMCurBedNo"] : null, //病床号 + 'app_num' => $order["RISRAppNum"] ? $order["RISRAppNum"] : null, //申请单号 + ]; $requiredFields = [ 'reg_num', 'user_name', 'user_sex', 'entrust', 'is_pay', 'reservation_department', 'entrust_date', 'entrust_time', 'user_brithday', 'patient_type', - 'implement_department', 'entrust_id', 'episodeid', 'RISRAcceptDeptCode' + 'implement_department', 'entrust_id', 'episodeid', 'RISRAcceptDeptCode','app_num' ]; // 判断是否为空 diff --git a/Laravel/config/app.php b/Laravel/config/app.php index ec0baf4..3055ffe 100644 --- a/Laravel/config/app.php +++ b/Laravel/config/app.php @@ -13,6 +13,7 @@ return [ 'WxReturnCodeUrl_local'=>'http://192.168.31.106:5173/#/getWxCode/', //获取code后引导返回到前端的地址 开发 'WxReturnCodeUrl_server'=>'https://www.yanzai.vip/common/mH5/#/getWxCode/', //获取code后引导返回到前端的地址 生产 + 'YingGuBaseUrl'=>'http://192.168.0.1', //盈谷url ], diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php index 9e2bf13..03d4c94 100644 --- a/Laravel/routes/api.php +++ b/Laravel/routes/api.php @@ -97,6 +97,8 @@ Route::group(['middleware'=>['checktoken','log'],'prefix'=>'v1'],function () { Route::post('admin/InpatientWardGetList','App\Http\Controllers\API\Admin\YeWu\InpatientWardController@GetList');//获取病区列表 Route::post('admin/InpatientWardSave','App\Http\Controllers\API\Admin\YeWu\InpatientWardController@Save');//保存病区 Route::post('admin/InpatientWardDel','App\Http\Controllers\API\Admin\YeWu\InpatientWardController@Del');//删除病区 + Route::post('admin/SignIn','App\Http\Controllers\API\Admin\YeWu\SignInController@SignIn');//签到 + Route::post('admin/CancelSign','App\Http\Controllers\API\Admin\YeWu\SignInController@CancelSign');//取消签到 }); //暂时不加权限 diff --git a/YiJi-admin/src/api/api.js b/YiJi-admin/src/api/api.js index 9eda97c..3ad5034 100644 --- a/YiJi-admin/src/api/api.js +++ b/YiJi-admin/src/api/api.js @@ -314,3 +314,11 @@ export const InpatientWardSave = (data = {}) => { export const InpatientWardDel = (data = {}) => { return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/InpatientWardDel', data: data }) } +//签到 +export const SignIn = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/SignIn', data: data }) +} +//取消签到 +export const CancelSign = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/CancelSign', data: data }) +} \ No newline at end of file diff --git a/YiJi-admin/src/views/YeWu/MainList.vue b/YiJi-admin/src/views/YeWu/MainList.vue index 4977170..19f8850 100644 --- a/YiJi-admin/src/views/YeWu/MainList.vue +++ b/YiJi-admin/src/views/YeWu/MainList.vue @@ -64,7 +64,8 @@ 预 约 取消预约 更改预约时间 - 报到 + 报到 + 取消报到 打印申请单隐藏按钮 打印申请单 打印表格 @@ -201,8 +202,15 @@
检查项目:{{item.maininfo.entrust}}
- - + + +
+ {{item}} +
+
+ {{item}} +
+
@@ -220,7 +228,7 @@ DepartmentResourceGetEnableList, GetServiceDateTime, GetLoglist, - CheckEntrstItemGroup,getMainDetail + CheckEntrstItemGroup,getMainDetail,SignIn,CancelSign } from '@/api/api.js' import { ElMessage, @@ -566,6 +574,73 @@ const closeIfram=()=>{ GetList() } + //签到 + let TiShiShow=ref(false); + let successItem=ref([]); + let failItem=ref([]); + const SignInFunc=()=>{ + if (tableSelected.value.length === 0) { + ElMessage.error('请勾选1条记录') + return false + } + let ids=[]; + tableSelected.value.forEach((v,i)=>{ + ids.push(v.id) + }) + loading.value=true; + SignIn({ + MainListIds:ids + }).then(res => { + loading.value=false + if (res.status) { + if(res.data.success.length==ids.length){ + ElMessage({ + message: "签到成功", + type: 'success', + }) + }else{ + TiShiShow.value=true + successItem.value=res.data.success + failItem.value=res.data.fail + } + GetList() + }else{ + ElMessage.error(res.msg) + } + }) + } + //取消报到 + const CancelSignFunc=()=>{ + if (tableSelected.value.length === 0) { + ElMessage.error('请勾选1条记录') + return false + } + let ids=[]; + tableSelected.value.forEach((v,i)=>{ + ids.push(v.id) + }) + loading.value=true; + CancelSign({ + MainListIds:ids + }).then(res => { + loading.value=false + if (res.status) { + if(res.data.success.length==ids.length){ + ElMessage({ + message: "取消成功", + type: 'success', + }) + }else{ + TiShiShow.value=true + successItem.value=res.data.success + failItem.value=res.data.fail + } + GetList() + }else{ + ElMessage.error(res.msg) + } + }) + } onMounted(() => { if(loginUserinfo.value.group!=2){ getEnableResource()