|
|
|
|
@ -59,6 +59,7 @@ class UpdateUserTalentTags extends Command
|
|
|
|
|
$errorCount = 0;
|
|
|
|
|
$skippedCount = 0;
|
|
|
|
|
$notFoundUsers = []; // 收集所有未匹配上的用户信息
|
|
|
|
|
$skippedData = []; // 收集所有被跳过的数据信息
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
|
|
|
|
@ -79,6 +80,13 @@ class UpdateUserTalentTags extends Command
|
|
|
|
|
if (empty($courseNameRaw)) {
|
|
|
|
|
$this->warn("第 {$rowNum} 行: 课程名称为空,跳过");
|
|
|
|
|
$skippedCount++;
|
|
|
|
|
$skippedData[] = [
|
|
|
|
|
'row' => $rowNum,
|
|
|
|
|
'reason' => '课程名称为空',
|
|
|
|
|
'name' => $userName ?? '',
|
|
|
|
|
'course' => '',
|
|
|
|
|
'talent_tag' => $talentTag ?? '',
|
|
|
|
|
];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -93,12 +101,26 @@ class UpdateUserTalentTags extends Command
|
|
|
|
|
if (empty($userName)) {
|
|
|
|
|
$this->warn("第 {$rowNum} 行: 姓名为空,跳过");
|
|
|
|
|
$skippedCount++;
|
|
|
|
|
$skippedData[] = [
|
|
|
|
|
'row' => $rowNum,
|
|
|
|
|
'reason' => '姓名为空',
|
|
|
|
|
'name' => '',
|
|
|
|
|
'course' => $courseNameRaw,
|
|
|
|
|
'talent_tag' => $talentTag ?? '',
|
|
|
|
|
];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($talentTag)) {
|
|
|
|
|
$this->warn("第 {$rowNum} 行: 人才标签为空,跳过");
|
|
|
|
|
$skippedCount++;
|
|
|
|
|
$skippedData[] = [
|
|
|
|
|
'row' => $rowNum,
|
|
|
|
|
'reason' => '人才标签为空',
|
|
|
|
|
'name' => $userName,
|
|
|
|
|
'course' => $courseNameRaw,
|
|
|
|
|
'talent_tag' => '',
|
|
|
|
|
];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -181,6 +203,15 @@ class UpdateUserTalentTags extends Command
|
|
|
|
|
$this->info("第 {$rowNum} 行: 用户 '{$userName}' (ID: {$user->id}) 已存在标签 '{$talentTag}',跳过");
|
|
|
|
|
$this->info(" 当前人才标签: {$oldTalentTagsDisplay}");
|
|
|
|
|
$skippedCount++;
|
|
|
|
|
$skippedData[] = [
|
|
|
|
|
'row' => $rowNum,
|
|
|
|
|
'reason' => '标签已存在',
|
|
|
|
|
'name' => $userName,
|
|
|
|
|
'course' => $courseNameRaw,
|
|
|
|
|
'talent_tag' => $talentTag,
|
|
|
|
|
'user_id' => $user->id,
|
|
|
|
|
'current_tags' => $oldTalentTagsDisplay,
|
|
|
|
|
];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -202,6 +233,14 @@ class UpdateUserTalentTags extends Command
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$this->error("第 {$rowNum} 行: 更新用户 '{$userName}' 失败: " . $e->getMessage());
|
|
|
|
|
$errorCount++;
|
|
|
|
|
$skippedData[] = [
|
|
|
|
|
'row' => $rowNum,
|
|
|
|
|
'reason' => '更新失败: ' . $e->getMessage(),
|
|
|
|
|
'name' => $userName,
|
|
|
|
|
'course' => $courseNameRaw,
|
|
|
|
|
'talent_tag' => $talentTag,
|
|
|
|
|
'user_id' => $user->id ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -216,7 +255,7 @@ class UpdateUserTalentTags extends Command
|
|
|
|
|
$this->info("跳过(已存在/空数据): {$skippedCount} 条");
|
|
|
|
|
$this->info("更新失败: {$errorCount} 条");
|
|
|
|
|
$this->info('========================================');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 输出所有未匹配上的用户列表
|
|
|
|
|
if (!empty($notFoundUsers)) {
|
|
|
|
|
$this->info('');
|
|
|
|
|
@ -230,6 +269,30 @@ class UpdateUserTalentTags extends Command
|
|
|
|
|
$this->info("共 {$notFoundCount} 个用户未匹配上");
|
|
|
|
|
$this->info('========================================');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 输出所有被跳过的数据详情
|
|
|
|
|
if (!empty($skippedData)) {
|
|
|
|
|
$this->info('');
|
|
|
|
|
$this->info('========================================');
|
|
|
|
|
$this->info('被跳过的数据详情:');
|
|
|
|
|
$this->info('========================================');
|
|
|
|
|
foreach ($skippedData as $skipped) {
|
|
|
|
|
$this->warn("第 {$skipped['row']} 行: {$skipped['reason']}");
|
|
|
|
|
$this->warn(" 姓名: " . ($skipped['name'] ?: '(空)'));
|
|
|
|
|
$this->warn(" 课程: " . ($skipped['course'] ?: '(空)'));
|
|
|
|
|
$this->warn(" 人才标签: " . ($skipped['talent_tag'] ?: '(空)'));
|
|
|
|
|
if (isset($skipped['user_id']) && !empty($skipped['user_id'])) {
|
|
|
|
|
$this->warn(" 用户ID: {$skipped['user_id']}");
|
|
|
|
|
}
|
|
|
|
|
if (isset($skipped['current_tags']) && !empty($skipped['current_tags'])) {
|
|
|
|
|
$this->warn(" 当前标签: {$skipped['current_tags']}");
|
|
|
|
|
}
|
|
|
|
|
$this->info('');
|
|
|
|
|
}
|
|
|
|
|
$this->info('========================================');
|
|
|
|
|
$this->info("共 {$skippedCount} 条数据被跳过");
|
|
|
|
|
$this->info('========================================');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|