This commit is contained in:
wucongxing 2023-04-25 17:03:51 +08:00
parent ec457bf594
commit 5181d8f43b
4 changed files with 10 additions and 483 deletions

View File

@ -45,7 +45,7 @@ class AssignDoctorConsumer extends ConsumerMessage
*/ */
public function consumeMessage($data, AMQPMessage $message): string public function consumeMessage($data, AMQPMessage $message): string
{ {
Log::getInstance()->error("开始执行 分配医生 队列" . json_encode($data, JSON_UNESCAPED_UNICODE)); Log::getInstance('queue-AssignDoctor')->info("开始" . json_encode($data, JSON_UNESCAPED_UNICODE));
Db::beginTransaction(); Db::beginTransaction();
@ -56,14 +56,14 @@ class AssignDoctorConsumer extends ConsumerMessage
$order_inquiry = OrderInquiry::getOne($params); $order_inquiry = OrderInquiry::getOne($params);
if (empty($order_inquiry)) { if (empty($order_inquiry)) {
Db::rollBack(); Db::rollBack();
Log::getInstance()->error("分配医生队列执行失败:未查询到对应订单数据"); Log::getInstance()->error("错误:未查询到对应订单数据");
return Result::DROP;// 销毁 return Result::DROP;// 销毁
} }
$res = $this->checkInquiryStatus($order_inquiry); $res = $this->checkInquiryStatus($order_inquiry);
if (!$res){ if (!$res){
Db::rollBack(); Db::rollBack();
Log::getInstance()->error("分配医生队列执行失败:订单状态错误"); Log::getInstance()->error("错误:订单状态错误");
return Result::DROP;// 销毁 return Result::DROP;// 销毁
} }

View File

@ -69,485 +69,7 @@ class TestController extends AbstractController
$this->test_15(); $this->test_15();
} }
// 获取云证书-首次
public function test_1(){
$ca = new Ca();
// // 测试医生
// $data = array();
// $data['user_id'] = "491925054435950592";
// $data['card_num'] = "410323199603261241";
// $result = $ca->getCloudCert($data);
//
// $data = array();
// $data['user_id'] = "491925054435950592";
// $data['cert_base64'] = $result['certBase64'];
// $data['cert_chain_p7'] = $result['certP7'];
// $data['cert_serial_number'] = $result['certSerialnumber'];
// $data['ca_pin'] = "491925054435950592";
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
// if (empty($doctor_pharmacist_cert)){
// return fail();
// }
// 测试药师
// $data = array();
// $data['user_id'] = "534534546";
// $data['card_num'] = "410323199603261240";
// $result = $ca->getCloudCert($data);
//
// $data = array();
// $data['user_id'] = "534534546";
// $data['cert_base64'] = $result['certBase64'];
// $data['cert_chain_p7'] = $result['certP7'];
// $data['cert_serial_number'] = $result['certSerialnumber'];
// $data['ca_pin'] = "534534546";
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
// if (empty($doctor_pharmacist_cert)){
// return fail();
// }
// 测试企业
// $data = array();
// $data['user_id'] = "5345345461";
// $data['card_num'] = "91510106MABTJY4K9R";
// $result = $ca->getCloudCert($data,"Organizational");
//
// $data = array();
// $data['is_system'] = 1;
// $data['cert_base64'] = $result['certBase64'];
// $data['cert_chain_p7'] = $result['certP7'];
// $data['cert_serial_number'] = $result['certSerialnumber'];
// $data['ca_pin'] = "5345345461";
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
// if (empty($doctor_pharmacist_cert)){
// return fail();
// }
}
// 获取用户云证书数据-验证PKCS7签名
public function test_2(){
$ca = new Ca();
$params = array();
$params['user_id'] = "491925054435950592";
$params['type'] = 1;
$doctor_pharmacist_cert = UserCaCert::getOne($params);
if (empty($doctor_pharmacist_cert)){
return fail(HttpEnumCode::HTTP_ERROR,"用户数据错误");
}
// 获取云证书签名
$data = array();
$data['created_at'] = "2023-03-01 12:44:10";
$data['department_custom_name'] = "外科";
$data['user_name'] = "测试用户1";
$data['sex'] = "";
$data['age'] = 19;
$data['allergy_history'] = "";
$data['icd_name'] = "感冒";
$data['doctor_advice'] = "多吃药";
$data['product'] = [
[
"product_name" => "感冒药150ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
[
"product_name" => "感冒药250ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
[
"product_name" => "感冒药350ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
[
"product_name" => "感冒药450ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
[
"product_name" => "感冒药550ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
];
$result = $ca->getCertSign("491925054435950592","491925054435950592",$data);
// 验证PKCS7签名-验证无需处理,只要不返回错误即可
$ca->verifyPkcs7($result['signP7'],$data);
}
// 添加签章配置(首次)
public function test_3(){
$CaOnline = new CaOnline();
// // 下载阿里云图片
// $oss = new Oss();
//
// $filename = "applet/doctor/cert/f2abdb81-fac0-4264-bc11-aa2b6cf2761c.png";
//
// $style = "image/resize,m_lfit,w_100,h_350";
//
// $sign_image = $oss->getCusTomObjectToRAM($filename,$style);
// $sign_image = base64_encode($sign_image);
// if (!$sign_image){
// return fail(HttpEnumCode::SERVER_ERROR);
// }
//
// $sign_param = [
// [
// "llx"=> "500", // 左边底部X坐标
// "lly"=>"3015", // 左边底部Y坐标
// "urx"=>"850", // 右边上部x坐标
// "ury"=>"3115", // 右边上部y坐标
// "pageList"=>[1],
// "sealImg"=>$sign_image
// ]
// ];
// $data = array();
// $data['sign_param'] = json_encode($sign_param);
// $data['seal_img'] = $sign_image;
//
// $result = $ca->addUserSignConfig("491925054435950592","410323199603261241",$data);
// 下载阿里云图片
$oss = new Oss();
$filename = "applet/doctor/cert/f2abdb81-fac0-4264-bc11-aa2b6cf2761c.png";
$style = "image/resize,m_lfit,w_100,h_350";
$sign_image = $oss->getCusTomObjectToRAM($filename,$style);
$sign_image = base64_encode($sign_image);
if (!$sign_image){
return fail(HttpEnumCode::SERVER_ERROR);
}
$sign_param = [
[ // 医生端
"llx" => "120", // 左边底部X坐标
"lly" => "190", // 左边底部Y坐标
"urx" => "190", // 右边上部x坐标
"ury" => "140", // 右边上部y坐标
"pageList" => [1],
"sealImg" => $sign_image
],
];
$data = array();
$data['sign_param'] = json_encode($sign_param);
$data['seal_img'] = $sign_image;
$result = $CaOnline->addUserSignConfig("491925054435950592","130582199202032038",$data);
}
// 获取用户签章图片
public function test_4(){
$ca = new Ca();
$result = $ca->getFetchUserSeal("491925054435950592");
$data = urldecode($result[0]['sealImg']);
dump($data);
}
// 生成处方pdf图片
public function test_5(){
// 下载阿里云图片
// $oss = new Oss();
//
// $filename = "basic/file/prescription.jpg";
// $sign_image = $oss->getObjectToRAM($filename);
$sign_image = fopen("./extend/Ca/prescription.jpg", 'r+');
$manager = new ImageManager();
$image = $manager->make($sign_image);
$fontPath = './extend/Ca/msyh.ttf';
// 处方号
$image->text('1234567890', 1480, 540, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
// 日期
$image->text('2023-03-21', 354, 675, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
// 科室
$image->text('测试科室1', 1385, 675, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
// 姓名
$image->text('测试姓名', 354, 795, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
// 性别
$image->text('男', 1385, 790, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
// 年龄
$image->text('19', 354, 900, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
// 过敏史
$image->text('对阿莫西林过敏对阿莫西林过敏', 405, 1030, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
// 初步诊断
$image->text('对阿莫西林过敏对阿莫西林过敏', 445, 1145, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
// 医生建议
$image->text('没有建议', 445, 1252, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(60);
$font->align('left');
});
$data = array();
$data['product'] = [
[
"product_name" => "感冒药150ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
[
"product_name" => "感冒药250ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
[
"product_name" => "感冒药350ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
[
"product_name" => "感冒药450ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
[
"product_name" => "感冒药550ml*10",
"single_unit" => "一次一包",
"frequency_use" => "1天3次",
"single_use" => "口服",
"prescription_product_num" => "X1盒",
],
];
// 用药
foreach ($data['product'] as $key => $item){
if ($key <= 2){
$x_axis = 229;
$y_axis = 1600 + $key * 350;
}else{
$x_axis = 1240;
$y_axis = 1600 + ($key - 3) * 350;
}
$image->text($item['product_name'], $x_axis, $y_axis, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(50);
$font->align('left');
});
$image->text("用量:" . $item['single_unit'] . " " . $item['frequency_use'], $x_axis, $y_axis+90, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(50);
$font->align('left');
});
$image->text("用法:" . $item['single_use'], $x_axis, $y_axis+180, function ($font) use($fontPath) {
$font->file($fontPath);
$font->size(50);
$font->align('left');
});
}
// 将处理后的图片重新保存到其他路径
// $image->save('./runtime/2.jpg');
$result = (string) $image->encode('png', 75);
// 图片生成pdf
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->AddPage();
$pdf->Image('@' . $result, 10, 10, 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false);
$path = dirname(__DIR__, 2) . "/file/prescription/";
$a = mkdirs($path);
if (!$a){
// 目录创建失败
}
$pdf->Output(dirname(__DIR__, 2) . "/file/prescription/" . "prescription_img.pdf","F");
}
// pdf进行签章
public function test_6(){
$pdf_file = fopen("./runtime/prescription.pdf",'r');
$oss = new Oss();
$filename = "applet/doctor/cert/f2abdb81-fac0-4264-bc11-aa2b6cf2761c.png";
$style = "image/resize,m_lfit,w_100,h_350";
$sign_image = $oss->getCusTomObjectToRAM($filename,$style);
$sign_image = base64_encode($sign_image);
if (!$sign_image){
return fail(HttpEnumCode::SERVER_ERROR);
}
$sign_param = [
[ // 医生端
"llx"=>"120", // 左边底部X坐标
"lly"=>"190", // 左边底部Y坐标
"urx"=>"190", // 右边上部x坐标
"ury"=>"140", // 右边上部y坐标
"pageList"=>[1],
"sealImg"=>$sign_image
],
// [ // 药师端
// "llx"=>"350", // 左边底部X坐标
// "lly"=>"190", // 左边底部Y坐标
// "urx"=>"440", // 右边上部x坐标
// "ury"=>"140", // 右边上部y坐标
// "pageList"=>[1],
// "sealImg"=>$sign_image
// ]
];
$data = array();
$data['sign_param'] = json_encode($sign_param);
$data['pdf_file'] = $pdf_file;
$ca = new Ca();
$result = $ca->addSignPdf("491925054435950592",$data);
$file_id = $result[0]['fileId'];
$result = $ca->getSignedFile("491925054435950592",$file_id);
if (empty($result)){
return fail();
}
// $file = fopen("./runtime/test.pdf", "w") or die("Unable to open file!");
// fwrite($file, $result);
// fclose($file);
// 上传阿里云oss
$oss = new Oss();
$filename = "applet/doctor/prescription/test.pdf";
$result = $oss->putObject($filename, $result);
dump($result);
}
// 延迟队列测试
public function test_7(){
$out_trade_no = $this->request->input('out_trade_no');
if ($out_trade_no == 1){
// 增加至取消订单延迟队列
$data = array();
$data['order_no'] = 111;
$data['order_type'] = 1;
$message = new CancelUnpayOrdersDelayDirectProducer($data);
$message->setDelayMs(1000 * 5 * 1);
$producer = $this->container->get(Producer::class);
$res = $producer->produce($message);
if (!$res) {
Db::rollBack();
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
}
}else{
// 增加至取消订单延迟队列
$data = array();
$data['order_no'] = 2222;
$data['order_type'] = 1;
$message = new CancelUnpayOrdersDelayDirectProducer($data);
$message->setDelayMs(1000 * 15 * 1);
$producer = $this->container->get(Producer::class);
$res = $producer->produce($message);
if (!$res) {
Db::rollBack();
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
}
}
}
// 删除签章配置
public function test_8(){
$ca = new Ca();
$result = $ca->deleteUserSignConfig("491925054435950592");
}
// 下载签章的pdf文件
public function test_9(){
$ca = new Ca();
$result = $ca->getSignedFile("5345345461","1642769369872105473");
if (empty($result)){
return fail();
}
// 上传阿里云oss
$oss = new Oss();
$filename = "applet/doctor/prescription/111.pdf";
$result = $oss->putObject($filename, $result);
dump($result);
}
// 处方上报处方平台 // 处方上报处方平台
public function test_11(){ public function test_11(){
@ -801,6 +323,7 @@ class TestController extends AbstractController
} }
public function test_15(){ public function test_15(){
$wg = new \Hyperf\Utils\WaitGroup(); $wg = new \Hyperf\Utils\WaitGroup();
$channel = new Channel(); $channel = new Channel();
$wg->add(2); $wg->add(2);

View File

@ -127,7 +127,7 @@ class LoginService extends BaseService
// 创建im账号 // 创建im账号
$account = new Account(); $account = new Account();
// 创建单个账号 // 创建单个账号
$account->createAccount($user->user_id,$user->user_name,$avatar); $account->createAccount($user->user_id,$user->user_name,addAliyunOssWebsite($avatar));
} else { } else {
// 已注册用户 // 已注册用户
// 重复注册不同端 // 重复注册不同端
@ -346,7 +346,7 @@ class LoginService extends BaseService
// 创建im账号 // 创建im账号
$account = new Account(); $account = new Account();
// 创建单个账号 // 创建单个账号
$account->createAccount($user->user_id,$user->user_name,$avatar); $account->createAccount($user->user_id,$user->user_name,addAliyunOssWebsite($avatar));
} else { } else {
// 已注册用户 // 已注册用户
if ($user_type != $user['user_type']) { if ($user_type != $user['user_type']) {

View File

@ -94,6 +94,10 @@ class UserService extends BaseService
return fail(); return fail();
} }
if ($avatar == $user['avatar']){
return success();
}
// 匹配去除oss网址 // 匹配去除oss网址
$avatar = PcreMatch::pregRemoveOssWebsite($avatar); $avatar = PcreMatch::pregRemoveOssWebsite($avatar);