Commit f86da17b by lujunyi

import

parent 4e715668
...@@ -72,6 +72,47 @@ public function handle(array $input): JsonResponse ...@@ -72,6 +72,47 @@ public function handle(array $input): JsonResponse
return $return; 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);
});
}*/
/** /**
* 构造表单. * 构造表单.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment