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
67d16cd7
authored
Nov 22, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.imohe.com/zhaozengyu/tzt-admin
parents
a2e07396
f86da17b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
0 deletions
+61
-0
app/Admin/Extensions/ToolBar/Forms/DrugImportForm.php
+41
-0
app/Models/DrugModel.php
+20
-0
No files found.
app/Admin/Extensions/ToolBar/Forms/DrugImportForm.php
View file @
67d16cd7
...
...
@@ -72,6 +72,47 @@ public function handle(array $input): JsonResponse
return
$return
;
}
/*public function handle(array $input)
{
// 表单参数
$file = $input['import_file'];
$filePath = storage_path('app/'.$file);
// 每1000行数据为一批数据进行读取
$chunkSize = 1000;
Excel::import($filePath)->first()->chunk($chunkSize, function (SheetCollection $collection) {
// 此处的数组下标依然是excel表中数据行的行号
$rows = $collection->toArray();
$arr = [];
foreach ($rows as $row) {
$item = array_map(function ($value) {
return is_string($value) ? trim($value) : $value;
}, $row);
$pinyin = new Pinyin();
$code = strtoupper($pinyin->abbr($item['通用名'])->join(''));
$arr[] = [
'product_id' => $item['君元ID'] ?? 0,
'name' => $item['通用名'],
'product_name' => $item['商品名'],
'spec' => $item['包装规格'],
'preparation_pec' => $item['制剂规格'],
'dosage_form' => $item['剂型'],
'unit' => $item['计量单位'],
'factory' => $item['生产企业'],
'approval_no' => $item['批准文号'],
'mnemonic' => $item['助记码'],
'standard_code' => $item['本位码'],
'category_code' => $item['分类码'],
'category_name' => $item['分类名称'],
'is_foreign' => self::toBool($item['是否进口药']),
'is_rx' => self::toBool($item['是否处方药']),
'is_si' => self::toBool($item['是否医保药']),
'code' => $code,
];
}
DrugModel::insert($arr);
});
}*/
/**
* 构造表单.
*/
...
...
app/Models/DrugModel.php
View file @
67d16cd7
...
...
@@ -14,6 +14,26 @@ class DrugModel extends Model
protected
$table
=
'drug'
;
protected
$fillable
=
[
'product_id'
,
'name'
,
'product_name'
,
'spec'
,
'preparation_pec'
,
'dosage_form'
,
'unit'
,
'factory'
,
'approval_no'
,
'mnemonic'
,
'standard_code'
,
'category_code'
,
'category_name'
,
'is_foreign'
,
'is_rx'
,
'is_si'
,
'code'
,
];
// 是否处方药[0=否,1=是]
const
RX_TRUE
=
0
;
...
...
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