From a97c74717fe8bb069354da3c2437f83c4d57e9e1 Mon Sep 17 00:00:00 2001 From: vilson <545522390@qq.com> Date: Thu, 20 Feb 2020 22:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=87=83=E5=B0=BD=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: vilson <545522390@qq.com> --- application/command.php | 4 ++ .../common/Plugins/GateWayWorker/crontab.php | 40 +++++++++++++++++++ application/common/command/ProjectReport.php | 21 ++++++++++ crontab.bat | 1 + crontab.sh | 2 + crontab_stop.sh | 2 + 6 files changed, 70 insertions(+) create mode 100644 application/command.php create mode 100644 application/common/Plugins/GateWayWorker/crontab.php create mode 100644 application/common/command/ProjectReport.php create mode 100644 crontab.bat create mode 100644 crontab.sh create mode 100644 crontab_stop.sh diff --git a/application/command.php b/application/command.php new file mode 100644 index 0000000..7cb49f0 --- /dev/null +++ b/application/command.php @@ -0,0 +1,4 @@ + 'app\common\command\ProjectReport', +]; diff --git a/application/common/Plugins/GateWayWorker/crontab.php b/application/common/Plugins/GateWayWorker/crontab.php new file mode 100644 index 0000000..b35e982 --- /dev/null +++ b/application/common/Plugins/GateWayWorker/crontab.php @@ -0,0 +1,40 @@ +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]; +} + diff --git a/application/common/command/ProjectReport.php b/application/common/command/ProjectReport.php new file mode 100644 index 0000000..b974ed0 --- /dev/null +++ b/application/common/command/ProjectReport.php @@ -0,0 +1,21 @@ +setName('ProjectReport'); + } + + protected function execute(Input $input, Output $output) + { + \app\common\Model\ProjectReport::setDayilyProejctReport(); + $output->writeln('success_at ' . nowTime()); + } +} diff --git a/crontab.bat b/crontab.bat new file mode 100644 index 0000000..22c8801 --- /dev/null +++ b/crontab.bat @@ -0,0 +1 @@ +php application\common\Plugins\GateWayWorker\crontab.php diff --git a/crontab.sh b/crontab.sh new file mode 100644 index 0000000..01deb66 --- /dev/null +++ b/crontab.sh @@ -0,0 +1,2 @@ +#!/bin/bash +php application/common/Plugins/GateWayWorker/crontab.php start& diff --git a/crontab_stop.sh b/crontab_stop.sh new file mode 100644 index 0000000..0960ea1 --- /dev/null +++ b/crontab_stop.sh @@ -0,0 +1,2 @@ +#!/bin/bash +php application/common/Plugins/GateWayWorker/crontab.php stop&