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
cfd95a8b
authored
Aug 16, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改完成
parent
a5836255
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
app/Http/Controllers/Api/SupplierExaminationApiController.php
app/Http/Services/SupplierExaminationService.php
app/Http/Validators/SupplierExaminationValidator.php
public/data/import_supplier_examination_template.xlsx
app/Http/Controllers/Api/SupplierExaminationApiController.php
View file @
cfd95a8b
...
...
@@ -122,7 +122,7 @@ class SupplierExaminationApiController extends Controller
$this
->
response
(
-
1
,
'删除失败'
,
$result
);
}
//上传
相似商品
//上传
IQC检测记录
private
function
ImportSupplierExamination
(
$request
)
{
$file
=
$request
->
file
(
'file'
);
...
...
app/Http/Services/SupplierExaminationService.php
View file @
cfd95a8b
...
...
@@ -71,6 +71,9 @@ class SupplierExaminationService
//拼装数据插入校验,校验完成插入数据库
$examineData
=
[];
foreach
(
$data
as
$index
=>
$item
)
{
if
(
$this
->
checkArrAllNull
(
$item
))
{
continue
;
}
if
(
$index
==
0
)
{
continue
;
}
...
...
@@ -87,7 +90,7 @@ class SupplierExaminationService
$supplierName
=
$item
[
6
];
$skuName
=
$item
[
7
];
$brandName
=
$item
[
8
];
$amount
=
$item
[
9
]
;
$amount
=
str_replace
(
','
,
''
,
$item
[
9
])
;
$batch
=
$item
[
10
];
$producingArea
=
$item
[
11
];
$stockInDate
=
$item
[
12
];
...
...
@@ -95,7 +98,7 @@ class SupplierExaminationService
$deliverySn
=
$item
[
14
];
$tallyRequest
=
$item
[
15
];
$examineRequest
=
$item
[
16
];
$unhealthyAmount
=
$item
[
17
]
;
$unhealthyAmount
=
str_replace
(
','
,
''
,
$item
[
17
])
;
$abnormalLevel
=
$item
[
18
];
$unhealthyContent
=
$item
[
19
];
$examineResult
=
$item
[
20
];
...
...
@@ -131,9 +134,7 @@ class SupplierExaminationService
if
(
!
is_numeric
(
$amount
)
||
empty
(
$amount
))
{
throw
new
\Exception
(
"数量只能为纯数字且不能为空! (第${lineNo}行),请修改后再次提交"
);
}
if
(
!
is_numeric
(
$unhealthyAmount
)
||
empty
(
$unhealthyAmount
))
{
throw
new
\Exception
(
"不良数量只能为纯数字且不能为空 (第${lineNo}行),请修改后再次提交"
);
}
if
(
empty
(
$examineResult
)
||
!
in_array
(
$examineResult
,
array_values
(
config
(
'field.SupplierExamineResult'
))))
{
throw
new
\Exception
(
"检验结果只能(退货|特批入库|正常入库)其中一个且不能为空 (第${lineNo}行),请修改后再次提交"
);
...
...
@@ -186,6 +187,17 @@ class SupplierExaminationService
}
}
public
function
checkArrAllNull
(
$arr
)
{
foreach
(
$arr
as
$item
)
{
if
(
$item
)
{
return
false
;
}
}
return
true
;
}
private
function
checkImportCsvHeader
(
$header
)
{
$header
=
array_map
(
function
(
$value
)
{
...
...
@@ -215,7 +227,12 @@ class SupplierExaminationService
'检验结果'
,
'备注'
];
foreach
(
$header
as
$key
=>
$item
)
{
if
(
strpos
(
$item
,
$validHeader
[
$key
])
===
false
)
{
return
false
;
}
}
return
$validHeader
==
$header
;
return
true
;
}
}
\ No newline at end of file
app/Http/Validators/SupplierExaminationValidator.php
View file @
cfd95a8b
...
...
@@ -22,7 +22,7 @@ class SupplierExaminationValidator
"sku_name"
=>
"required"
,
"brand_name"
=>
"required"
,
"amount"
=>
"required|integer|min:1"
,
"unhealthy_amount"
=>
"required|integer"
,
//
"unhealthy_amount" => "required|integer",
"examine_result"
=>
"required"
,
];
$messages
=
$this
->
messages
();
...
...
public/data/import_supplier_examination_template.xlsx
View file @
cfd95a8b
No preview for this file type
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