v1.0.27: 碎片处理中心(完整方案) - 完整度计算引擎(四表分层/阈值)+is_incomplete标记(写操作挂钩)+api/fragment八接口(统计/硬碎片列表详情转换废弃/软碎片列表详情补全)+fragment.html前端(指标卡+硬软碎片双区块)
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* 硬碎片列表接口 GET /api/fragment/hard_list.php
|
||||
* 参数:page / limit / source_type / status / source_channel / keyword
|
||||
* 返回:{ list, total, page, limit },每行含完整度 score、缺失层级、内容摘要
|
||||
*/
|
||||
require_once __DIR__ . '/../common/db.php';
|
||||
require_once __DIR__ . '/../common/response.php';
|
||||
require_once __DIR__ . '/../common/auth.php';
|
||||
require_once __DIR__ . '/hard_common.php';
|
||||
|
||||
checkPermission('preliminary');
|
||||
|
||||
[$page, $limit] = pageParams();
|
||||
$keyword = trim($_REQUEST['keyword'] ?? '');
|
||||
$status = trim($_REQUEST['status'] ?? '');
|
||||
$sourceType = trim($_REQUEST['source_type'] ?? '');
|
||||
$sourceChannel = trim($_REQUEST['source_channel'] ?? '');
|
||||
|
||||
$where = ["is_active = 1", "status NOT IN ('已转换','已废弃')"];
|
||||
$params = [];
|
||||
if ($keyword !== '') {
|
||||
$where[] = '(company_name LIKE ? OR person_name LIKE ? OR contact_phone LIKE ? OR contact_email LIKE ? OR description LIKE ?)';
|
||||
$like = "%$keyword%";
|
||||
array_push($params, $like, $like, $like, $like, $like);
|
||||
}
|
||||
if ($status !== '') { $where[] = 'status = ?'; $params[] = $status; }
|
||||
if ($sourceType !== '') { $where[] = 'source_type = ?'; $params[] = $sourceType; }
|
||||
if ($sourceChannel !== '') { $where[] = 'source_channel = ?'; $params[] = $sourceChannel; }
|
||||
$whereSql = implode(' AND ', $where);
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
|
||||
$stmt = $pdo->prepare("SELECT COUNT(*) FROM preliminary_data WHERE $whereSql");
|
||||
$stmt->execute($params);
|
||||
$total = (int)$stmt->fetchColumn();
|
||||
|
||||
$offset = ($page - 1) * $limit;
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT id, source_type, company_name, person_name, contact_phone, contact_email,
|
||||
target_product_category, description, status, source_channel, recorded_by,
|
||||
follow_person, converted_type, converted_id, created_at, updated_at
|
||||
FROM preliminary_data
|
||||
WHERE $whereSql
|
||||
ORDER BY id DESC
|
||||
LIMIT $limit OFFSET $offset"
|
||||
);
|
||||
$stmt->execute($params);
|
||||
$rows = $stmt->fetchAll();
|
||||
|
||||
$list = [];
|
||||
foreach ($rows as $r) {
|
||||
$calc = hardCompleteness($r);
|
||||
$r['completeness'] = $calc['score'];
|
||||
$r['level'] = $calc['level'];
|
||||
$r['missing'] = $calc['missing'];
|
||||
$r['summary'] = hardSummary($r);
|
||||
$r['source_type_label'] = ['company' => '企业', 'person' => '人员', 'product' => '产品', 'need' => '需求', 'mixed' => '混合'][$r['source_type']] ?? $r['source_type'];
|
||||
$list[] = $r;
|
||||
}
|
||||
|
||||
Response::success(['list' => $list, 'total' => $total, 'page' => $page, 'limit' => $limit]);
|
||||
Reference in New Issue
Block a user