41 lines
933 B
PHP
41 lines
933 B
PHP
<?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];
|
|
}
|
|
|