From f0fb754d82dc8d58e46fc767d5a803d86c98765e Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 3 Apr 2023 14:34:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/TestController.php | 66 ++++++++++++++++++++++- app/Services/OrderPrescriptionService.php | 7 ++- app/Services/UserPharmacistService.php | 2 + 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 8751d92..6c52389 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -34,13 +34,14 @@ class TestController extends AbstractController // $this->test_3(); // $this->test_4(); // $this->test_6(); - $this->test_9(); +// $this->test_9(); // $this->test_10(); // $this->test_11(); // $this->test_5(); // $this->test_1(); // $this->test_11(); // $this->test_12(); + $this->test_13(); } // 获取云证书-首次 @@ -498,7 +499,7 @@ class TestController extends AbstractController // 下载签章的pdf文件 public function test_9(){ $ca = new Ca(); - $result = $ca->getSignedFile("5345345461","1642762886467977217"); + $result = $ca->getSignedFile("5345345461","1642769369872105473"); if (empty($result)){ return fail(); } @@ -643,4 +644,65 @@ class TestController extends AbstractController // dump($result); } + public function test_13(){ + $oss = new Oss(); + $hospital_sign_image_path = "basic/file/hospital_signature.png"; + + // 下载医院签名图片 + $style = "image/resize,w_300,h_300"; + $sign_image = $oss->getCusTomObjectToRAM($hospital_sign_image_path,$style); + $sign_image = base64_encode($sign_image); + if (!$sign_image){ + throw new BusinessException("医院签名图片下载失败"); + } + + $sign_param = [ + [ // 医院签章 + "llx"=>"1550", // 左边底部X坐标 + "lly"=>"1350", // 左边底部Y坐标 + "urx"=>"2250", // 右边上部x坐标 + "ury"=>"650", // 右边上部y坐标 + "pageList"=>[1], + "sealImg"=>$sign_image + ], + ]; + + // 打开处方pdf文件 + unset($pdf_file); + $pdf_file = fopen("./runtime/" . "501383937792086017" . ".pdf",'r'); + + $ca = new Ca(); + + // 处方pdf进行签章 + $data = array(); + $data['sign_param'] = json_encode($sign_param); + $data['pdf_file'] = $pdf_file; + $hospital_sign_pdf_result = $ca->addSignPdf("5345345461",$data); + if (empty($hospital_sign_pdf_result[0]['fileId'])){ + throw new BusinessException("处方签章失败"); + } + + dump($hospital_sign_pdf_result); + + dump("处方pdf进行医院签章成功"); + + + + // 下载处方签章文件 + unset($prescription_pdf_result); + $file_id = $hospital_sign_pdf_result[0]['fileId']; + $prescription_pdf_result = $ca->getSignedFile("5345345461",$file_id); + + if (empty($prescription_pdf_result)){ + throw new BusinessException("下载处方签章文件失败"); + } + + dump("下载医院处方签章文件成功"); + + $file = fopen("./runtime/test.pdf", "w") or die("Unable to open file!"); + fwrite($file, $prescription_pdf_result); + fclose($file); + + } + } \ No newline at end of file diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index 6b7f805..5448a63 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -452,6 +452,10 @@ class OrderPrescriptionService extends BaseService // 打开处方pdf文件 $pdf_file = fopen("./runtime/" . $order_prescription['order_prescription_id'] . ".pdf",'r'); + if (!$pdf_file){ + throw new BusinessException("处方图片打开失败"); + } + // 处方pdf进行签章 $data = array(); @@ -529,11 +533,12 @@ class OrderPrescriptionService extends BaseService throw new BusinessException("下载处方签章文件失败"); } - dump("下载处方签章文件成功"); + dump("下载医院处方签章文件成功"); // 上传oss $hospital_filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'pdf'; $prescription_pdf_url = $oss->putObject($hospital_filename, $prescription_pdf_result); + dump("上传医院处方签章文件成功"); } $result = array(); diff --git a/app/Services/UserPharmacistService.php b/app/Services/UserPharmacistService.php index a73f248..e1adcc1 100644 --- a/app/Services/UserPharmacistService.php +++ b/app/Services/UserPharmacistService.php @@ -127,6 +127,8 @@ class UserPharmacistService extends BaseService public function putPrescriptionVerify(): array { $user_info = $this->request->getAttribute("userInfo") ?? []; + $user_info['user_id'] = "534534546"; + $user_info['client_user_id'] = "534534546"; $order_prescription_id = $this->request->route('order_prescription_id'); $pharmacist_audit_status = $this->request->input('pharmacist_audit_status');