This commit is contained in:
wangjinlei
2022-11-25 11:00:09 +08:00
parent 40cf8445df
commit 9f27e8e054
3 changed files with 133 additions and 48 deletions

View File

@@ -423,7 +423,8 @@ class Main extends Controller {
myPost($push_url,$re); myPost($push_url,$re);
} }
} }
/** /**
* 获取图片cn站点拉取主站img文件 * 获取图片cn站点拉取主站img文件
*/ */
@@ -455,6 +456,8 @@ class Main extends Controller {
$fileData['mubiao'] = $dir.'/3714895481e8d2338c25c57bbcfba0b7.pdf'; $fileData['mubiao'] = $dir.'/3714895481e8d2338c25c57bbcfba0b7.pdf';
Queue::push( 'app\api\job\imgFile@fire' , $fileData , "file" ); Queue::push( 'app\api\job\imgFile@fire' , $fileData , "file" );
} }
/** /**
* @title 获取首页Highlights * @title 获取首页Highlights

View File

@@ -9,20 +9,20 @@ class imgFile {
//put your code here //put your code here
public function fire(Job $job, $data) { public function fire(Job $job, $data) {
$res = $this->send($data); $this->send($data);
$job->delete(); $job->delete();
if($res){ // if($res){
$job->delete(); // $job->delete();
}else{ // }else{
if($job->attempts()>3){ // if($job->attempts()>3){
// 第1种处理方式重新发布任务,该任务延迟10秒后再执行 // // 第1种处理方式重新发布任务,该任务延迟10秒后再执行
//$job->release(10); // //$job->release(10);
// 第2种处理方式原任务的基础上1分钟执行一次并增加尝试次数 // // 第2种处理方式原任务的基础上1分钟执行一次并增加尝试次数
//$job->failed(); // //$job->failed();
// 第3种处理方式删除任务 // // 第3种处理方式删除任务
$job->delete(); // $job->delete();
} // }
} // }
} }
/** /**

View File

@@ -1,15 +1,9 @@
<?php <?php
namespace app\master\controller; namespace app\master\controller;
use Exception;
use PHPExcel;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\IOFactory; use PhpOffice\PhpWord\IOFactory;
use think\Controller; use think\Controller;
use think\Db;
use think\Queue;
use think\Validate;
/** /**
* @title 文章接口 * @title 文章接口
@@ -109,11 +103,13 @@ class Mytest extends Controller
$PHPWord = new PhpWord(); $PHPWord = new PhpWord();
$section = $PHPWord->createSection(); $section=$PHPWord->addSection();
// $section = $PHPWord->createSection();
$PHPWord->addTitleStyle(1, array('bold' => true, 'size' => 18, 'name' => 'Arial', 'Color' => '333'), array('align' => 'center')); $PHPWord->addTitleStyle(1, array('bold' => true, 'size' => 18, 'name' => 'Arial', 'Color' => '333'), array('align' => 'center'));
$section->addTitle("疫情防控", 1); // $section->addTitle("疫情防控", 1);
//定义样式数组 //定义样式数组
@@ -137,7 +133,10 @@ class Mytest extends Controller
); );
$cellStyle = array('gridSpan' => 2); // $cellStyle = array('gridSpan' => 2);
$cellStyle1 = array('gridSpan' => 3,"bgColor"=>"FF0000",'align'=>'center');
$cellStyle2 = array('gridSpan' => 3,"bgColor"=>"EEEE11",'align'=>'center');
$cellStyle3 = array('gridSpan' => 3,"bgColor"=>"0099FF",'align'=>'center');
//添加表格样式 //添加表格样式
@@ -145,53 +144,136 @@ class Mytest extends Controller
//添加表格 //添加表格
$table = $section->addTable('myOwnTableStyle'); $table = $section->addTable('myOwnTableStyle');
$table->addRow(); $table->addRow();
$table->addCell(9000,$cellStyle1)->addText('高风险等级地区');
$gn = "";
foreach($fg as $v){
$table->addRow();
if($v['p']==$gn){
$table->addCell(2000,array('vMerge' => 'continue'));
}else{
$table->addCell(2000, array('vMerge' => 'restart','valign'=>'center'))->addText($v['p']);
}
$table->addCell(2000)->addText($v["city"]);
$table->addCell(5000)->addText($v['area']);
$gn = $v['p'];
}
$table->addCell(3000)->addText('测试1'); $table = $section->addTable('myOwnTableStyle');
$table->addCell(3000)->addText('测试2');
$table->addCell(3000)->addText('测试3');
$table->addRow(); $table->addRow();
$table->addCell(9000,$cellStyle2)->addText('中风险等级地区');
$zn = "";
foreach($fz as $v){
$table->addRow();
if($v['p']==$zn){
$table->addCell(2000,array('vMerge' => 'continue'));
}else{
$table->addCell(2000, array('vMerge' => 'restart','valign'=>'center'))->addText($v['p']);
}
$table->addCell(2000)->addText($v["city"]);
$table->addCell(5000)->addText($v['area']);
$zn = $v['p'];
}
$table->addCell(3000)->addText('测试4');
$table->addCell(6000, $cellStyle)->addText('测试5'); //合并列单元格 $table1 = $section->addTable('myOwnTableStyle');
$table1->addRow();
$table1->addCell(9000,$cellStyle3)->addText('低风险等级地区');
$dn = "";
foreach($fd as $v){
$table1->addRow();
if($v['p']==$dn){
$table1->addCell(2000,array('vMerge' => 'continue'));
}else{
$table1->addCell(2000, array('vMerge' => 'restart','valign'=>'center'))->addText($v['p']);
}
$table1->addCell(2000)->addText($v["city"]);
$table1->addCell(5000)->addText($v['area']);
$dn = $v['p'];
}
$table->addRow();
// $table1 = $section->addTable('myOwnTableStyle');
// $table1->addRow();
// $table1->addCell(9000,$cellStyle2)->addText('中风险等级地区');
// $zn = "";
// foreach($fz as $v){
// $table1->addRow();
// if($v['p']==$zn){
// $table->addCell(2000,array('vMerge' => 'continue'));
// }else{
// $table->addCell(2000, array('vMerge' => 'restart'))->addText($v['p']);
// }
// $table1->addCell(2000)->addText($v["city"]);
// $table1->addCell(5000)->addText($v['area']);
// $zn = $v['p'];
// }
$table->addCell(3000, array('vMerge' => 'restart'))->addText('合并');
$table->addCell(3000, array('vMerge' => 'restart'))->addText('测试6');
$table->addCell(3000)->addText('测试7'); // $table2 = $section->addTable('myOwnTableStyle');
// $table2->addRow();
// $table2->addCell(9000,$cellStyle3)->addText('低风险等级地区');
// $dn = "";
// foreach($fd as $v){
// $table2->addRow();
// if($v['p']==$dn){
// $table->addCell(2000,array('vMerge' => 'continue'));
// }else{
// $table->addCell(2000, array('vMerge' => 'restart'))->addText($v['p']);
// }
// $table2->addCell(2000)->addText($v["city"]);
// $table2->addCell(5000)->addText($v['area']);
// $dn = $v['p'];
// }
$table->addRow(); // $table->addRow();
$table->addCell(3000, array('vMerge' => 'continue')); // $table->addCell(3000)->addText('测试1');
$table->addCell(3000)->addText('测试8'); // $table->addCell(3000)->addText('测试2');
$table->addCell(3000)->addText('测试9'); // $table->addCell(3000)->addText('测试3');
$table->addRow(); // $table->addRow();
$table->addCell(3000)->addText('测试10'); // $table->addCell(3000)->addText('测试4');
$table->addCell(3000)->addText('测试11'); // $table->addCell(6000, $cellStyle)->addText('测试5'); //合并列单元格
$table->addCell(3000)->addText('测试12'); // $table->addRow();
$file = '测试.docx'; // $table->addCell(3000, array('vMerge' => 'restart'))->addText('合并');
// $table->addCell(3000)->addText('测试6');
// $table->addCell(3000)->addText('测试7');
// $table->addRow();
// $table->addCell(3000, array('vMerge' => 'continue'));
// $table->addCell(3000)->addText('测试8');
// $table->addCell(3000)->addText('测试9');
// $table->addRow();
// $table->addCell(3000,array('vMerge' => 'continue'));
// $table->addCell(3000)->addText('测试10');
// $table->addCell(3000)->addText('测试11');
$file = '风险区域总结.docx';
//文档存在服务器上用此代码 //文档存在服务器上用此代码
$objWriter = IOFactory::createWriter($PHPWord, 'Word2007'); // $objWriter = IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('存储地址/编程爱好者.docx'); // $objWriter->save('d:\编程爱好者.docx');
//直接下载不存储在服务器上用此代码 //直接下载不存储在服务器上用此代码