Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bc527fab
authored
Nov 18, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.imohe.com/zhaozengyu/tzt-admin
parents
7f9439e5
1c3fa528
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
18 deletions
+73
-18
app/Admin/Controllers/PrescriptionPrintController.php
+45
-18
database/migrations/2024_11_18_155308_add_prescription_pic_eseal_to_prescription_table.php
+28
-0
public/static/images/dianzizhang.png
+0
-0
No files found.
app/Admin/Controllers/PrescriptionPrintController.php
View file @
bc527fab
...
@@ -28,6 +28,7 @@ public function index(Content $content): Content
...
@@ -28,6 +28,7 @@ public function index(Content $content): Content
public
function
search
()
public
function
search
()
{
{
$prescriptionNo
=
request
(
'prescription_no'
);
$prescriptionNo
=
request
(
'prescription_no'
);
$printEseal
=
request
(
'print_eseal'
,
0
);
// 是否打印电子印章,实时生成
if
(
empty
(
$prescriptionNo
))
{
if
(
empty
(
$prescriptionNo
))
{
return
response
()
->
json
([
return
response
()
->
json
([
...
@@ -36,14 +37,21 @@ public function search()
...
@@ -36,14 +37,21 @@ public function search()
]);
]);
}
}
//
try {
try
{
// 获取处方信息
// 获取处方信息
$prescription
=
PrescriptionModel
::
where
(
'id'
,
$prescriptionNo
)
->
first
();
$prescription
=
PrescriptionModel
::
where
(
'id'
,
$prescriptionNo
)
->
first
();
if
(
!
$prescription
)
{
if
(
!
$prescription
)
{
return
response
()
->
json
([
'status'
=>
false
,
'message'
=>
'未找到该处方'
]);
return
response
()
->
json
([
'status'
=>
false
,
'message'
=>
'未找到该处方'
]);
}
}
// 检查处方图片是否已经生成
// 检查处方图片是否已经生成
if
(
$prescription
->
prescription_pic
)
{
if
(
$printEseal
&&
$prescription
->
prescription_pic_eseal
)
{
return
response
()
->
json
([
'status'
=>
true
,
'data'
=>
[
'img_url'
=>
Storage
::
url
(
$prescription
->
prescription_pic_eseal
),
],
]);
}
elseif
(
$prescription
->
prescription_pic
)
{
return
response
()
->
json
([
return
response
()
->
json
([
'status'
=>
true
,
'status'
=>
true
,
'data'
=>
[
'data'
=>
[
...
@@ -174,34 +182,53 @@ public function search()
...
@@ -174,34 +182,53 @@ public function search()
$pharmacistSign
->
resize
(
150
,
100
);
$pharmacistSign
->
resize
(
150
,
100
);
$img
->
place
(
$pharmacistSign
,
'bottom-left'
,
870
,
410
);
$img
->
place
(
$pharmacistSign
,
'bottom-left'
,
870
,
410
);
}
}
// 不带印章处方图片生成
// 将图片保存到临时文件
$picName
=
$prescriptionNo
.
'.jpg'
;
$tempPath
=
storage_path
(
'app/public'
)
.
$prescriptionNo
.
'.jpg'
;
$tempPath
=
storage_path
(
'app/public'
)
.
$picName
;
$img
->
save
(
$tempPath
);
$img
->
save
(
$tempPath
);
// 不带电子印章
// 上传到腾讯云
// 上传到腾讯云
Storage
::
putFileAs
(
'prescriptions'
,
$tempPath
,
$prescriptionNo
.
'.jpg'
);
Storage
::
putFileAs
(
'prescriptions'
,
$tempPath
,
$picName
);
// 电子印章版处方图片生成
$eseal
=
Image
::
read
(
public_path
(
'static/images/dianzizhang.png'
));
// $eseal->rotate(90);
$eseal
->
resize
(
150
,
150
);
$img
->
place
(
$eseal
,
'bottom-right'
,
180
,
500
);
$picEsealName
=
$prescriptionNo
.
'-eseal.jpg'
;
$tempEsealPath
=
storage_path
(
'app/public'
)
.
$picEsealName
;
$img
->
save
(
$tempEsealPath
);
// 上传到腾讯云
Storage
::
putFileAs
(
'prescriptions'
,
$tempEsealPath
,
$picEsealName
);
// 删除临时文件
// 删除临时文件
unlink
(
$tempPath
);
unlink
(
$tempPath
);
unlink
(
$tempEsealPath
);
$cosPath
=
'prescriptions/'
.
$prescriptionNo
.
'.jpg'
;
$cosPath
=
"prescriptions/
{
$picName
}
"
;
$cosEsealPath
=
"prescriptions/
{
$picEsealName
}
"
;
// 将生成的
图片路径存储到数据库
// 将生成的处方
图片路径存储到数据库
$prescription
->
prescription_pic
=
$cosPath
;
$prescription
->
prescription_pic
=
$cosPath
;
$prescription
->
save
();
$prescription
->
prescription_pic_eseal
=
$cosEsealPath
;
$prescription
->
save
();
// 保存处方图片路径
if
(
$printEseal
=
true
)
{
$imgUrl
=
Storage
::
url
(
$cosEsealPath
);
}
else
{
$imgUrl
=
Storage
::
url
(
$cosPath
);
}
return
response
()
->
json
([
return
response
()
->
json
([
'status'
=>
true
,
'status'
=>
true
,
'data'
=>
[
'data'
=>
[
'img_url'
=>
Storage
::
url
(
$cosPath
)
,
'img_url'
=>
$imgUrl
,
],
],
]);
]);
//
} catch (\Exception $e) {
}
catch
(
\Exception
$e
)
{
//
return response()->json([
return
response
()
->
json
([
//
'status' => false,
'status'
=>
false
,
//
'message' => '处方生成失败:'.$e->getMessage(),
'message'
=>
'处方生成失败:'
.
$e
->
getMessage
(),
//
]);
]);
//
}
}
}
}
}
}
database/migrations/2024_11_18_155308_add_prescription_pic_eseal_to_prescription_table.php
0 → 100644
View file @
bc527fab
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*/
public
function
up
()
:
void
{
Schema
::
table
(
'prescription'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'prescription_pic_eseal'
)
->
nullable
()
->
comment
(
'处方单带电子印章图片地址'
);
});
}
/**
* Reverse the migrations.
*/
public
function
down
()
:
void
{
Schema
::
table
(
'prescription'
,
function
(
Blueprint
$table
)
{
//
});
}
};
public/static/images/dianzizhang.png
0 → 100644
View file @
bc527fab
47.2 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment