feat(history): 添加历史数据管理功能和数据分析图表
- 在addons.php中添加example模块路由配置 - 新增application/config.php配置文件,包含应用设置、数据库配置等 - 实现dashboard.js仪表盘功能,包含冷热号码分析、比例分析图表 - 添加history.js历史数据管理功能,支持号码查询和统计分析 - 集成echarts图表库实现数据可视化展示 - 添加号码颜色映射和生肖映射功能 - 实现号码球样式格式化显示 - 添加遗漏号码、走势图、冷热分析等数据分析功能
This commit is contained in:
@@ -588,7 +588,78 @@ class History extends Model
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
// 基于最新一期(result[0])的lookback窗口,计算当前所有49个号码的冷热状态
|
||||
$current = $this->_computeCurrentHotCold($allHistorySorted, $historySorted[0], $lookback);
|
||||
|
||||
return [
|
||||
'list' => $result,
|
||||
'current' => $current
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于指定期的lookback窗口,计算所有49个号码的冷热状态
|
||||
* @param array $allHistorySorted 全量历史数据
|
||||
* @param mixed $targetRow 目标期数据
|
||||
* @param int $lookback 向前期数
|
||||
* @return array {hot: [{num, count}], cold: [{num, count}], warm: [{num, count}]}
|
||||
*/
|
||||
private function _computeCurrentHotCold($allHistorySorted, $targetRow, $lookback)
|
||||
{
|
||||
$targetTime = $targetRow['openTime'];
|
||||
$count = array_fill(1, 49, 0);
|
||||
$periodCount = 0;
|
||||
|
||||
for ($j = 0; $j < count($allHistorySorted); $j++) {
|
||||
$checkRow = $allHistorySorted[$j];
|
||||
$checkTime = $checkRow['openTime'];
|
||||
|
||||
if ($checkTime >= $targetTime) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($periodCount >= $lookback) {
|
||||
break;
|
||||
}
|
||||
|
||||
$num = (int)$checkRow['num7'];
|
||||
if ($num >= 1 && $num <= 49) {
|
||||
$count[$num]++;
|
||||
}
|
||||
$periodCount++;
|
||||
}
|
||||
|
||||
$avgCount = $periodCount > 0 ? $periodCount / 49 : 0;
|
||||
$hot = [];
|
||||
$cold = [];
|
||||
$warm = [];
|
||||
|
||||
for ($num = 1; $num <= 49; $num++) {
|
||||
$status = 'warm';
|
||||
if ($avgCount > 0) {
|
||||
if ($count[$num] > $avgCount * 1.5) {
|
||||
$status = 'hot';
|
||||
} elseif ($count[$num] < $avgCount * 0.5) {
|
||||
$status = 'cold';
|
||||
}
|
||||
}
|
||||
|
||||
$item = ['num' => $num, 'count' => $count[$num]];
|
||||
if ($status === 'hot') {
|
||||
$hot[] = $item;
|
||||
} elseif ($status === 'cold') {
|
||||
$cold[] = $item;
|
||||
} else {
|
||||
$warm[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
// 热号按次数降序,冷号按次数升序
|
||||
usort($hot, function ($a, $b) { return $b['count'] - $a['count']; });
|
||||
usort($cold, function ($a, $b) { return $a['count'] - $b['count']; });
|
||||
usort($warm, function ($a, $b) { return $b['count'] - $a['count']; });
|
||||
|
||||
return ['hot' => $hot, 'cold' => $cold, 'warm' => $warm];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user