From c120103692ff381aa68abf78acf13dfc91e1876b Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 20 Apr 2023 14:14:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=84=E6=96=B9=E9=98=9F?= =?UTF-8?q?=E5=88=97=E6=89=A7=E8=A1=8C=EF=BC=8C=E7=B3=BB=E7=BB=9F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=80=89=E6=8B=A9=E6=B7=BB=E5=8A=A0=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Amqp/Consumer/AssignDoctorConsumer.php | 2 +- .../AutoPharmacistCaVerifyConsumer.php | 58 +++++++++++++++++++ app/Amqp/Producer/AssignDoctorProducer.php | 2 +- .../AutoPharmacistCaVerifyProducer.php | 28 +++++++++ app/Model/OrderPrescription.php | 3 +- app/Model/SystemConfig.php | 43 ++++++++++++++ app/Services/OrderPrescriptionService.php | 17 ------ app/Services/UserDoctorService.php | 28 +++++++++ 8 files changed, 161 insertions(+), 20 deletions(-) create mode 100644 app/Amqp/Consumer/AutoPharmacistCaVerifyConsumer.php create mode 100644 app/Amqp/Producer/AutoPharmacistCaVerifyProducer.php create mode 100644 app/Model/SystemConfig.php diff --git a/app/Amqp/Consumer/AssignDoctorConsumer.php b/app/Amqp/Consumer/AssignDoctorConsumer.php index bcda1f0..2b796f2 100644 --- a/app/Amqp/Consumer/AssignDoctorConsumer.php +++ b/app/Amqp/Consumer/AssignDoctorConsumer.php @@ -29,7 +29,7 @@ use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; /** - * 分配医生 + * 自动分配医生 * 快速问诊、问诊购药等订单支付完成后,进行分配医生 */ #[Consumer(exchange: 'amqp.direct', routingKey: 'AssignDoctor', queue: 'assign.doctor.queue', nums: 1)] diff --git a/app/Amqp/Consumer/AutoPharmacistCaVerifyConsumer.php b/app/Amqp/Consumer/AutoPharmacistCaVerifyConsumer.php new file mode 100644 index 0000000..e630b2f --- /dev/null +++ b/app/Amqp/Consumer/AutoPharmacistCaVerifyConsumer.php @@ -0,0 +1,58 @@ +error("开始执行 药师自动签章审核 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE)); + + Db::beginTransaction(); + + try { + // 检测入参参数 + $res = $this->checkParams($data); + + Db::commit(); + Log::getInstance()->error("药师自动签章审核 队列执行成功"); + } catch (\Exception $e) { + Db::rollBack(); + Log::getInstance()->error("药师自动签章审核 队列执行失败原因:" . $e->getMessage()); + return Result::REQUEUE; // 重回队列 + } + + return Result::ACK; + } + + /** + * 检测执行参数 + * @param array $data + * @return bool + */ + protected function checkParams(array $data): bool + { + if (!isset($data['prescription_file_id'])){ + return false; + } + + if (!isset($data['order_prescription_id'])){ + return false; + } + return true; + } +} diff --git a/app/Amqp/Producer/AssignDoctorProducer.php b/app/Amqp/Producer/AssignDoctorProducer.php index 3f6d5f3..5a30c1f 100644 --- a/app/Amqp/Producer/AssignDoctorProducer.php +++ b/app/Amqp/Producer/AssignDoctorProducer.php @@ -8,7 +8,7 @@ use Hyperf\Amqp\Annotation\Producer; use Hyperf\Amqp\Message\ProducerMessage; /** - * 分配医生 + * 自动分配医生 * 快速问诊、问诊购药等订单支付完成后,进行分配医生 */ #[Producer(exchange: 'amqp.direct', routingKey: 'AssignDoctor')] diff --git a/app/Amqp/Producer/AutoPharmacistCaVerifyProducer.php b/app/Amqp/Producer/AutoPharmacistCaVerifyProducer.php new file mode 100644 index 0000000..029d07c --- /dev/null +++ b/app/Amqp/Producer/AutoPharmacistCaVerifyProducer.php @@ -0,0 +1,28 @@ +payload = $data; + } +} diff --git a/app/Model/OrderPrescription.php b/app/Model/OrderPrescription.php index 24dc82e..8570a10 100644 --- a/app/Model/OrderPrescription.php +++ b/app/Model/OrderPrescription.php @@ -27,6 +27,7 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property int $platform_audit_status 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回) * @property string $platform_fail_time 平台审核失败时间 * @property string $platform_fail_reason 处方平台驳回原因 + * @property int $is_auto_phar_verify 是否药师自动审核(0:否 1:是) * @property string $doctor_created_time 医生开具处方时间 * @property string $expired_time 处方过期时间 * @property int $is_delete 是否删除(0:否 1:是) @@ -54,7 +55,7 @@ class OrderPrescription extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'patient_id', 'family_id', 'pharmacist_id', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_verify_time', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_time', 'platform_fail_reason', 'doctor_created_time', 'expired_time', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'doctor_advice', 'created_at', 'updated_at']; + protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'patient_id', 'family_id', 'pharmacist_id', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_verify_time', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_time', 'platform_fail_reason', 'is_auto_phar_verify', 'doctor_created_time', 'expired_time', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'doctor_advice', 'created_at', 'updated_at']; protected string $primaryKey = "order_prescription_id"; diff --git a/app/Model/SystemConfig.php b/app/Model/SystemConfig.php new file mode 100644 index 0000000..2f46dc7 --- /dev/null +++ b/app/Model/SystemConfig.php @@ -0,0 +1,43 @@ +first($fields); + } +} diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index 1416a76..43529ac 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -158,17 +158,6 @@ class OrderPrescriptionService extends BaseService throw new BusinessException("医生开方日期错误"); } -// // 获取处方文件数据 -// $params = array(); -// $params['order_prescription_id'] = $order_prescription_id; -// $order_prescription_file = OrderPrescriptionFile::getOne($params); -// if (empty($order_prescription_file)){ -// // 检测处方图片 -// if ($user['user_type'] == 3) { -// throw new BusinessException("处方文件错误"); -// } -// } - $CaService = new CaService($order_prescription,$user); // 获取云证书签名+验证云证书签名 @@ -197,9 +186,6 @@ class OrderPrescriptionService extends BaseService // 进行处方pdf签章 $file_id = $CaService->addSignPdf($order_prescription,$user['user_type']); - // 增加队列处理、自动下载处方签章文件并上传oss - - if ($user['user_type'] == 3) { // 药师端时,需要进行系统签章 // 把药师签章的pdf存储至本地文件 @@ -208,9 +194,6 @@ class OrderPrescriptionService extends BaseService // 进行处方pdf签章 $file_id = $CaService->addSignPdf($order_prescription,$user['user_type']); - - // 加入下载签章队列 - } $result = array(); diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 12b0335..271d333 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -5,6 +5,7 @@ namespace App\Services; use App\Amqp\Producer\AssignPharmacistProducer; use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer; use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer; +use App\Amqp\Producer\AutoPharmacistCaVerifyProducer; use App\Constants\DoctorTitleCode; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; @@ -32,6 +33,7 @@ use App\Model\PatientHistoryInquiry; use App\Model\Popup; use App\Model\Product; use App\Model\ProductPlatformAmount; +use App\Model\SystemConfig; use App\Model\SystemInquiryConfig; use App\Model\SystemInquiryTime; use App\Model\User; @@ -1381,8 +1383,18 @@ class UserDoctorService extends BaseService return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); } + // 获取系统配置 + $params = array(); + $params['system_config_id'] = 1; + $system_config = SystemConfig::getOne($params); + if (empty($system_config)){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); + } + // 修改处方表 $data = array(); + $data['is_auto_phar_verify'] = $system_config['is_auto_phar_verify_prescription'];// 是否药师自动审核(0:否 1:是) $data['doctor_created_time'] = date('Y-m-d H:i:s',time()); $params = array(); @@ -1400,6 +1412,22 @@ class UserDoctorService extends BaseService return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); } + if ($system_config['is_auto_phar_verify_prescription'] == 1){ + // 添加药师自动签章审核队列 + $data = array(); + $data['prescription_file_id'] = $prescription_open_result['file_id']; + $data['order_prescription_id'] = $order_prescription->order_prescription_id; + + $message = new AutoPharmacistCaVerifyProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + // 处方开具成功,添加自动签章审核队列失败 + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); + } + } + // 发送消息-药师审核中 $ImService = new ImService(); $ImService->pharmacistVerify($order_inquiry,(string)$order_prescription->order_prescription_id,$product_name,$user_doctor['user_id'],$order_inquiry['user_id']);