Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
41680f18
authored
Mar 16, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
空格校验
parent
890df309
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
app/Console/Commands/SetSupplierFollowUp.php
app/Http/Services/DataService.php
app/Console/Commands/SetSupplierFollowUp.php
View file @
41680f18
...
@@ -31,6 +31,6 @@ class SetSupplierFollowUp extends Command
...
@@ -31,6 +31,6 @@ class SetSupplierFollowUp extends Command
public
function
handle
()
public
function
handle
()
{
{
$service
=
new
DataService
();
$service
=
new
DataService
();
$service
->
importSupplierLevel
();
$service
->
trimSupplierName
();
}
}
}
}
app/Http/Services/DataService.php
View file @
41680f18
...
@@ -301,7 +301,7 @@ class DataService
...
@@ -301,7 +301,7 @@ class DataService
$reader
->
sheet
(
'2021年评估'
,
function
(
$sheet
)
use
(
$reader
,
$supplierChannelModel
)
{
$reader
->
sheet
(
'2021年评估'
,
function
(
$sheet
)
use
(
$reader
,
$supplierChannelModel
)
{
$number
=
0
;
$number
=
0
;
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
if
(
$key
==
0
)
{
if
(
$key
==
0
)
{
continue
;
continue
;
}
}
//判断如果有日志了就跳过
//判断如果有日志了就跳过
...
@@ -310,7 +310,7 @@ class DataService
...
@@ -310,7 +310,7 @@ class DataService
$level
=
trim
(
$item
[
2
]);
$level
=
trim
(
$item
[
2
]);
//先去判断是否存在
//先去判断是否存在
$supplierLevelMap
=
$supplierChannelModel
->
where
(
'supplier_name'
,
$supplierName
)
$supplierLevelMap
=
$supplierChannelModel
->
where
(
'supplier_name'
,
$supplierName
)
->
select
([
'level'
,
'supplier_id'
])
->
first
();
->
select
([
'level'
,
'supplier_id'
])
->
first
();
if
(
empty
(
$supplierLevelMap
))
{
if
(
empty
(
$supplierLevelMap
))
{
$number
++
;
$number
++
;
echo
'供应商不存在 : '
.
$supplierName
.
PHP_EOL
;
echo
'供应商不存在 : '
.
$supplierName
.
PHP_EOL
;
...
@@ -385,6 +385,19 @@ class DataService
...
@@ -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导入供应商
//从excel导入供应商
public
function
importSupplier
()
public
function
importSupplier
()
{
{
...
@@ -393,7 +406,7 @@ class DataService
...
@@ -393,7 +406,7 @@ class DataService
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
{
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
{
$supplierChannelModel
=
new
SupplierChannelModel
();
$supplierChannelModel
=
new
SupplierChannelModel
();
$supplierService
=
new
SupplierService
();
$supplierService
=
new
SupplierService
();
$reader
->
sheet
(
'供应商清单'
,
function
(
$sheet
)
use
(
$reader
,
$supplierChannelModel
,
$supplierService
)
{
$reader
->
sheet
(
'供应商清单'
,
function
(
$sheet
)
use
(
$reader
,
$supplierChannelModel
,
$supplierService
)
{
$number
=
0
;
$number
=
0
;
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
$supplierName
=
trim
(
$item
[
1
]);
$supplierName
=
trim
(
$item
[
1
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment