Commit 1b1da179 by 杨树贤

IQC上传校验

parent befd767b
......@@ -8,6 +8,7 @@ use App\Http\Controllers\Filter\SupplierAccountFilter;
use App\Http\Controllers\Filter\SupplierExaminationFilter;
use App\Http\Transformers\SupplierAccountTransformer;
use App\Http\Transformers\SupplierExaminationTransformer;
use App\Model\IntracodeModel;
use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierChannelModel;
......@@ -65,9 +66,14 @@ class SupplierExaminationService
if (SupplierExaminationModel::where('data_md5', $dataMd5)->exists()) {
throw new \Exception('该文件已经上传过,请选择其它文件');
}
//获取所有采购员用于校验
$channelUsers = (new IntracodeModel())->getAllEncode();
$channelUserNames = array_column($channelUsers, 'name');
$supplierNames = (new SupplierChannelModel())->where('is_type', 0)->pluck('supplier_name')->toArray();
//拼装数据插入校验,校验完成插入数据库
$examineData = [];
foreach ($data as $index => $item) {
$lineNo = $index + 1;
//检测模板头部
if ($index == 0) {
if (!$this->checkImportCsvHeader($item)) {
......@@ -79,24 +85,43 @@ class SupplierExaminationService
return trim($value);
}, $item);
$examineTime = $item[0];
$purchaseName = $item[1];
$channelUserName = $item[1];
$supplierName = $item[2];
$skuName = $item[3];
$brandName = $item[4];
$amount = $item[5];
$examineAmount = $item[6];
$unhealthyAmount = $item[7];
$abnormalLevel = $item[8];
$abnormalLevel = (int)$item[8];
$unhealthyContent = $item[9];
$examineResult = $item[10];
$handleWay = $item[11];
$remark = $item[12];
if (empty($supplierName)) {
throw new \Exception('上传文件里面存在供应商名称为空的数据,请修改后再次提交');
throw new \Exception("存在供应商名称为空的数据(第${lineNo}行),请修改后再次提交");
}
if (!in_array($supplierName,$supplierNames)) {
throw new \Exception("存在无效供应商的数据(第${lineNo}行),请修改后再次提交");
}
if (!in_array($channelUserName,$channelUserNames)) {
throw new \Exception("存在无效的采购员(第${lineNo}行),请修改后再次提交");
}
if (!is_integer($amount)) {
throw new \Exception("数量只能为纯数字(第${lineNo}行),请修改后再次提交");
}
if (!is_integer($examineAmount)) {
throw new \Exception("检测数量只能为纯数字(第${lineNo}行),请修改后再次提交");
}
if (!is_integer($unhealthyAmount)) {
throw new \Exception("不良数量只能为纯数字(第${lineNo}行),请修改后再次提交");
}
if (!in_array($abnormalLevel,[1,2,3])) {
throw new \Exception("存在不合理的异常等级,等级必须为纯数字1,2,3 (第${lineNo}行),请修改后再次提交");
}
$examineData[] = [
'examine_time' => $examineTime ? strtotime($examineTime) : '',
'purchase_name' => $purchaseName,
'purchase_name' => $channelUserName,
'supplier_name' => $supplierName,
'sku_name' => $skuName,
'brand_name' => $brandName,
......
检货时间,采购员,供应商,型号,品牌,数量,检验数量,不良数,异常等级,不良现象,检验结果,处理方式,备注
检货时间,采购员,供应商,型号,品牌,数量,检验数量,不良数,异常等级,不良现象,检验结果,处理方式,备注
......@@ -10,7 +10,7 @@
2020/10/19,邓小姣,深圳市沃德顺科电子科技有限公司,ADP151AUJZ-3.3,ADI,600,600,无盘无标签有盘标签照片,,丝印格式不正常,标签不正常,山寨货,退货,
2020/10/21,张佑辉,深圳市芯毅科技有限公司,MP3202DJ-LF-Z,MPS,"3,000",3000,3000,,标签不正常,本体丝印错误,山寨货,退货,
2020/11/3,马玉强,深圳市粤鑫朋电子有限公司,RT8272GSP,RICHTEK,60,6,6,,反面金属面及引脚有明显氧化现象,氧化货,退货,
2020/12/8,王秋,深圳市菱睿供应链管理有限公司,FQP13N50C,ON,2400,1000X8,2400,,包装盒标签不正确,本体丝印不正常。,山寨货,退货,
2020/12/8,王秋,深圳市菱睿供应链管理有限公司,FQP13N50C,ON,2400,1000X8,2400,,包装盒标签不正确,本体丝印不正常。,山寨货,退货1,
2020/12/29,陈欢,深圳市联翔兴业电子有限公司,24LC512T-I/SN, MicroChip,3300,4,4,,包装盘袋标签均不正常,本体外形非MicroChip封装外形,山寨货,退货,
2020/12/30,汤浩升,深圳明嘉瑞科技有限公司,TL431AILPR,TI,2000,4,4,,本体信息与包装标签信息不一致且标签涂抹,山寨货,退货,
2021/1/4,廖长青,深圳市路泽半导体有限公司(顺乐),SG6742MRSY,ON,2500+1500,8,8,,本体信息与包装标签信息不一致,换盘换标签货,换货,
......
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