GeneratePdfData.php
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace App\Console\Commands\GeneratePDF;
use App\Models\File\PdfFile;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Services\CosService;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Console\Command;
class GeneratePdfData extends Command
{
// use CmdSignal;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'generate_pdf_data';
/**
* The console command description.
*
* @var string
*/
protected $description = '生成v6绑定的aicc用户的pdf备用数据';
// 最大支持5个进程
public $maxRunNumber = 50;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle()
{
return $this->main();
}
/**
* @return int
*/
public function start(): int
{
return $this->main();
}
/**
* @return int
*/
protected function main()
{
$month = date('m');
$list = ProjectAssociation::query()->whereStatus(ProjectAssociation::STATUS_NORMAL)
->where('m_status', '!=', $month)->first();
if (is_null($list)) {
$this->error('没有任务,等待中');
sleep(60);
return 0;
}
$pdfFile = new PdfFile();
$bool = $pdfFile->saveData(['pid' => $list->id]);
if (!$bool) {
$this->error('生成v6绑定的aicc用户的pdf备用数据添加失败');
return 0;
}
$list->m_status = $month;
$list->save();
$this->info('生成v6绑定的aicc用户的pdf备用数据添加成功');
return 0;
}
}