v1.0.27: 碎片处理中心(完整方案) - 完整度计算引擎(四表分层/阈值)+is_incomplete标记(写操作挂钩)+api/fragment八接口(统计/硬碎片列表详情转换废弃/软碎片列表详情补全)+fragment.html前端(指标卡+硬软碎片双区块)
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* 碎片处理中心 - 顶部指标卡接口 GET /api/fragment/stats_overview.php
|
||||
* 返回:{ hard_total 硬碎片总数, soft_total 软碎片总数, month_new 本月新增,
|
||||
* month_processed 本月处理, pending 待处理碎片 }
|
||||
*/
|
||||
require_once __DIR__ . '/../common/db.php';
|
||||
require_once __DIR__ . '/../common/response.php';
|
||||
require_once __DIR__ . '/../common/auth.php';
|
||||
|
||||
checkPermission('preliminary');
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
|
||||
// 硬碎片:preliminary_data 中未终结(未转换/未废弃)的记录
|
||||
$hardTotal = (int)$pdo->query(
|
||||
"SELECT COUNT(*) FROM preliminary_data WHERE is_active = 1 AND status NOT IN ('已转换','已废弃')"
|
||||
)->fetchColumn();
|
||||
|
||||
// 软碎片:四张主表 is_incomplete=1 之和
|
||||
$softTotal = 0;
|
||||
foreach (['companies', 'persons', 'social_accounts', 'media_commercial_attributes'] as $t) {
|
||||
$softTotal += (int)$pdo->query("SELECT COUNT(*) FROM `$t` WHERE is_incomplete = 1")->fetchColumn();
|
||||
}
|
||||
|
||||
// 本月新增(硬碎片按 created_at)
|
||||
$monthNew = (int)$pdo->query(
|
||||
"SELECT COUNT(*) FROM preliminary_data WHERE is_active = 1 AND created_at >= DATE_FORMAT(CURDATE(), '%Y-%m-01')"
|
||||
)->fetchColumn();
|
||||
|
||||
// 本月处理(已转换/已废弃且 processed_at 在本月)
|
||||
$monthProcessed = (int)$pdo->query(
|
||||
"SELECT COUNT(*) FROM preliminary_data
|
||||
WHERE is_active = 1 AND status IN ('已转换','已废弃')
|
||||
AND processed_at >= DATE_FORMAT(CURDATE(), '%Y-%m-01')"
|
||||
)->fetchColumn();
|
||||
|
||||
// 待处理碎片
|
||||
$pending = (int)$pdo->query(
|
||||
"SELECT COUNT(*) FROM preliminary_data WHERE is_active = 1 AND status = '待处理'"
|
||||
)->fetchColumn();
|
||||
|
||||
Response::success([
|
||||
'hard_total' => $hardTotal,
|
||||
'soft_total' => $softTotal,
|
||||
'month_new' => $monthNew,
|
||||
'month_processed' => $monthProcessed,
|
||||
'pending' => $pending,
|
||||
]);
|
||||
Reference in New Issue
Block a user