v1.0.50: 碎片处理6项修改 - 1)硬数据板块改名为「硬数据碎片新增与处理」;2)硬数据彻底移除「状态」字段(查看弹窗/数据表status列/列表接口全部删除,已转换以converted_id非空标识,preliminary旧页同步清理);3)硬数据操作列「继续补全」改「手动补全」+新增「AI补全」占位;4)软数据操作列「补全」改「手动补全」+新增「AI补全」占位;5)硬数据「废弃」改为从preliminary_data彻底硬删除;6)人员性别枚举收敛为男/女/未知(迁移归并其他/保密)

This commit is contained in:
nanguaboss
2026-08-11 00:09:33 +08:00
parent 9f06ee1cd9
commit 69fd4246c2
15 changed files with 92 additions and 85 deletions
+3 -3
View File
@@ -4,7 +4,7 @@
* 入参:source_type(company|person|product|need|mixed,必填)/
* company_name / person_name / contact_phone / contact_email /
* target_product_category / description / source_channel
* 写入 preliminary_data,status=待处理,recorded_by=当前登录用户
* 写入 preliminary_data,recorded_by=当前登录用户(v1.0.50 起无 status 字段)
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
@@ -85,8 +85,8 @@ $pdo->prepare(
"INSERT INTO preliminary_data
(source_type, company_name, industry, registration_number, business_role, country, address,
person_name, contact_phone, contact_email, work_location, id_number, platform, account_id, profile_url,
source_channel, recorded_by, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '待处理')"
source_channel, recorded_by)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
)->execute([
$sourceType,
$companyName !== '' ? $companyName : null,
+11 -11
View File
@@ -31,8 +31,8 @@ $frag = $stmt->fetch();
if (!$frag) {
Response::error('碎片不存在');
}
if (in_array($frag['status'], ['已转换', '已废弃'], true)) {
Response::error('该碎片已处理(' . $frag['status'] . ')');
if ($frag['converted_id']) {
Response::error('该碎片已处理(已转换)');
}
$companyName = trim($_POST['company_name'] ?? ($frag['company_name'] ?? ''));
@@ -65,31 +65,31 @@ if ($profileUrl !== '' && !preg_match('/^https?:\/\//i', $profileUrl)) {
switch ($targetType) {
case 'company':
if ($companyName === '') {
Response::error('企业类型转软碎片:企业名称为必填项,请先「继续补全」', 400);
Response::error('企业类型转软碎片:企业名称为必填项,请先「手动补全」', 400);
}
if ($industry === '') {
Response::error('企业类型转软碎片:行业为必填项,请先「继续补全」填写行业', 400);
Response::error('企业类型转软碎片:行业为必填项,请先「手动补全」填写行业', 400);
}
if ($registrationNum === '') {
Response::error('企业类型转软碎片:注册号为必填项,请先「继续补全」填写注册号', 400);
Response::error('企业类型转软碎片:注册号为必填项,请先「手动补全」填写注册号', 400);
}
break;
case 'person':
if ($personName === '') {
Response::error('人员类型转软碎片:姓名为必填项,请先「继续补全」', 400);
Response::error('人员类型转软碎片:姓名为必填项,请先「手动补全」', 400);
}
if ($phone === '' && $email === '') {
Response::error('人员类型转软碎片:手机号码、邮箱至少填写一项,请先「继续补全」', 400);
Response::error('人员类型转软碎片:手机号码、邮箱至少填写一项,请先「手动补全」', 400);
}
break;
case 'product':
if ($companyName === '') {
Response::error('产品类型转软碎片:公司名称为必填项,请先「继续补全」', 400);
Response::error('产品类型转软碎片:公司名称为必填项,请先「手动补全」', 400);
}
break;
case 'need':
if ($companyName === '') {
Response::error('需求类型转软碎片:公司名称为必填项,请先「继续补全」', 400);
Response::error('需求类型转软碎片:公司名称为必填项,请先「手动补全」', 400);
}
break;
}
@@ -215,9 +215,9 @@ switch ($targetType) {
break;
}
// 标记碎片已转换
// 标记碎片已转换(v1.0.50 起不再写 status 字段,以 converted_id 非空标识已转换)
$pdo->prepare(
"UPDATE preliminary_data SET status = '已转换', converted_type = ?, converted_id = ?, processed_at = NOW() WHERE id = ?"
"UPDATE preliminary_data SET converted_type = ?, converted_id = ?, processed_at = NOW() WHERE id = ?"
)->execute([$targetType, $convertedId, $id]);
logCurrent('convert', 'fragment', 'preliminary_data', $id, [
+7 -5
View File
@@ -2,6 +2,7 @@
/**
* 硬碎片废弃接口 POST /api/fragment/hard_discard.php
* 入参:id
* v1.0.50:废弃改为从 preliminary_data 彻底硬删除(不再保留记录)
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
@@ -17,17 +18,18 @@ if ($id <= 0) {
}
$pdo = DB::getInstance()->getPdo();
$stmt = $pdo->prepare("SELECT id, status FROM preliminary_data WHERE id = ? AND is_active = 1");
$stmt = $pdo->prepare("SELECT id, converted_id FROM preliminary_data WHERE id = ? AND is_active = 1");
$stmt->execute([$id]);
$frag = $stmt->fetch();
if (!$frag) {
Response::error('碎片不存在');
}
if (in_array($frag['status'], ['已转换', '已废弃'], true)) {
Response::error('该碎片已处理(' . $frag['status'] . ')');
if ($frag['converted_id']) {
Response::error('该碎片已转换,不可废弃');
}
$pdo->prepare("UPDATE preliminary_data SET status = '已废弃', processed_at = NOW() WHERE id = ?")->execute([$id]);
// 彻底硬删除(v1.0.50 起废弃不再保留记录)
$pdo->prepare("DELETE FROM preliminary_data WHERE id = ?")->execute([$id]);
logCurrent('discard', 'fragment', 'preliminary_data', $id, ['status' => '已废弃']);
logCurrent('discard', 'fragment', 'preliminary_data', $id, ['action' => 'hard_delete']);
Response::success(null, '已废弃');
+4 -5
View File
@@ -1,8 +1,9 @@
<?php
/**
* 硬碎片列表接口 GET /api/fragment/hard_list.php
* 参数:page / limit / source_type / status / source_channel / keyword
* 参数:page / limit / source_type / source_channel / keyword
* 返回:{ list, total, page, limit },每行含完整度 score、缺失层级、内容摘要
* 说明:v1.0.50 起移除 status 字段(查看弹窗/数据表均不再展示状态),列表仅返回未转换(converted_id IS NULL)记录
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
@@ -13,18 +14,16 @@ 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 ('已转换','已废弃')"];
$where = ["is_active = 1", "converted_id IS NULL"];
$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);
@@ -39,7 +38,7 @@ $offset = ($page - 1) * $limit;
$stmt = $pdo->prepare(
"SELECT id, source_type, company_name, industry, registration_number, business_role, country, address,
person_name, contact_phone, contact_email, work_location, id_number, platform, account_id, profile_url,
status, source_channel, recorded_by,
source_channel, recorded_by,
follow_person, converted_type, converted_id, created_at, updated_at
FROM preliminary_data
WHERE $whereSql
+2 -2
View File
@@ -26,8 +26,8 @@ $frag = $stmt->fetch();
if (!$frag) {
Response::error('碎片不存在');
}
if (in_array($frag['status'], ['已转换', '已废弃'], true)) {
Response::error('该碎片已处理(' . $frag['status'] . ')');
if ($frag['converted_id']) {
Response::error('该碎片已处理(已转换)');
}
$sourceType = trim($_POST['source_type'] ?? ($frag['source_type'] ?? ''));
+6 -5
View File
@@ -2,12 +2,13 @@
/**
* 碎片处理中心 - 顶部概览接口 GET /api/fragment/stats_overview.php
* 指标:
* - hard_total 硬碎片待处理数(preliminary_data 未终结)
* - hard_total 硬碎片待处理数(preliminary_data 未转换)
* - soft_total 软碎片待处理数(四主表 is_incomplete=1)
* - month_new 本月新增(硬碎片本月新增 + 软碎片本月新增)
* - month_processed 本月处理(本月已转换硬碎片 + 本月已补全软碎片)
* - cumulative 累计处理(历史已转换硬碎片 + 历史已补全软碎片)
* - pending 待处理碎片(硬待处理 + 软待处理)
* 说明:v1.0.50 起 preliminary_data 无 status 字段,已转换以 converted_id 非空标识
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
@@ -18,9 +19,9 @@ checkPermission('preliminary');
$pdo = DB::getInstance()->getPdo();
$monthStart = "DATE_FORMAT(CURDATE(), '%Y-%m-01')";
// 硬碎片待处理数
// 硬碎片待处理数(未转换)
$hardTotal = (int)$pdo->query(
"SELECT COUNT(*) FROM preliminary_data WHERE is_active = 1 AND status NOT IN ('已转换','已废弃')"
"SELECT COUNT(*) FROM preliminary_data WHERE is_active = 1 AND converted_id IS NULL"
)->fetchColumn();
// 软碎片待处理数(四主表 is_incomplete=1 之和)
@@ -50,7 +51,7 @@ $softMonthNew += (int)$pdo->query(
// 本月已转换硬碎片
$hardConvertedMonth = (int)$pdo->query(
"SELECT COUNT(*) FROM preliminary_data
WHERE is_active = 1 AND status = '已转换' AND processed_at >= $monthStart"
WHERE is_active = 1 AND converted_id IS NOT NULL AND processed_at >= $monthStart"
)->fetchColumn();
// 本月已补全软碎片(fragment 模块 complete 日志)
@@ -60,7 +61,7 @@ $softCompletedMonth = (int)$pdo->query(
// 历史累计已转换硬碎片
$hardConvertedTotal = (int)$pdo->query(
"SELECT COUNT(*) FROM preliminary_data WHERE is_active = 1 AND status = '已转换'"
"SELECT COUNT(*) FROM preliminary_data WHERE is_active = 1 AND converted_id IS NOT NULL"
)->fetchColumn();
// 历史累计已补全软碎片