From c2830d3ae26e028a8eaf05c5ecbe403fc41aeeed Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 30 Mar 2023 14:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BA=E8=8D=AF?= =?UTF-8?q?=E5=93=81=E8=AE=A2=E5=8D=95=20=E8=AE=A2=E5=8D=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/TestController.php | 8 ++- app/Services/OrderPrescriptionService.php | 76 +++++++++++++---------- app/Services/PatientOrderService.php | 4 +- 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index ae15e1b..b589293 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -30,7 +30,9 @@ class TestController extends AbstractController // $this->test_4(); // $this->test_6(); // $this->test_9(); - $this->test_10(); +// $this->test_10(); + $this->test_11(); +// $this->test_5(); } // 获取云证书-首次 @@ -166,7 +168,7 @@ class TestController extends AbstractController // 下载阿里云图片 $oss = new Oss(); - $filename = "Basic/images/prescription_img.jpg"; + $filename = "Basic/images/prescription.jpg"; $sign_image = $oss->getObjectToRAM($filename); $manager = new ImageManager(); @@ -502,6 +504,6 @@ class TestController extends AbstractController public function test_11(){ $OrderPrescriptionService = new OrderPrescriptionService(); - $result = $OrderPrescriptionService->doctorOpenPrescription("499871705345941504"); + $result = $OrderPrescriptionService->doctorOpenPrescription("499871705345941504",1); } } \ No newline at end of file diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index e45c3c5..5de037a 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -11,6 +11,7 @@ use App\Model\OrderPrescription; use App\Model\OrderPrescriptionIcd; use App\Model\OrderPrescriptionProduct; use App\Model\OrderProductItem; +use App\Model\User; use App\Model\UserDoctor; use Extend\Alibaba\Oss; use Extend\Ca\Ca; @@ -106,7 +107,7 @@ class OrderPrescriptionService extends BaseService } // 医生开具处方 - public function doctorOpenPrescription(string $order_prescription_id) + public function doctorOpenPrescription(string $order_prescription_id,string $user_type) { try { // 获取处方数据 @@ -169,40 +170,40 @@ class OrderPrescriptionService extends BaseService $icd_name = ""; } - $ca = new Ca(); - - // 获取云证书签名 - $data = array(); - $data['created_at'] = $order_prescription['doctor_created_time']; - $data['department_custom_name'] = $hospital_department_custom['department_name'] ?: ""; - $data['user_name'] = $order_prescription['patient_name']; - $data['sex'] = sexToStringSex($order_prescription['patient_sex']); - $data['age'] = $order_prescription['patient_age']; - $data['allergy_history'] = $order_inquiry_case['allergy_history'] ?: "无"; - $data['icd_name'] = $icd_name; - $data['doctor_advice'] = $order_prescription['doctor_advice'] ?: "无"; - - // 商品数据 - $data['product'] = array(); - foreach ($order_prescription_product as $item){ - $product = array(); - $product['product_name'] = $item['product_name'] . "(" . $item['product_spec'] . ")"; // 商品名称+商品规格 - $product['single_unit'] = $item['single_unit'] ?: ""; // 单次剂量(例:1次1包) - $product['frequency_use'] = $item['frequency_use'] ?: ""; // 使用频率(例:1天3次) - $product['single_use'] = $item['single_use'] ?: ""; // 单次用法(例:口服) - $product['prescription_product_num'] = $item['prescription_product_num'] . $item['packaging_unit']; // 商品数量 + 基本包装单位(例:盒/瓶) - $data['product'][] = $product; - } - - $cert_sign_result = $ca->getCertSign("491925054435950592", "491925054435950592", $data); - - // 验证云证书签名-验证无需处理,只要不返回错误即可 - $ca->verifyPkcs7($cert_sign_result['signP7'],$data); +// $ca = new Ca(); +// +// // 获取云证书签名 +// $data = array(); +// $data['created_at'] = $order_prescription['doctor_created_time']; +// $data['department_custom_name'] = $hospital_department_custom['department_name'] ?: ""; +// $data['user_name'] = $order_prescription['patient_name']; +// $data['sex'] = sexToStringSex($order_prescription['patient_sex']); +// $data['age'] = $order_prescription['patient_age']; +// $data['allergy_history'] = $order_inquiry_case['allergy_history'] ?: "无"; +// $data['icd_name'] = $icd_name; +// $data['doctor_advice'] = $order_prescription['doctor_advice'] ?: "无"; +// +// // 商品数据 +// $data['product'] = array(); +// foreach ($order_prescription_product as $item){ +// $product = array(); +// $product['product_name'] = $item['product_name'] . "(" . $item['product_spec'] . ")"; // 商品名称+商品规格 +// $product['single_unit'] = $item['single_unit'] ?: ""; // 单次剂量(例:1次1包) +// $product['frequency_use'] = $item['frequency_use'] ?: ""; // 使用频率(例:1天3次) +// $product['single_use'] = $item['single_use'] ?: ""; // 单次用法(例:口服) +// $product['prescription_product_num'] = $item['prescription_product_num'] . $item['packaging_unit']; // 商品数量 + 基本包装单位(例:盒/瓶) +// $data['product'][] = $product; +// } +// +// $cert_sign_result = $ca->getCertSign("491925054435950592", "491925054435950592", $data); +// +// // 验证云证书签名-验证无需处理,只要不返回错误即可 +// $ca->verifyPkcs7($cert_sign_result['signP7'],$data); // 生成处方pdf图片 $oss = new Oss(); - $filename = "basic/file/prescription.pdf"; + $filename = "basic/file/prescription.jpg"; $sign_image = $oss->getObjectToRAM($filename); $manager = new ImageManager(); @@ -273,6 +274,7 @@ class OrderPrescriptionService extends BaseService $font->align('left'); }); + // 商品数据 foreach ($order_prescription_product as $key => $item){ if ($key <= 2){ $x_axis = 229; @@ -312,11 +314,21 @@ class OrderPrescriptionService extends BaseService $pdf->AddPage(); $pdf->Image('@' . $img_result, 10, 10, 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false); + + // 生成本地文件 $pdf->Output(dirname(__DIR__, 2) . "/prescription_img.pdf","F"); + // 生成文件流 + $pdf_result = $pdf->Output("","S"); + + // 上传oss + $filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'pdf'; + + $prescription_pdf = $oss->putObject($filename, $pdf_result); + dump($prescription_pdf); } catch (\Exception $e) { - + dump($e->getMessage()); } } } \ No newline at end of file diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index 9dc9f02..a52c735 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -866,10 +866,10 @@ class PatientOrderService extends BaseService return fail(HttpEnumCode::HTTP_ERROR, "处方未审核"); } - if ($order_prescription['prescription_status'] == 3) { + if ($order_prescription['prescription_status'] == 4) { return fail(HttpEnumCode::HTTP_ERROR, "处方已失效"); } - if ($order_prescription['prescription_status'] == 4) { + if ($order_prescription['prescription_status'] == 5) { return fail(HttpEnumCode::HTTP_ERROR, "处方已使用"); }