v1.0.29: 碎片处理按dp方案2修订 - 完整度改三层独立判定(核心100%/重要60%/非必要40%,任一不达标即碎片)+字段分层调整(persons email升核心,companies核心扩5字段)+指标卡5张(新增累计处理,本月/累计=硬+软合计)+软碎片列表加各层完整度列+硬碎片完整度改已填/总可填
This commit is contained in:
@@ -1,45 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* 硬碎片公共逻辑:字段分层 / 完整度计算 / 内容摘要
|
||||
* 硬碎片公共逻辑:完整度计算(按非空字段直接计数)+ 内容摘要
|
||||
* 被 hard_list.php 与 hard_detail.php 共用
|
||||
*/
|
||||
|
||||
/** 硬碎片字段分层(按 source_type) */
|
||||
const HARD_LAYERS = [
|
||||
'company' => ['core' => ['company_name', 'contact_phone'], 'important' => ['contact_email'], 'supplementary' => ['person_name', 'description', 'target_product_category']],
|
||||
'person' => ['core' => ['person_name', 'contact_phone'], 'important' => ['contact_email'], 'supplementary' => ['company_name', 'description', 'target_product_category']],
|
||||
'product' => ['core' => ['company_name', 'target_product_category'], 'important' => ['contact_phone', 'contact_email'], 'supplementary' => ['person_name', 'description']],
|
||||
'need' => ['core' => ['company_name', 'target_product_category'], 'important' => ['contact_phone', 'contact_email'], 'supplementary' => ['person_name', 'description']],
|
||||
'mixed' => ['core' => ['company_name', 'person_name'], 'important' => ['contact_phone', 'contact_email'], 'supplementary' => ['description', 'target_product_category']],
|
||||
];
|
||||
/** 硬碎片可统计字段(公司名/联系人/电话/邮箱/品类/描述) */
|
||||
const HARD_FIELDS = ['company_name', 'person_name', 'contact_phone', 'contact_email', 'target_product_category', 'description'];
|
||||
const HARD_LABELS = [
|
||||
'company_name' => '公司名称', 'person_name' => '联系人', 'contact_phone' => '电话',
|
||||
'contact_email' => '邮箱', 'target_product_category' => '产品品类', 'description' => '描述',
|
||||
];
|
||||
|
||||
/** 计算硬碎片完整度与缺失层级 */
|
||||
/** 计算硬碎片完整度:已填字段数 ÷ 总可填字段数 × 100% */
|
||||
function hardCompleteness($row)
|
||||
{
|
||||
$layers = HARD_LAYERS[$row['source_type']] ?? HARD_LAYERS['mixed'];
|
||||
$missing = ['core' => [], 'important' => [], 'supplementary' => []];
|
||||
foreach (['core', 'important', 'supplementary'] as $layer) {
|
||||
foreach ($layers[$layer] as $field) {
|
||||
if ($row[$field] === null || trim((string)$row[$field]) === '') {
|
||||
$missing[$layer][] = $field;
|
||||
}
|
||||
$filled = 0;
|
||||
$missing = [];
|
||||
foreach (HARD_FIELDS as $field) {
|
||||
if ($row[$field] !== null && trim((string)$row[$field]) !== '') {
|
||||
$filled++;
|
||||
} else {
|
||||
$missing[] = $field;
|
||||
}
|
||||
}
|
||||
$score = 100 - count($missing['core']) * 20 - count($missing['important']) * 8 - count($missing['supplementary']) * 2;
|
||||
$score = max(0, $score);
|
||||
$level = 'complete';
|
||||
if (!empty($missing['core'])) {
|
||||
$level = 'core';
|
||||
} elseif (!empty($missing['important'])) {
|
||||
$level = 'important';
|
||||
} elseif (!empty($missing['supplementary'])) {
|
||||
$level = 'supplementary';
|
||||
}
|
||||
return ['score' => $score, 'level' => $level, 'missing' => $missing];
|
||||
$total = count(HARD_FIELDS);
|
||||
$score = $total > 0 ? (int)round($filled / $total * 100) : 0;
|
||||
return ['score' => $score, 'missing' => $missing];
|
||||
}
|
||||
|
||||
/** 内容摘要:拼接已有关键信息 */
|
||||
|
||||
Reference in New Issue
Block a user