新增处方队列执行,系统配置选择添加队列
This commit is contained in:
parent
3d4a941537
commit
c120103692
@ -29,7 +29,7 @@ use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* 分配医生
|
||||
* 自动分配医生
|
||||
* 快速问诊、问诊购药等订单支付完成后,进行分配医生
|
||||
*/
|
||||
#[Consumer(exchange: 'amqp.direct', routingKey: 'AssignDoctor', queue: 'assign.doctor.queue', nums: 1)]
|
||||
|
||||
58
app/Amqp/Consumer/AutoPharmacistCaVerifyConsumer.php
Normal file
58
app/Amqp/Consumer/AutoPharmacistCaVerifyConsumer.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
||||
/**
|
||||
* 药师自动签章审核
|
||||
* 医生签章后,加入此队列,下载医生签章pdf,并进行药师/医院签章审核
|
||||
*/
|
||||
#[Consumer(exchange: 'amqp.direct', routingKey: 'AutoPharmacistCaVerify', queue: 'auto.pharmacist.ca.verify.queue', nums: 1)]
|
||||
class AutoPharmacistCaVerifyConsumer extends ConsumerMessage
|
||||
{
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance()->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;
|
||||
}
|
||||
}
|
||||
@ -8,7 +8,7 @@ use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
|
||||
/**
|
||||
* 分配医生
|
||||
* 自动分配医生
|
||||
* 快速问诊、问诊购药等订单支付完成后,进行分配医生
|
||||
*/
|
||||
#[Producer(exchange: 'amqp.direct', routingKey: 'AssignDoctor')]
|
||||
|
||||
28
app/Amqp/Producer/AutoPharmacistCaVerifyProducer.php
Normal file
28
app/Amqp/Producer/AutoPharmacistCaVerifyProducer.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
|
||||
/**
|
||||
* 药师自动签章审核
|
||||
* 医生签章后,加入此队列,下载医生签章pdf,并进行药师/医院签章审核
|
||||
*/
|
||||
#[Producer(exchange: 'amqp.direct', routingKey: 'AutoPharmacistCaVerify')]
|
||||
class AutoPharmacistCaVerifyProducer extends ProducerMessage
|
||||
{
|
||||
/**
|
||||
* @param $data
|
||||
* [
|
||||
* prescription_file_id:订单-处方表-ca处方文件主键
|
||||
* order_prescription_id:订单-处方id
|
||||
* ]
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->payload = $data;
|
||||
}
|
||||
}
|
||||
@ -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";
|
||||
|
||||
|
||||
43
app/Model/SystemConfig.php
Normal file
43
app/Model/SystemConfig.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $system_config_id 主键id
|
||||
* @property int $is_auto_phar_verify_prescription 药师是否自动审核处方(0:否 1:是)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class SystemConfig extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'system_config';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['system_config_id', 'is_auto_phar_verify_prescription', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "system_config_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
|
||||
@ -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']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user