Commit f91ddabc by 杨树贤

异常供应商标签

parent 142832ba
...@@ -35,6 +35,7 @@ class SetSupplierFollowUp extends Command ...@@ -35,6 +35,7 @@ class SetSupplierFollowUp extends Command
// $service->importSupplierLevel(); // $service->importSupplierLevel();
// $service->changeSupplierTypeByIsType(); // $service->changeSupplierTypeByIsType();
// $service->transferPayType(); // $service->transferPayType();
$service->makeTempTagForSupplier(); // $service->makeTempTagForSupplier();
$service->makeSupplierSystemTagAbnormal();
} }
} }
...@@ -243,15 +243,15 @@ class DataService ...@@ -243,15 +243,15 @@ class DataService
} }
//打上历史检测异常标签 //打上历史检测异常标签
public function makeSupplierSystemTagAbnormal() public function makeSupplierSystemTagAbnormal($change = false)
{ {
ini_set('memory_limit', '-1'); ini_set('memory_limit', '-1');
$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';
try { try {
Excel::selectSheetsByIndex(0)->load($filePath, function ($reader) { Excel::selectSheetsByIndex(0)->load($filePath, function ($reader) use ($change) {
$reader->sheet('QC不良记录', function () use ($reader) { $reader->sheet('QC不良记录', function () use ($reader, $change) {
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
$suppliers = []; $suppliers = [];
foreach ($reader->all()->toArray() as $key => $item) { foreach ($reader->all()->toArray() as $key => $item) {
...@@ -265,6 +265,8 @@ class DataService ...@@ -265,6 +265,8 @@ class DataService
$supplier = $supplierModel->where('supplier_name', $supplierName)->first(); $supplier = $supplierModel->where('supplier_name', $supplierName)->first();
if (!empty($supplier)) { if (!empty($supplier)) {
$suppliers[] = $supplier->toArray(); $suppliers[] = $supplier->toArray();
} else {
echo "供应商 : " . $supplierName . "不存在,跳过" . PHP_EOL;
} }
} }
$tagService = new SupplierTagService(); $tagService = new SupplierTagService();
...@@ -272,15 +274,18 @@ class DataService ...@@ -272,15 +274,18 @@ 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'];
echo "供应商 : " . $supplier['supplier_name'] . "检测异常,需要打上标签" . PHP_EOL;
if (strpos($supplier['system_tags'], '历史检测异常') !== false) { if (strpos($supplier['system_tags'], '历史检测异常') !== false) {
continue; 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 ($change) {
$supplierModel->where('supplier_id', $supplierId)->update([ if ($tagService->saveTags($supplierId, 14, $newTags, $oldTags)) {
'system_tags' => $newTags $supplierModel->where('supplier_id', $supplierId)->update([
]); 'system_tags' => $newTags
]);
}
} }
} }
}); });
...@@ -451,13 +456,6 @@ class DataService ...@@ -451,13 +456,6 @@ class DataService
$supplierId)->value('quality_assurance_agreement'); $supplierId)->value('quality_assurance_agreement');
//供应商性质为现货商,且没有上传品质协议,系统标签需要贴【临时供应商标签】,等级标记为E //供应商性质为现货商,且没有上传品质协议,系统标签需要贴【临时供应商标签】,等级标记为E
if (!$hasQualityAssuranceAgreement && $supplier['supplier_group'] == 2) { if (!$hasQualityAssuranceAgreement && $supplier['supplier_group'] == 2) {
$tagService = new SupplierTagService();
$oldTags = $supplier['system_tags'];
// if (strpos($supplier['system_tags'], '临时供应商') !== false) {
// continue;
// }
$newTags = $supplier['system_tags'] ? rtrim($supplier['system_tags'], ',') . ',临时供应商' : '临时供应商';
if ($supplier['level'] != '' && $supplier['level'] != 'E') { if ($supplier['level'] != '' && $supplier['level'] != 'E') {
echo "供应商编码 ${supplier['supplier_code']} 已经有等级${supplier['level']},但是不为等级E,跳过" . PHP_EOL; echo "供应商编码 ${supplier['supplier_code']} 已经有等级${supplier['level']},但是不为等级E,跳过" . PHP_EOL;
continue; continue;
...@@ -468,19 +466,7 @@ class DataService ...@@ -468,19 +466,7 @@ class DataService
'supplier_type' => 2 'supplier_type' => 2
]); ]);
} }
// echo "供应商编码 ${supplier['supplier_code']} 打上临时供应商标签,等级标记为E" . PHP_EOL;
// if ($change) {
// if ($tagService->saveTags($supplierId, 14, $newTags, $oldTags)) {
// SupplierChannelModel::where('supplier_id', $supplierId)->update([
// 'system_tags' => $newTags,
// 'level' => 'E'
// ]);
// }
// }
} }
} }
} }
......
No preview for this file type
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