项目燃尽图
Signed-off-by: vilson <545522390@qq.com>
This commit is contained in:
parent
0b9b4c19ae
commit
a97c74717f
4
application/command.php
Normal file
4
application/command.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'projectReport' => 'app\common\command\ProjectReport',
|
||||||
|
];
|
40
application/common/Plugins/GateWayWorker/crontab.php
Normal file
40
application/common/Plugins/GateWayWorker/crontab.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Workerman\Lib\Timer;
|
||||||
|
use Workerman\Worker;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
require_once __DIR__ . '/../../../../vendor/autoload.php';
|
||||||
|
|
||||||
|
date_default_timezone_set('Asia/Shanghai');
|
||||||
|
|
||||||
|
$task = new Worker();
|
||||||
|
$task->name = 'crontab';
|
||||||
|
$doneTicket = [];
|
||||||
|
$task->onWorkerStart = function ($task) {
|
||||||
|
$timerId = Timer::add(1, 'checkTime');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 运行worker
|
||||||
|
Worker::runAll();
|
||||||
|
|
||||||
|
function checkTime()
|
||||||
|
{
|
||||||
|
global $doneTicket;
|
||||||
|
$now = time();
|
||||||
|
$dateTime = date('H:i', $now);
|
||||||
|
//每天23:55统计项目情况
|
||||||
|
if ($dateTime == '23:55' && (!isset($doneTicket['setProjectReportDate']) || date('Y-m-d', $now) != $doneTicket['setProjectReportDate'])) {
|
||||||
|
setProjectReport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setProjectReport()
|
||||||
|
{
|
||||||
|
global $doneTicket;
|
||||||
|
$doneTicket['setProjectReportDate'] = date('Y-m-d', time());
|
||||||
|
exec("php think projectReport",$out);
|
||||||
|
echo $out[0];
|
||||||
|
}
|
||||||
|
|
21
application/common/command/ProjectReport.php
Normal file
21
application/common/command/ProjectReport.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\command;
|
||||||
|
|
||||||
|
use think\console\Command;
|
||||||
|
use think\console\Input;
|
||||||
|
use think\console\Output;
|
||||||
|
|
||||||
|
class ProjectReport extends Command
|
||||||
|
{
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this->setName('ProjectReport');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(Input $input, Output $output)
|
||||||
|
{
|
||||||
|
\app\common\Model\ProjectReport::setDayilyProejctReport();
|
||||||
|
$output->writeln('success_at ' . nowTime());
|
||||||
|
}
|
||||||
|
}
|
1
crontab.bat
Normal file
1
crontab.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
php application\common\Plugins\GateWayWorker\crontab.php
|
2
crontab.sh
Normal file
2
crontab.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
php application/common/Plugins/GateWayWorker/crontab.php start&
|
2
crontab_stop.sh
Normal file
2
crontab_stop.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
php application/common/Plugins/GateWayWorker/crontab.php stop&
|
Loading…
x
Reference in New Issue
Block a user