Commit 41680f18 by 杨树贤

空格校验

parent 890df309
......@@ -31,6 +31,6 @@ class SetSupplierFollowUp extends Command
public function handle()
{
$service = new DataService();
$service->importSupplierLevel();
$service->trimSupplierName();
}
}
......@@ -301,7 +301,7 @@ class DataService
$reader->sheet('2021年评估', function ($sheet) use ($reader, $supplierChannelModel) {
$number = 0;
foreach ($reader->all()->toArray() as $key => $item) {
if ($key==0) {
if ($key == 0) {
continue;
}
//判断如果有日志了就跳过
......@@ -310,7 +310,7 @@ class DataService
$level = trim($item[2]);
//先去判断是否存在
$supplierLevelMap = $supplierChannelModel->where('supplier_name', $supplierName)
->select(['level','supplier_id'])->first();
->select(['level', 'supplier_id'])->first();
if (empty($supplierLevelMap)) {
$number++;
echo '供应商不存在 : ' . $supplierName . PHP_EOL;
......@@ -385,6 +385,19 @@ class DataService
}
}
public function trimSupplierName()
{
$suppliers = SupplierChannelModel::where('is_type', 0)->select([
'supplier_id',
'supplier_name'
])->get()->toArray();
foreach ($suppliers as $supplier) {
if (mb_strlen($supplier['supplier_name']) != mb_strlen(trim($supplier['supplier_name']))) {
echo '有空格的供应商 : ' . $supplier['supplier_name'] . mb_strlen($supplier['supplier_name']) . "_" . mb_strlen(trim($supplier['supplier_name'])) . PHP_EOL;
}
}
}
//从excel导入供应商
public function importSupplier()
{
......@@ -393,7 +406,7 @@ class DataService
Excel::selectSheetsByIndex(0)->load($filePath, function ($reader) {
$supplierChannelModel = new SupplierChannelModel();
$supplierService = new SupplierService();
$reader->sheet('供应商清单', function ($sheet) use ($reader, $supplierChannelModel,$supplierService) {
$reader->sheet('供应商清单', function ($sheet) use ($reader, $supplierChannelModel, $supplierService) {
$number = 0;
foreach ($reader->all()->toArray() as $key => $item) {
$supplierName = trim($item[1]);
......
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