Commit 6c390430 by 杨树贤

IQC修整

parent 06d84b5b
......@@ -31,18 +31,27 @@ class SupplierExaminationApiController extends Controller
public function AddSupplierExamination($request)
{
$params = $request->only([
'supplier_name',
'order_sn',
'purchase_sn',
'examine_time',
'sales_name',
'purchase_name',
'ticket_type',
'supplier_name',
'sku_name',
'brand_name',
'amount',
'examine_amount',
'batch',
'producing_area',
'stock_in_date',
'income_sn',
'delivery_sn',
'tally_request',
'examine_request',
'unhealthy_amount',
'abnormal_level',
'unhealthy_content',
'examine_result',
'abnormal_level',
'handle_way',
'remark',
]);
$validator = new SupplierExaminationValidator();
......@@ -63,18 +72,27 @@ class SupplierExaminationApiController extends Controller
{
$params = $request->only([
'id',
'supplier_name',
'order_sn',
'purchase_sn',
'examine_time',
'sales_name',
'purchase_name',
'ticket_type',
'supplier_name',
'sku_name',
'brand_name',
'amount',
'examine_amount',
'batch',
'producing_area',
'stock_in_date',
'income_sn',
'delivery_sn',
'tally_request',
'examine_request',
'unhealthy_amount',
'abnormal_level',
'unhealthy_content',
'examine_result',
'abnormal_level',
'handle_way',
'remark',
]);
$validator = new SupplierExaminationValidator();
......
......@@ -112,4 +112,12 @@ class DepartmentService
}
return [];
}
//根据用户名获取部门名称
public function getDepartmentNameByUserName($userName)
{
$departmentId = UserInfoModel::where('name', $userName)->value('department_id');
$departmentName = DepartmentModel::where('department_id', $departmentId)->value('department_name');
return $departmentName;
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ use Maatwebsite\Excel\Facades\Excel;
class SupplierExaminationService
{
public function getSupplierExaminationList($request)
{
$limit = $request->get('limit', 10);
......@@ -70,46 +71,65 @@ class SupplierExaminationService
//检测模板头部
if ($index == 0) {
if (!$this->checkImportCsvHeader($item)) {
throw new \Exception('文件不是标准上传模板');
throw new \Exception('文件不是标准上传模板,请核对后再上传');
}
continue;
}
$item = array_map(function ($value) {
return trim($value);
}, $item);
$examineTime = $item[0];
$channelUserName = $item[1];
$supplierName = $item[2];
$skuName = $item[3];
$brandName = $item[4];
$amount = $item[5];
$examineAmount = $item[6];
$unhealthyAmount = $item[7];
$abnormalLevel = (int)$item[8];
$unhealthyContent = $item[9];
$examineResult = $item[10];
$handleWay = $item[11];
$remark = $item[12];
$orderSn = $item[0];
$purchaseSn = $item[1];
$examineTime = $item[2];
$salesName = $item[3];
$channelUserName = $item[4];
$ticketType = $item[5];
$supplierName = $item[6];
$skuName = $item[7];
$brandName = $item[8];
$amount = $item[9];
$batch = $item[10];
$producingArea = $item[11];
$stockInDate = $item[12];
$incomeSn = $item[13];
$deliverySn = $item[14];
$tallyRequest = $item[15];
$examineRequest = $item[16];
$unhealthyAmount = $item[17];
$abnormalLevel = $item[18];
$unhealthyContent = $item[19];
$examineResult = $item[20];
$remark = $item[21];
if (empty($supplierName)) {
throw new \Exception("存在供应商名称为空的数据(第${lineNo}行),请修改后再次提交");
throw new \Exception("供应商名称不能为空! (第${lineNo}行),请修改后再次提交");
}
if (empty($examineTime)) {
throw new \Exception("检货时间不能为空! (第${lineNo}行),请修改后再次提交");
}
if (!in_array($supplierName,$supplierNames)) {
if (!in_array($supplierName, $supplierNames)) {
throw new \Exception("存在无效供应商(供应商系统不存在)的数据(第${lineNo}行),请修改后再次提交");
}
if (!in_array($channelUserName,$channelUserNames)) {
if (!in_array($channelUserName, $channelUserNames)) {
throw new \Exception("存在无效的采购员(第${lineNo}行),请修改后再次提交");
}
if (!is_numeric($amount)) {
throw new \Exception("数量只能为纯数字(第${lineNo}行),请修改后再次提交");
if (empty($skuName)) {
throw new \Exception("型号不能为空! (第${lineNo}行),请修改后再次提交");
}
if (empty($brandName)) {
throw new \Exception("品牌不能为空! (第${lineNo}行),请修改后再次提交");
}
if (!is_numeric($amount) || empty($amount)) {
throw new \Exception("数量只能为纯数字且不能为空! (第${lineNo}行),请修改后再次提交");
}
if (!is_numeric($examineAmount)) {
throw new \Exception("检测数量只能为纯数字(第${lineNo}行),请修改后再次提交");
if (!is_numeric($unhealthyAmount) || empty($unhealthyAmount)) {
throw new \Exception("不良数量只能为纯数字且不能为空 (第${lineNo}行),请修改后再次提交");
}
if (!is_numeric($unhealthyAmount)) {
throw new \Exception("不良数量只能为纯数字(第${lineNo}行),请修改后再次提交");
if (empty($examineResult) || !in_array($examineResult,
array_values(config('field.SupplierExamineResult')))) {
throw new \Exception("检验结果只能(退货|特批入库|正常入库)其中一个且不能为空 (第${lineNo}行),请修改后再次提交");
}
if (!in_array($abnormalLevel,[1,2,3])) {
if (!in_array($abnormalLevel, [1, 2, 3])) {
throw new \Exception("存在不合理的异常等级,等级必须为纯数字1,2,3 (第${lineNo}行),请修改后再次提交");
}
......@@ -120,14 +140,40 @@ class SupplierExaminationService
'sku_name' => $skuName,
'brand_name' => $brandName,
'amount' => $amount,
'examine_amount' => $examineAmount,
'unhealthy_amount' => $unhealthyAmount,
'abnormal_level' => $abnormalLevel,
'examine_result' => $examineResult,
'remark' => $remark,
'data_md5' => $dataMd5,
];
$examineData[] = [
'order_sn' => $orderSn,
'purchase_sn' => $orderSn,
'examine_time' => $examineTime,
'sales_name' => $salesName,
'purchase_name' => $channelUserName,
'ticket_type' => $ticketType,
'supplier_name' => $supplierName,
'sku_name' => $skuName,
'brand_name' => $brandName,
'amount' => $amount,
'batch' => $batch,
'producing_area' => $producingArea,
'stock_in_date' => $stockInDate,
'income_sn' => $incomeSn,
'delivery_sn' => $deliverySn,
'tally_request' => $tallyRequest,
'examine_request' => $examineRequest,
'unhealthy_amount' => $unhealthyAmount,
'abnormal_level' => $abnormalLevel,
'unhealthy_content' => $unhealthyContent,
'examine_result' => $examineResult,
'handle_way' => $handleWay,
'remark' => $remark,
'create_time' => time(),
'data_md5' => $dataMd5,
'create_uid' => request()->user->userId,
'create_name' => request()->user->name,
];
}
......@@ -151,18 +197,27 @@ class SupplierExaminationService
private function checkImportCsvHeader($header)
{
$validHeader = [
'销售订单号',
'采购订单号',
'检货时间',
'销售',
'采购员',
'A/B单',
'供应商',
'型号',
'品牌',
'数量',
'检验数量',
'批次',
'产地',
'入库日期',
'来货单号',
'送货单',
'理货要求',
'验货要求',
'不良数',
'异常等级',
'不良现象',
'检验结果',
'处理方式',
'备注'
];
......
......@@ -4,6 +4,7 @@
namespace App\Http\Transformers;
use App\Http\Services\DepartmentService;
use App\Model\SupplierChannelModel;
class SupplierExaminationTransformer
......@@ -11,6 +12,8 @@ class SupplierExaminationTransformer
public function transformList($list)
{
foreach ($list as &$item) {
$item['purchase_department'] = (new DepartmentService())->getDepartmentNameByUserName($item['purchase_name']);
$item['sales_department'] = $item['sales_name'] ? (new DepartmentService())->getDepartmentNameByUserName($item['sales_name']) : '';
$item['create_time'] = $item['create_time'] ? date('Y-m-d H:i:s', $item['create_time']) : '';
$item['update_time'] = $item['update_time'] ? date('Y-m-d H:i:s', $item['update_time']) : '';
$item['examine_time'] = $item['examine_time'] ? date('Y-m-d', $item['examine_time']) : '';
......
......@@ -22,12 +22,9 @@ class SupplierExaminationValidator
"sku_name" => "required",
"brand_name" => "required",
"amount" => "required|integer|min:1",
"examine_amount" => "required|integer",
"unhealthy_amount" => "required|integer",
"unhealthy_content" => "required",
"examine_result" => "required",
"abnormal_level" => "required",
"handle_way" => "required",
];
$messages = $this->messages();
$validator = Validator::make($params, $rules, $messages, $this->attributes());
......@@ -52,7 +49,7 @@ class SupplierExaminationValidator
{
return [
'supplier_name' => '供应商名称',
'examine_time' => '检时间',
'examine_time' => '检时间',
'purchase_name' => '采购员',
'sku_name' => '型号',
'brand_name' => '品牌',
......
......@@ -191,5 +191,17 @@ return [
2 => '处理中',
3 => '执行上传完成',
4 => '其他失败',
],
'SupplierAbnormalLevel' => [
1 => '(假货,贴牌,翻新,散新)',
2 => '(氧化,划痕,歪角,丝印不清楚/磨字)',
3 => '(来料错误,包装不良,无标签)',
],
'SupplierExamineResult' => [
'退货' => '退货',
'特批入库' => '特批入库',
'正常入库' => '正常入库',
]
];
\ No newline at end of file
检货时间,采购员,供应商,型号,品牌,数量,检验数量,不良数,异常等级,不良现象,检验结果,处理方式,备注
销售订单号,采购订单号,检货时间,销售,采购员,A/B单,供应商,型号,品牌,数量,批次,产地,入库日期,来货单号,送货单,理货要求,验货要求,不良数,异常等级,不良现象,检验结果,备注
......@@ -63,22 +63,33 @@
let cols = [
{type: 'checkbox'},
{field: 'id', title: 'ID', align: 'center', width: 80},
{field: 'order_sn', title: '销售订单号', align: 'center', width: 150},
{field: 'purchase_sn', title: '采购订单号', align: 'center', width: 150},
{
field: 'examine_time', title: '检货时间', align: 'center', width: 130
},
{field: 'sales_name', title: '销售', align: 'center', width: 100},
{field: 'sales_department', title: '销售部门', align: 'center', width: 100},
{field: 'purchase_name', title: '采购员', align: 'center', width: 100},
{field: 'purchase_department', title: '采购部门', align: 'center', width: 100},
{field: 'ticket_type', title: 'A/B单', align: 'center', width: 100},
{
field: 'supplier_name', title: '供应商', align: 'center', width: 200
},
{field: 'sku_name', title: '型号', align: 'center', width: 160},
{field: 'brand_name', title: '品牌', align: 'center', width: 160},
{field: 'amount', title: '数量', align: 'center', width: 100},
{field: 'examine_amount', title: '检测数量', align: 'center', width: 100},
{field: 'unhealthy_amount', title: '不良数', align: 'center', width: 100},
{field: 'amount', title: '数量', align: 'center', width: 80},
{field: 'batch', title: '批次', align: 'center', width: 80},
{field: 'producing_area', title: '产地', align: 'center', width: 80},
{field: 'stock_in_date', title: '入库日期', align: 'center', width: 80},
{field: 'income_sn', title: '来货单号', align: 'center', width: 80},
{field: 'delivery_sn', title: '送货单', align: 'center', width: 80},
{field: 'tally_request', title: '理货要求', align: 'center', width: 80},
{field: 'examine_request', title: '验货要求', align: 'center', width: 100},
{field: 'abnormal_level', title: '异常等级', align: 'center', width: 80},
{field: 'unhealthy_content', title: '不良现象', align: 'center', width: 150},
{field: 'examine_result', title: '检验结果', align: 'center', width: 150},
{field: 'handle_way', title: '处理方式', align: 'center', width: 150},
{field: 'remark', title: '备注', align: 'center', width: 150},
];
let currentPage = 0;
......
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