v1.0.27: 碎片处理中心(完整方案) - 完整度计算引擎(四表分层/阈值)+is_incomplete标记(写操作挂钩)+api/fragment八接口(统计/硬碎片列表详情转换废弃/软碎片列表详情补全)+fragment.html前端(指标卡+硬软碎片双区块)

This commit is contained in:
nanguaboss
2026-08-09 15:47:05 +08:00
parent b68232bff3
commit 76431c20ac
25 changed files with 1342 additions and 3 deletions
+56
View File
@@ -0,0 +1,56 @@
<?php
/**
* 软碎片详情接口 GET /api/fragment/soft_detail.php?table=persons&id=1
* 返回:{ table, id, name, score, level, missing_core, missing_important, missing_supp, threshold, row }
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
require_once __DIR__ . '/../common/auth.php';
require_once __DIR__ . '/../common/completeness.php';
checkPermission('preliminary');
$table = trim($_REQUEST['table'] ?? '');
$id = (int)($_REQUEST['id'] ?? 0);
if (!in_array($table, ['persons', 'companies', 'social_accounts', 'media'], true) || $id <= 0) {
Response::error('参数错误', 400);
}
$pdo = DB::getInstance()->getPdo();
$info = completenessInfo($pdo, $table, $id);
if (!$info) {
Response::error('记录不存在');
}
$tableLabels = ['persons' => '人员', 'companies' => '企业', 'social_accounts' => '联系方式', 'media' => '媒体'];
$name = '';
switch ($table) {
case 'persons':
$name = $info['row']['full_name'] ?? '';
break;
case 'companies':
$name = $info['row']['display_name'] ?? '';
break;
case 'social_accounts':
$name = $info['row']['account_id'] ?? '';
break;
case 'media':
$acc = $pdo->prepare("SELECT account_id FROM social_accounts WHERE id = ?");
$acc->execute([$id]);
$name = (string)$acc->fetchColumn();
break;
}
Response::success([
'table' => $table,
'table_label' => $tableLabels[$table],
'id' => $id,
'name' => $name ?: ('#' . $id),
'score' => $info['score'],
'level' => $info['level'],
'threshold' => $info['threshold'],
'missing_core' => array_map(function ($f) { return ['key' => $f, 'label' => COMPLETENESS_LABELS[$f] ?? $f]; }, $info['missing_core']),
'missing_important' => array_map(function ($f) { return ['key' => $f, 'label' => COMPLETENESS_LABELS[$f] ?? $f]; }, $info['missing_important']),
'missing_supp' => array_map(function ($f) { return ['key' => $f, 'label' => COMPLETENESS_LABELS[$f] ?? $f]; }, $info['missing_supp']),
'row' => $info['row'],
]);