...
|
...
|
@@ -792,4 +792,274 @@ class AdminExcelDataController extends AdminBaseController |
|
|
return $url;
|
|
|
}
|
|
|
|
|
|
//报修改造渲染数据到表格上
|
|
|
public function repairExcelData($arr,$table,$party){
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
$adminCommon = new AdminCommonController();
|
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
|
$xlsName = $arr['time'];
|
|
|
//设置sheet名称
|
|
|
$name = '报表';
|
|
|
$name = $adminCommon->iconv_to_utf8($name);
|
|
|
|
|
|
$sheet->setTitle($xlsName.$name);
|
|
|
//合并单元格
|
|
|
|
|
|
//报表名称
|
|
|
$sheet->mergeCells('B1:J1');
|
|
|
|
|
|
//甲方logo,甲方公司名称
|
|
|
$sheet->mergeCells('B3:B4');
|
|
|
$sheet->mergeCells('C3:D3');
|
|
|
$sheet->mergeCells('C4:D4');
|
|
|
|
|
|
//乙方logo,乙方公司名称
|
|
|
$sheet->mergeCells('F3:F4');
|
|
|
$sheet->mergeCells('G3:I3');
|
|
|
$sheet->mergeCells('G4:I4');
|
|
|
|
|
|
//乙方发起人姓名
|
|
|
$sheet->mergeCells('B6:C6');
|
|
|
$sheet->mergeCells('B7:C7');
|
|
|
|
|
|
//乙方项目组
|
|
|
$sheet->mergeCells('F6:H6');
|
|
|
$sheet->mergeCells('F7:H7');
|
|
|
|
|
|
//培训演习状态
|
|
|
$sheet->mergeCells('I6:J6');
|
|
|
$sheet->mergeCells('I7:J7');
|
|
|
|
|
|
//培训演习单号
|
|
|
$sheet->mergeCells('K6:L6');
|
|
|
$sheet->mergeCells('K7:L7');
|
|
|
|
|
|
//甲方领导确认人
|
|
|
$sheet->mergeCells('B9:C9');
|
|
|
$sheet->mergeCells('B10:C10');
|
|
|
|
|
|
//乙方员工确认人
|
|
|
$sheet->mergeCells('D9:E9');
|
|
|
$sheet->mergeCells('D10:E10');
|
|
|
|
|
|
|
|
|
$spreadsheet->getDefaultStyle()->getFont()->setName('微软雅黑');//字体
|
|
|
|
|
|
//设置默认宽
|
|
|
$sheet->getDefaultColumnDimension()->setWidth(8);
|
|
|
//设置高度
|
|
|
$sheet->getRowDimension(1)->setRowHeight(45);
|
|
|
// $sheet->getRowDimension(2)->setRowHeight(55);
|
|
|
|
|
|
//***********************背景填充颜色*****************************
|
|
|
$sheet->getStyle( 'A1:M11')->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
|
|
|
$sheet->getStyle( 'A1:M11')->getFill()->getStartColor()->setRGB('222B35');//背景颜色
|
|
|
//***********************画出单元格边框结束*****************************
|
|
|
|
|
|
//标题
|
|
|
$sheet->setCellValue('B1', $arr['title']);
|
|
|
$sheet->getStyle('B1')->getFont()->setSize(18);//字体大小
|
|
|
$sheet->getStyle('B1')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
|
|
|
$sheet->getStyle('B1')->getFont()->setBold(true);//字体加粗
|
|
|
|
|
|
//甲方logo
|
|
|
$imageA = $arr['a_company']['logo'];
|
|
|
if(@fopen($imageA , 'r' ) ) {
|
|
|
//这是一个坑,刚开始我把实例化图片类放在了循环外面,但是失败了,也就是每个图片都要实例化一次
|
|
|
$imageADrawing = new Drawing();
|
|
|
$imageADrawing->setPath($imageA);
|
|
|
// 设置图片的宽度
|
|
|
$imageADrawing->setResizeProportional(false);
|
|
|
$imageADrawing->setWidthAndHeight(40,40);
|
|
|
//图片显示在B3
|
|
|
$imageADrawing->setCoordinates('B3');
|
|
|
$imageADrawing->setWorksheet($sheet);
|
|
|
}
|
|
|
|
|
|
$sheet->getStyle('B3:K10')->getFont()->setSize(8);//字体大小
|
|
|
$sheet->getStyle('C3:G3')->getFont()->getColor()->setRGB('949494');//设置颜色为灰色
|
|
|
$sheet->getStyle('B6:K6')->getFont()->getColor()->setRGB('949494');//设置颜色为灰色
|
|
|
$sheet->getStyle('B9:I9')->getFont()->getColor()->setRGB('949494');//设置颜色为灰色
|
|
|
$sheet->getStyle('C4:G4')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
|
|
|
$sheet->getStyle('B7:K7')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
|
|
|
$sheet->getStyle('B10:I10')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
|
|
|
|
|
|
//甲方公司
|
|
|
$sheet->setCellValue('C3', '甲方公司');
|
|
|
//甲方公司名称
|
|
|
$sheet->setCellValue('C4', $arr['a_company']['company_name']);
|
|
|
|
|
|
//乙方logo
|
|
|
$imageB = $arr['b_company']['logo'];
|
|
|
if(@fopen($imageB , 'r' ) ) {
|
|
|
//这是一个坑,刚开始我把实例化图片类放在了循环外面,但是失败了,也就是每个图片都要实例化一次
|
|
|
$objDrawing = new Drawing();
|
|
|
$objDrawing->setPath($imageB);
|
|
|
// 设置图片的宽度
|
|
|
$objDrawing->setResizeProportional(false);
|
|
|
$objDrawing->setWidthAndHeight(40,40);
|
|
|
//图片显示在F3
|
|
|
$objDrawing->setCoordinates('F3');
|
|
|
$objDrawing->setWorksheet($sheet);
|
|
|
}
|
|
|
|
|
|
//乙方公司
|
|
|
$sheet->setCellValue('G3', '乙方公司');
|
|
|
//乙方公司名称
|
|
|
$sheet->setCellValue('G4', $arr['b_company']['company_name']);
|
|
|
|
|
|
//甲方/乙方发起人姓名
|
|
|
if($party == 0){
|
|
|
$sheet->setCellValue('B6', '甲方发起人');
|
|
|
}else{
|
|
|
$sheet->setCellValue('B6', '乙方发起人');
|
|
|
}
|
|
|
$sheet->setCellValue('B7', $arr['user_login']);
|
|
|
|
|
|
//报修改造时间
|
|
|
if($table == 'repair'){
|
|
|
$sheet->setCellValue('D6', '报修时间');
|
|
|
}else{
|
|
|
$sheet->setCellValue('D6', '改造时间');
|
|
|
}
|
|
|
$sheet->setCellValue('D7', $arr['create_time']);
|
|
|
|
|
|
//乙方项目组
|
|
|
$sheet->setCellValue('F6', '项目组');
|
|
|
$sheet->setCellValue('F7', $arr['group_name']);
|
|
|
|
|
|
//报修改造状态
|
|
|
if($table == 'repair'){
|
|
|
$sheet->setCellValue('I6', '报修状态');
|
|
|
}else{
|
|
|
$sheet->setCellValue('I6', '改造状态');
|
|
|
}
|
|
|
$sheet->setCellValue('I7', $arr['status']);
|
|
|
|
|
|
//报修改造单号
|
|
|
if($table == 'repair'){
|
|
|
$sheet->setCellValue('K6', '报修单号');
|
|
|
}else{
|
|
|
$sheet->setCellValue('K6', '改造单号');
|
|
|
}
|
|
|
$sheet->setCellValue('K7', $arr['number']);
|
|
|
$sheet->getStyle('K7')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER);//解决长数字显示为科学计数法
|
|
|
|
|
|
//报修改造确认人(甲方发起,乙方确认,乙方发起,甲方确认)
|
|
|
if($party == 0){
|
|
|
$sheet->setCellValue('B9', '乙方员工确认人');
|
|
|
}else{
|
|
|
$sheet->setCellValue('B9', '甲方员工确认人');
|
|
|
}
|
|
|
$sheet->setCellValue('B10', $arr['h_user']);
|
|
|
|
|
|
//甲方员工确认完成人
|
|
|
$sheet->setCellValue('D9', '甲方员工确认完成人');
|
|
|
$sheet->setCellValue('D10', $arr['confirm_user']);
|
|
|
|
|
|
//完成时间
|
|
|
$sheet->setCellValue('F9', '完成时间');
|
|
|
$sheet->setCellValue('F10', $arr['finish_time']);
|
|
|
|
|
|
//工期
|
|
|
$sheet->setCellValue('I9', '工期(天)');
|
|
|
$sheet->setCellValue('I10', $arr['check_period']);
|
|
|
|
|
|
$array1 = [
|
|
|
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT,
|
|
|
'textRotation' => 0,
|
|
|
'wrapText' => TRUE
|
|
|
];
|
|
|
$sheet->getStyle('K7')->getAlignment()->applyFromArray($array1);//垂直水平居左
|
|
|
$sheet->getStyle('F10')->getAlignment()->applyFromArray($array1);//垂直水平居左
|
|
|
$sheet->getStyle('I10')->getAlignment()->applyFromArray($array1);//垂直水平居左
|
|
|
|
|
|
//循环开始
|
|
|
$cols = 13;
|
|
|
$cells = ['C','E','G','I','K'];
|
|
|
foreach($arr['repair'] as $value){
|
|
|
$cols += 1;
|
|
|
//巡检点名称
|
|
|
$array = [
|
|
|
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
|
|
|
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
|
|
|
'textRotation' => 0,
|
|
|
'wrapText' => TRUE
|
|
|
];
|
|
|
$sheet->mergeCells('A'.$cols.':B'.$cols);
|
|
|
$sheet->setCellValue('A'.$cols, $value['check_name']);
|
|
|
$sheet->getStyle('A'.$cols)->getAlignment()->applyFromArray($array);//垂直水平居中
|
|
|
//循环第二层
|
|
|
foreach($value['images'] as $image_image){
|
|
|
//渲染图片日期
|
|
|
$col_day = $cols - 1;
|
|
|
$sheet->mergeCells('C'.$col_day.':D'.$col_day);
|
|
|
$sheet->setCellValue('C'.$col_day, $image_image['day']);
|
|
|
|
|
|
//获取图片个数
|
|
|
$length = count($image_image['image']);
|
|
|
$col = ceil($length/5);
|
|
|
for($i=0;$i<$col;$i++) {
|
|
|
$col_i = $cols + $i;
|
|
|
$sheet->getRowDimension($col_i)->setRowHeight(105);
|
|
|
$sheet->mergeCells('C' . $col_i . ':D' . $col_i);
|
|
|
$sheet->mergeCells('E' . $col_i . ':F' . $col_i);
|
|
|
$sheet->mergeCells('G' . $col_i . ':H' . $col_i);
|
|
|
$sheet->mergeCells('I' . $col_i . ':J' . $col_i);
|
|
|
$sheet->mergeCells('K' . $col_i . ':L' . $col_i);
|
|
|
$key = 0;
|
|
|
foreach($image_image['image'] as $k=>$image_value){
|
|
|
$pre = $i+4*$i;
|
|
|
$next = $i+1+4*($i+1);
|
|
|
if($k>=$pre && $k<$next){
|
|
|
//巡检图片
|
|
|
$image = $image_value['image_url'];
|
|
|
if(@fopen($image , 'r' ) ) {
|
|
|
//这是一个坑,刚开始我把实例化图片类放在了循环外面,但是失败了,也就是每个图片都要实例化一次
|
|
|
$obj = new Drawing();
|
|
|
$obj->setPath($image);
|
|
|
// 设置图片的宽度
|
|
|
$obj->setResizeProportional(false);
|
|
|
$obj->setWidthAndHeight(105,130);
|
|
|
//图片显示在F3
|
|
|
$obj->setCoordinates($cells[$key].$col_i);
|
|
|
$obj->setWorksheet($sheet);
|
|
|
}
|
|
|
$key++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
$cols += $col+1;
|
|
|
}
|
|
|
}
|
|
|
$sheet->getStyle( 'A12:M'.$cols)->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
|
|
|
$sheet->getStyle( 'A12:M'.$cols)->getFill()->getStartColor()->setRGB('F3F3F4');//背景颜色浅灰色
|
|
|
|
|
|
$objWrite = IOFactory::createWriter($spreadsheet, 'Xls');
|
|
|
|
|
|
//直接从浏览器中输出star
|
|
|
// header('pragma:public');
|
|
|
// header("Content-Disposition:attachment;filename=出货装箱单.xls");
|
|
|
// $objWrite->save('php://output');
|
|
|
// exit;
|
|
|
//直接从浏览器中输出end
|
|
|
|
|
|
$file_name = $xlsName.'.xls';
|
|
|
|
|
|
$files_url = ROOT_PATH . '/public/upload/export';
|
|
|
if(!is_dir($files_url)){
|
|
|
mkdir($files_url);
|
|
|
}
|
|
|
$file_url = ROOT_PATH . '/public/upload/export/'.$file_name;
|
|
|
$objWrite->save($file_url);
|
|
|
|
|
|
$sys = $adminCommon->getOperateSys();
|
|
|
if($sys == 'Linux'){
|
|
|
chmod($file_url, 0777);//适用于linux
|
|
|
}
|
|
|
//相对路径
|
|
|
$url = 'upload/export/'.$file_name;
|
|
|
return $url;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|