You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
64 lines
1.8 KiB
<?php
|
|
/**
|
|
* 文化
|
|
*/
|
|
header("Access-Control-Allow-Origin:*");
|
|
header('X-Accel-Buffering: no');
|
|
header('Content-Type: text/event-stream');
|
|
header('Cache-Control: no-cache');
|
|
ob_end_clean();
|
|
ob_implicit_flush(1);
|
|
|
|
use app\common\dm\Dm;
|
|
use app\common\logic\PassFlow;
|
|
require_once __DIR__ . '../../source/application/common/dm/Dm.php';
|
|
require_once __DIR__ . '../../source/application/common/logic/PassFlow.php';
|
|
require_once __DIR__ . '../../source/thinkphp/helper.php';
|
|
require_once __DIR__ . '../../source/thinkphp/library/think/Config.php';
|
|
require_once __DIR__ . '../../source/application/common.php';
|
|
$config = require_once __DIR__ . '../../source/application/database.php';
|
|
|
|
date_default_timezone_set('Asia/Shanghai');
|
|
$dm = new Dm($config['connections']['dm']);
|
|
|
|
$xh = 0;
|
|
while($xh < 1) {
|
|
$data = [];
|
|
|
|
# 主动推送对应页面数据
|
|
|
|
# 累计服务人数 - 24小时服务人次
|
|
$data['allFlowTrends'] = ['data' => PassFlow::allFlowTrends($dm)];
|
|
|
|
# 24小时总服务人次趋势
|
|
$data['getLibraryHours24List'] = ['data' => PassFlow::getLibraryHours24List($dm)];
|
|
|
|
# 各场馆服务人次趋势
|
|
$data['getLibraryGroupHoursList'] = ['data' => PassFlow::getLibraryGroupHoursList($dm)];
|
|
|
|
# 图书馆数据统计
|
|
$data['getLibraryLeaseData'] = ['data' => PassFlow::getLibraryLeaseData($dm)];
|
|
|
|
$xh = $xh + 1;
|
|
returnEventData($data,"message",$xh);
|
|
sleep(3);
|
|
}
|
|
|
|
function returnEventData($returnData, $event='message', $id=0, $retry=0) {
|
|
$str = '';
|
|
if($id>0) {
|
|
$str .= "id: {$id}".PHP_EOL;
|
|
}
|
|
if($event) {
|
|
$str.= "event: {$event}".PHP_EOL;
|
|
}
|
|
if($retry>0) {
|
|
$str .= "retry: {$retry}".PHP_EOL;
|
|
}
|
|
if(is_array($returnData)) {
|
|
$returnData = json_encode($returnData);
|
|
}
|
|
$str .= "data: {$returnData}".PHP_EOL;
|
|
$str .= PHP_EOL;
|
|
echo $str;
|
|
}
|