Commit cfd95a8b by 杨树贤

修改完成

parent a5836255
......@@ -122,7 +122,7 @@ class SupplierExaminationApiController extends Controller
$this->response(-1, '删除失败', $result);
}
//上传相似商品
//上传IQC检测记录
private function ImportSupplierExamination($request)
{
$file = $request->file('file');
......
......@@ -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
......@@ -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();
......
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