Commit 876aa1ce by 杨树贤

优化导入脚本

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