v1.0.29: 碎片处理按dp方案2修订 - 完整度改三层独立判定(核心100%/重要60%/非必要40%,任一不达标即碎片)+字段分层调整(persons email升核心,companies核心扩5字段)+指标卡5张(新增累计处理,本月/累计=硬+软合计)+软碎片列表加各层完整度列+硬碎片完整度改已填/总可填

This commit is contained in:
nanguaboss
2026-08-09 21:13:33 +08:00
parent 616da931fa
commit 17dc5d434b
11 changed files with 216 additions and 151 deletions
+26 -18
View File
@@ -1,8 +1,10 @@
<?php
/**
* 软碎片列表接口 GET /api/fragment/soft_list.php
* 参数:page / limit / table(所属表 persons|companies|social_accounts|media)/ level(core|important|supplementary)/ keyword
* 返回:{ list, total, page, limit },每行含 完整度 score、缺失层级标签、名称、缺失字段、所属表、录入时间
* 参数:page / limit / table(persons|companies|social_accounts|media)/ level(core|important|optional)/ keyword
* 返回:{ list, total, page, limit }
* 每行:{ table, table_label, id, name, overall 整体完整度, level 缺失层级,
* layer_rates {core,important,optional}, missing_fields 缺失字段(按核心→重要→非必要优先级), created_at }
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
@@ -17,10 +19,10 @@ $level = trim($_REQUEST['level'] ?? '');
$keyword = trim($_REQUEST['keyword'] ?? '');
$tableMap = [
'persons' => ['label' => '人员', 'name' => 'full_name'],
'companies' => ['label' => '企业', 'name' => 'display_name'],
'social_accounts' => ['label' => '联系方式', 'name' => 'account_id'],
'media' => ['label' => '媒体', 'name' => null], // media 需 JOIN social_accounts 取名
'persons' => ['label' => '人员', 'name' => 'full_name'],
'companies' => ['label' => '企业', 'name' => 'display_name'],
'social_accounts' => ['label' => '联系方式', 'name' => 'account_id'],
'media' => ['label' => '媒体', 'name' => null], // media 需 JOIN social_accounts 取名
];
$pdo = DB::getInstance()->getPdo();
@@ -32,7 +34,7 @@ foreach ($tableMap as $t => $cfg) {
}
if ($t === 'media') {
$rows = $pdo->query(
"SELECT m.social_account_id AS id, sa.account_id AS name, m.updated_at AS created_at
"SELECT m.social_account_id AS id, sa.account_id AS name, sa.created_at AS created_at
FROM media_commercial_attributes m
LEFT JOIN social_accounts sa ON sa.id = m.social_account_id
WHERE m.is_incomplete = 1"
@@ -48,24 +50,30 @@ foreach ($tableMap as $t => $cfg) {
if ($level !== '' && $info['level'] !== $level) {
continue;
}
$missingFields = array_merge($info['missing_core'], $info['missing_important'], $info['missing_supp']);
// 缺失字段按优先级:核心 → 重要 → 非必要
$missingFields = array_merge($info['missing']['core'], $info['missing']['important'], $info['missing']['optional']);
$all[] = [
'table' => $t,
'table_label' => $cfg['label'],
'id' => (int)$r['id'],
'name' => $r['name'] ?: ('#' . $r['id']),
'score' => $info['score'],
'level' => $info['level'],
'table' => $t,
'table_label' => $cfg['label'],
'id' => (int)$r['id'],
'name' => $r['name'] ?: ('#' . $r['id']),
'overall' => $info['overall'],
'level' => $info['level'],
'layer_rates' => [
'core' => $info['layers']['core']['rate'],
'important' => $info['layers']['important']['rate'],
'optional' => $info['layers']['optional']['rate'],
],
'missing_fields' => array_map(function ($f) { return COMPLETENESS_LABELS[$f] ?? $f; }, $missingFields),
'created_at' => $r['created_at'] ?? null,
'created_at' => $r['created_at'] ?? null,
];
}
}
// 按完整度升序(最残缺的排前面),再按时间倒序
// 排序:整体完整度升序(最残缺在前),同分按时间倒序
usort($all, function ($a, $b) {
if ($a['score'] !== $b['score']) {
return $a['score'] <=> $b['score'];
if ($a['overall'] !== $b['overall']) {
return $a['overall'] <=> $b['overall'];
}
return strcmp($b['created_at'] ?? '', $a['created_at'] ?? '');
});