Commit 876aa1ce by 杨树贤

优化导入脚本

parent 5a04ffca
Showing with 4 additions and 2 deletions
...@@ -247,12 +247,11 @@ class DataService ...@@ -247,12 +247,11 @@ class DataService
$channelModel = new SupplierChannelModel(); $channelModel = new SupplierChannelModel();
//读取excel //读取excel
$filePath = public_path('data') . DIRECTORY_SEPARATOR . 'abnormal_supplier.xlsx'; $filePath = public_path('data') . DIRECTORY_SEPARATOR . 'abnormal_supplier.xlsx';
$suppliers = [];
try { try {
Excel::selectSheetsByIndex(0)->load($filePath, function ($reader) { Excel::selectSheetsByIndex(0)->load($filePath, function ($reader) {
$reader->sheet('QC不良记录', function () use ($reader) { $reader->sheet('QC不良记录', function () use ($reader) {
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
dd($reader->all()->toArray()); $suppliers = [];
foreach ($reader->all()->toArray() as $key => $item) { foreach ($reader->all()->toArray() as $key => $item) {
if ($key == 0 || $key == 1) { if ($key == 0 || $key == 1) {
continue; continue;
...@@ -271,6 +270,9 @@ class DataService ...@@ -271,6 +270,9 @@ class DataService
foreach ($suppliers as $supplier) { foreach ($suppliers as $supplier) {
$supplierId = $supplier['supplier_id']; $supplierId = $supplier['supplier_id'];
$oldTags = $supplier['system_tags']; $oldTags = $supplier['system_tags'];
if (strpos($supplier['system_tags'], '历史检测异常') !== false) {
continue;
}
$newTags = $supplier['system_tags'] ? rtrim($supplier['system_tags'], $newTags = $supplier['system_tags'] ? rtrim($supplier['system_tags'],
',') . ',历史检测异常' : '历史检测异常'; ',') . ',历史检测异常' : '历史检测异常';
if ($tagService->saveTags($supplierId, 14, $newTags, $oldTags)) { if ($tagService->saveTags($supplierId, 14, $newTags, $oldTags)) {
......
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