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
19cbfa7b
authored
Dec 23, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调试
parent
105a7230
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
app/Admin/Extensions/ToolBar/Forms/ExternalPrescriptionImportForm.php
+17
-2
No files found.
app/Admin/Extensions/ToolBar/Forms/ExternalPrescriptionImportForm.php
View file @
19cbfa7b
...
...
@@ -28,14 +28,29 @@ public function handle(array $input): JsonResponse
// 表单参数
$file
=
$input
[
'import_file'
];
$filePath
=
storage_path
(
'app/'
.
$file
);
Log
::
info
(
"====>"
.
$filePath
);
//
Log::info("====>".$filePath);
try
{
// 每100行数据为一批数据进行读取
$chunkSize
=
10
;
$successNum
=
0
;
$failNum
=
0
;
$data
=
Excel
::
import
(
$filePath
)
->
sheet
(
'处方明细列表'
)
->
toArray
();
Log
::
info
(
"====>"
.
json_encode
(
$data
));
if
(
!
empty
(
$data
)
&&
is_array
(
$data
)){
// 判断处方单编号是会否重复,如果重复需进行合并药品数据
$prescriptions
=
[];
foreach
(
$data
as
$row
){
$prescriptionNo
=
$row
[
'处方编号'
];
$drug_info
[
'drug_name'
]
=
$row
[
'药品名称'
];
$drug_info
[
'drug_spec'
]
=
$row
[
'药品规格'
];
$drug_info
[
'drug_num'
]
=
$row
[
'药品数量'
];
if
(
!
isset
(
$prescriptions
[
$prescriptionNo
])){
$prescriptions
[
$prescriptionNo
]
=
$row
;
}
$prescriptions
[
$prescriptionNo
][
'药品明细'
][]
=
$drug_info
;
}
Log
::
info
(
"prescriptions====>"
.
json_encode
(
$prescriptions
));
}
$return
=
$this
->
response
()
->
success
(
"导入成功
{
$successNum
}
条"
)
->
refresh
();
unlink
(
$filePath
);
}
catch
(
Exception
$e
)
{
...
...
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