Commit b3bc53fa by wenyi.chen

线上

parent 35f9033a
......@@ -56,7 +56,7 @@ class ProductAllocation extends AuthBase
->alias('t1')
->join('product t2','t1.product_id=t2.id')
->join('admin t3','t1.user_id=t3.id')
->field('t1.status as product_allocation_status,t1.*')
->field('t1.status as product_allocation_status,t1.id as allocation_id,t1.*')
->field('t2.status as product_status,t2.*')
->field('t3.status as admin_status,t3.*')
->where($where)
......@@ -126,6 +126,9 @@ class ProductAllocation extends AuthBase
$EnterpriseInfoModel =new EnterpriseInfoModel();
$AdminModel =new AdminModel();
$productAllocationInfo = $ProductAllocationModel->where('id',$id)->find();
if(empty($productAllocationInfo)){
return returnResult(config("config.code.error"),'未找到相关信息!');
}
$productInfo = $ProductModel->where('id',$productAllocationInfo['product_id'])->find();
$enterpriseInfo = $EnterpriseInfoModel->where('id',$productInfo['enterprise_id'])->find();
$adminInfo = $AdminModel->where('id',$productAllocationInfo['user_id'])->find();
......
......@@ -162,5 +162,121 @@ class Test
$res = Db::name('enterprise_info')->where('enterprise_name','亿嘉和科技股份有限公司')->select();
dump($res);
}
public function exportData()
{
$result = Db::name('product')->where('status',1)->select();
$spreadsheet = new Spreadsheet();
$writer = new Xlsx($spreadsheet);
$spreadsheet->createSheet();
$spreadsheet->setActiveSheetIndex(0);
$spreadsheet->getActiveSheet(0)->setTitle('产品库');
$sheet = $spreadsheet->getActiveSheet(0);
$num = 0;
$row = 2;
foreach ($result as $index=>$value){
$info = Db::name('enterprise_info')->where('id',$value['enterprise_id'])->find();
$spreadsheet->getDefaultStyle()->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
$spreadsheet->getDefaultStyle()->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
$spreadsheet->getDefaultStyle()->getAlignment()->setWrapText(true);
$sheet->getDefaultRowDimension()->setRowHeight(50); // 默认行高
$sheet->getDefaultColumnDimension()->setWidth(50); // 默认单元格宽度
$sheet->getStyle('A1:J1')->getFill()
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
->getStartColor()->setARGB('C5D9F1'); // FF后面的六位数是颜色的RGB值
$title = [
'产品ID',
'企业名称',
'产品分类',
'产品名称',
'产品链接',
'产品型号',
'产品功能描述',
'产品规格参数',
'检查备注',
'检查状态',
];
$col = 'A';
$column = ['A'];
for ($coli = 0; $coli < count($title); $coli++) {
$col= \app\api\business\ExcelBus::excelColPlus($col);
array_push($column,$col);
}
// 遍历标题数组,设置每个单元格的值
foreach ($title as $columns => $val) {
// 'A1', 'B1', 'C1', ...
$cell = $column[$columns] . '1';
// 设置单元格的值
$sheet->setCellValue($cell, $val);
// 设置单元格A1的对齐方式为居中
}
$position = 0;
$sheet = $spreadsheet->getActiveSheet();
// 名称
$sheet->setCellValue($column[$num+$position].$row, $value['product_id']);
$position++;
// 名称
$sheet->setCellValue($column[$num+$position].$row, $info['enterprise_name']);
$position++;
// 位置
$sheet->setCellValue($column[$num+$position].$row, $value['product_categ_name']);
$position++;
// 位置
$sheet->setCellValue($column[$num+$position].$row, $value['product_name']);
$position++;
// 位置
$sheet->setCellValue($column[$num+$position].$row, $value['page_url']);
$position++;
// 位置
$sheet->setCellValue($column[$num+$position].$row, $value['product_model']);
$position++;
// 位置
$sheet->setCellValue($column[$num+$position].$row, $value['describe']);
$position++;
// 位置
$sheet->setCellValue($column[$num+$position].$row, $value['parameter']);
$position++;
// 位置
$sheet->setCellValue($column[$num+$position].$row, $value['inspect_remarks']);
$position++;
$inspect_status = $value['inspect_status'];
if($inspect_status == 0){
$inspect_status = '待检查';
}
if($inspect_status == 1){
$inspect_status = '检查完成';
}
if($inspect_status == 2){
$inspect_status = '检查中';
}
if($inspect_status == 3){
$inspect_status = '数据异常';
}
if($inspect_status == 4){
$inspect_status = '检查异常';
}
if($inspect_status == 5){
$inspect_status = '数据废弃';
}
// 位置
$sheet->setCellValue($column[$num+$position].$row, $inspect_status);
$position++;
$row++;
}
$name ='./product_'.date('Y-m-d H:i:s').'.csv';
$writer->save($name);
}
}
\ No newline at end of file
......@@ -112,3 +112,5 @@ Route::rule("service/enterpriseName","Service/enterpriseName");
Route::rule("test","test/product");
Route::rule("cee","test/cee");
Route::rule("exportData","test/exportData");
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 to comment