// Use the subject of the authenticated test session, never the first candidate // or IAM membership ID. Server-side warehouse and assignment checks remain authoritative. export function selectSessionPdaOperator(operators, token) { let subject try { subject = JSON.parse(Buffer.from(token.split('.')[1], 'base64url').toString('utf8')).sub } catch { throw new Error('国内 PDA 验收缺少有效登录身份') } if (typeof subject !== 'string' || !/^[1-9]\d*$/.test(subject)) { throw new Error('国内 PDA 登录身份必须包含字符串用户编号') } const rows = Array.isArray(operators) ? operators : operators?.records || [] const operator = rows.find((item) => String(item.userId) === subject) if (!operator) throw new Error('当前登录 PDA 作业员不在目标仓库候选中,停止分配任务') return operator }