Commit 569ac709 by lujunyi

药品导入

parent 263aa722
......@@ -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;
}
......
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