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
569ac709
authored
Nov 21, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
药品导入
parent
263aa722
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
app/Admin/Extensions/ToolBar/Forms/DrugImportForm.php
+5
-2
No files found.
app/Admin/Extensions/ToolBar/Forms/DrugImportForm.php
View file @
569ac709
...
...
@@ -28,14 +28,17 @@ public function handle(array $input): JsonResponse
$chunkSize
=
10
;
$successNum
=
0
;
$failNum
=
0
;
Excel
::
import
(
$filePath
)
->
first
()
->
chunk
(
$chunkSize
,
function
(
SheetCollection
$collection
)
use
(
$successNum
)
{
Excel
::
import
(
$filePath
)
->
first
()
->
chunk
(
$chunkSize
,
function
(
SheetCollection
$collection
)
use
(
&
$successNum
)
{
// 此处的数组下标依然是excel表中数据行的行号
$rows
=
$collection
->
toArray
();
foreach
(
$rows
as
$row
)
{
$item
=
array_map
(
function
(
$value
)
{
return
is_string
(
$value
)
?
trim
(
$value
)
:
$value
;
},
$row
);
$drugModel
=
DrugModel
::
where
(
'product_id'
,
$item
[
'君元ID'
])
->
first
();
$drugModel
=
null
;
if
(
isset
(
$item
[
'君元ID'
])
&&
$item
[
'君元ID'
])
{
$drugModel
=
DrugModel
::
where
(
'product_id'
,
$item
[
'君元ID'
])
->
first
();
}
if
(
!
$drugModel
)
{
$drugModel
=
new
DrugModel
;
}
...
...
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