This commit is contained in:
杨志
2026-02-02 15:12:20 +08:00
parent 1db303e37d
commit b9b4e1b909
2 changed files with 34 additions and 48 deletions

View File

@@ -165,6 +165,37 @@ class CrawlerService
return $data ?: [];
}
/**
* 从职位树数据中收集可爬取的职位代码(排除 nocheck: true 的节点)
* 接口返回扁平数组 [ { CODE, TITLE, nocheck?, ... }, ... ]
* @param array $treeData getPositionTree 的返回值(可为裸数组或包装结构)
* @return string[]
*/
public function collectPositionCodesExcludingNocheck(array $treeData): array
{
$codes = [];
$nodes = $treeData;
if (isset($treeData['data']) && is_array($treeData['data'])) {
$nodes = $treeData['data'];
} elseif (isset($treeData['tree']) && is_array($treeData['tree'])) {
$nodes = $treeData['tree'];
}
foreach ($nodes as $item) {
if (!is_array($item)) {
continue;
}
// 有 nocheck 且为真true / "true" / 1则跳过避免把字符串 "false" 当真理
$nocheck = $item['nocheck'] ?? $item['noCheck'] ?? null;
if ($nocheck === true || $nocheck === 1 || (is_string($nocheck) && strtolower($nocheck) === 'true')) {
continue;
}
if (isset($item['CODE']) && $item['CODE'] !== '') {
$codes[] = $item['CODE'];
}
}
return $codes;
}
/**
* 获取职位详细信息
* @param string $zwdm 职位代码