weaver-work-cli 0.1.45 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{attachment-content-CE3GMWTS.js → attachment-content-MCXQBD6N.js} +3 -3
- package/dist/chunks/{chunk-VIMCY4DI.js → chunk-4RWS2YYL.js} +2 -2
- package/dist/chunks/{chunk-4EXOIQDI.js → chunk-6AXKWFKG.js} +4 -14
- package/dist/chunks/{chunk-JWWTI63L.js → chunk-6V5ZPKHV.js} +2 -8
- package/dist/chunks/{chunk-3ZMAQQ3W.js → chunk-76H3IKH6.js} +39 -26
- package/dist/chunks/{chunk-LGKWL4OH.js → chunk-AD46OMQK.js} +86 -25
- package/dist/chunks/{chunk-3WBIQLMB.js → chunk-GSZTA43P.js} +2 -2
- package/dist/chunks/{chunk-OAE3AZBQ.js → chunk-IP4CWQCF.js} +6 -6
- package/dist/chunks/{chunk-77YP6I52.js → chunk-IRMIEDXN.js} +1 -1
- package/dist/chunks/{chunk-LRCPNDZA.js → chunk-J2VEB5K3.js} +11 -9
- package/dist/chunks/{chunk-T4MWQAQB.js → chunk-JFAWZX53.js} +128 -9
- package/dist/chunks/{chunk-GR76ZDDX.js → chunk-LIEQJIGM.js} +3 -0
- package/dist/chunks/{chunk-DGMYACGJ.js → chunk-OXHHJWNC.js} +1 -1
- package/dist/chunks/{chunk-LXFVWZLM.js → chunk-PSOMGA3U.js} +3 -3
- package/dist/chunks/{conflict-IYJETSGT.js → conflict-H7EHQXYY.js} +2 -2
- package/dist/chunks/{create-flow-7JLC7UID.js → create-flow-VRVJEOBX.js} +6 -6
- package/dist/chunks/{ehr-MYRDCHZ4.js → ehr-SH2LM3NK.js} +528 -40
- package/dist/chunks/{env-3MBHAWBL.js → env-66FPSJDV.js} +2 -2
- package/dist/chunks/{factory-TZEVU4DU.js → factory-UH2TZBVA.js} +1 -1
- package/dist/chunks/{group-chat-KL3HFKRM.js → group-chat-CAKMMV7K.js} +3 -3
- package/dist/chunks/{invoice-OQP3TMKQ.js → invoice-UEAHSYAE.js} +279 -1
- package/dist/chunks/{lazy-dispatch-UH6HGK2I.js → lazy-dispatch-25XGTXLM.js} +2 -2
- package/dist/chunks/{meeting-C67EHQ4Z.js → meeting-VTBFW4HI.js} +10 -10
- package/dist/chunks/{recruit-stage-AHY5QAMF.js → recruit-stage-CAKZTUA7.js} +917 -85
- package/dist/chunks/{registry-XPWPGHYE.js → registry-JVQBLFQ5.js} +10 -10
- package/dist/chunks/{room-recommend-CNWE5WQK.js → room-recommend-5U55FMXZ.js} +4 -4
- package/dist/chunks/{schedule-YYNYBQIE.js → schedule-IDETODCA.js} +4 -4
- package/dist/cmd/action.js +14 -10
- package/dist/index.js +7 -7
- package/dist/shortcuts/ehr/host.js +2 -2
- package/dist/shortcuts/ehr/index.js +14 -3
- package/dist/shortcuts/ehr/manifest.js +5 -1
- package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +40 -10
- package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +258 -0
- package/dist/shortcuts/ehr/operations/recruit-position.js +10 -8
- package/dist/shortcuts/ehr/operations/recruit-stats.js +14 -1
- package/dist/shortcuts/ehr/operations/recruit-tag.js +173 -0
- package/dist/shortcuts/ehr/operations/recruit-write.js +137 -18
- package/dist/shortcuts/ehr/operations/recruit.js +180 -8
- package/dist/shortcuts/ehr/operations/registry.js +4 -0
- package/dist/shortcuts/ehr/operations.js +24 -0
- package/dist/shortcuts/ehr/recruit-stage/batch-store.js +78 -0
- package/dist/shortcuts/ehr/recruit-stage/context.js +231 -0
- package/dist/shortcuts/ehr/recruit-stage/continuation.js +74 -0
- package/dist/shortcuts/ehr/recruit-stage/errors.js +65 -0
- package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +165 -0
- package/dist/shortcuts/ehr/recruit-stage/host.js +109 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +1049 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +295 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +961 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/list.js +431 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +50 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +1647 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/search.js +158 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/types.js +34 -0
- package/dist/shortcuts/ehr/recruit-stage/runtime.js +31 -0
- package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +318 -0
- package/dist/shortcuts/ehr/recruit-stage/shared.js +805 -0
- package/dist/shortcuts/invoice/host.js +3 -0
- package/dist/shortcuts/invoice/manifest.js +61 -0
- package/dist/shortcuts/invoice/operations/registry.js +2 -0
- package/dist/shortcuts/invoice/operations/reim-subsidy.js +233 -0
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +93 -18
- package/dist/shortcuts/meeting/operations/eb/factory.js +5 -8
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +2 -13
- package/dist/shortcuts/meeting/operations/invitation.js +27 -4
- package/dist/shortcuts/recruit-stage/batch-store.js +78 -0
- package/dist/shortcuts/recruit-stage/fs-scan.js +165 -0
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +277 -20
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +31 -7
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +106 -16
- package/dist/shortcuts/recruit-stage/operations/registry.js +12 -0
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +273 -6
- package/dist/shortcuts/recruit-stage/operations/types.js +9 -0
- package/dist/shortcuts/recruit-stage/shared.js +60 -6
- package/docs/invoice.md +1 -0
- package/package.json +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +2 -2
- package/skills/weaver-e10-jucailin/SKILL.md +12 -3
- package/skills/weaver-e10-jucailin/archive/LEGACY-README.md +18 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-SKILL.md +239 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-openai.yaml +131 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-position-templates.md +221 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +334 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +127 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +65 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +63 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +142 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +114 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +56 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +101 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +148 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +77 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +72 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +69 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +241 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +457 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +128 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +146 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +69 -0
- package/skills/weaver-e10-jucailin/lib/recruit-xiaoe-file.mjs +192 -0
- package/skills/weaver-e10-jucailin/lib/xiaoe-session.mjs +66 -0
- package/skills/weaver-e10-jucailin/references/recruit-create.md +19 -93
- package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +64 -0
- package/skills/weaver-e10-jucailin/references/recruit-read.md +63 -1
- package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +95 -0
- package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +89 -0
- package/skills/weaver-e10-jucailin/references/recruit-tag.md +81 -0
- package/skills/weaver-e10-jucailin/references/recruit-write.md +53 -9
- package/skills/weaver-e10-meeting/SKILL.md +48 -4
- package/skills/weaver-e10-meeting/references/meeting-eb.md +1 -1
- package/skills/weaver-e10-recruit-stage/SKILL.md +8 -5
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +16 -6
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +5 -1
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +20 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +21 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +4 -0
- package/skills/weaver-e10-yepiaotong/SKILL.md +7 -5
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +9 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +68 -6
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +3 -3
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +8 -15
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +6 -5
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +206 -92
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +26 -21
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +35 -0
|
@@ -0,0 +1,1049 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ehr.recruit.stage.interview.arrange.* —— 安排面试(自 recruit-arrange-interview.mjs 1:1 移植)
|
|
3
|
+
*
|
|
4
|
+
* 页面「保存」实际执行的是按钮配置里的一串动作(HAR 实证,跨环境由 getFormButtons 运行时解析):
|
|
5
|
+
* ① 系统保存(saveFormData)→ ② esb(如「面试管理-新建日程」)→ ③ jsCode 调 assignedInterview
|
|
6
|
+
* → ④ esb(如「AI面试时发送提醒」)
|
|
7
|
+
* 本模块按同一顺序逐条执行,不写死任何按钮/动作 id;不认识的脚本动作跳过并在 warnings 明示。
|
|
8
|
+
*
|
|
9
|
+
* 三种操作:
|
|
10
|
+
* .prepare 只出确认摘要(含将执行的动作清单 + AI 面试候选方案),签发 continuation
|
|
11
|
+
* .apply 用户确认后执行(confirm + continuation + 指纹比对;AI 面试方案必填未选时阻断)
|
|
12
|
+
* .prefill 不落库:输出「人才卡片 URL + 面试管理列表 URL + jsExpr」;Agent 打开人才卡片 →
|
|
13
|
+
* (点「安排面试」打开表单)→ 执行 jsExpr 选中「面试方式=AI面试」→ 触发表单联动 → HR 核对保存
|
|
14
|
+
*
|
|
15
|
+
* 定位候选人(三选一,未带 talentId 时生效):mobile(人才库精确检索,唯一命中自动采用)/
|
|
16
|
+
* name(多条 → needChoice 输出候选让用户选,绝不自动挑一个)。
|
|
17
|
+
*
|
|
18
|
+
* AI 面试(type 含 AI/人工智能)时,邮箱与 AI 面试方案(digital_id)均为必填:
|
|
19
|
+
* 未指定方案时 prepare 输出 aiPlans 候选清单(关联字段候选接口 → 「面试数字人配置」列表兜底,
|
|
20
|
+
* objId 走 tag、listId 走菜单,均运行时解析),apply 直接阻断;绝不自动取第一条。
|
|
21
|
+
*/
|
|
22
|
+
import { randomUUID } from 'node:crypto';
|
|
23
|
+
import { rsSuccess, schemaOf } from './types.js';
|
|
24
|
+
import { rsFail, rsValidationError, rsConfirmationError } from '../errors.js';
|
|
25
|
+
import { objIdOf, formIdOf, getFormLayout, getFormLayoutMeta, saveFormData, runEsb, getFormButtons, resolvePersonId, getDsOptions, findMenuNode, resolveCurrentUser, buildCardUrl, buildListUrl, talentLinkExtra, pickSaveButtonActions, computeRequiredHint, randHex32, dsOptionsSnapshot, restoreDsOptions, invalidateEnvCache, verifySubmitted, expectedFields, probeCreatePermission, } from '../shared.js';
|
|
26
|
+
// 面试计划表单字段 dataKey(缓存 fields 里取)。
|
|
27
|
+
// 注意:digital_id 不放入此列表——它只在「面试方式含 AI」时才是必填,
|
|
28
|
+
// 放进来会让未部署数字人的环境连非 AI 面试都建不了(单独按需校验)。
|
|
29
|
+
const DATAKEYS = ['subject', 'start_time', 'end_time', 'interview_type', 'interview_session', 'interviewer',
|
|
30
|
+
'position_manage_id', 'talent_id', 'candidate_manage_id', 'mobile', 'email', 'interview_location', 'notice_mould'];
|
|
31
|
+
// 面试计划常用字段中文名(仅用于把联动必填结果说人话;字段 id 一律运行时解析)
|
|
32
|
+
const FIELD_LABELS = {
|
|
33
|
+
subject: '面试主题', start_time: '开始时间', end_time: '结束时间', interview_type: '面试方式',
|
|
34
|
+
interview_session: '面试轮次', interviewer: '面试官', position_manage_id: '应聘职位',
|
|
35
|
+
talent_id: '人才', candidate_manage_id: '应聘管理', mobile: '手机', email: '邮箱',
|
|
36
|
+
digital_id: 'AI面试方案', interview_paper_id: '面试试卷', send_channel: '发送渠道',
|
|
37
|
+
notice_mould: '通知模板', affiliate_schedule: '关联日程', union_status: '状态',
|
|
38
|
+
interview_location: '面试地点',
|
|
39
|
+
};
|
|
40
|
+
const labelOf = (k) => (FIELD_LABELS[k] ? FIELD_LABELS[k] + '(' + k + ')' : k);
|
|
41
|
+
const ASSIGNED_API_RE = /\/api\/recruit\/candidate\/assignedInterview/;
|
|
42
|
+
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
43
|
+
async function resolveCandidate(ctx, talentId) {
|
|
44
|
+
const { host, cache } = ctx;
|
|
45
|
+
const extra = { ebBusinessId: cache.lists?.talent?.listId || '' };
|
|
46
|
+
const hr = await host.request({ path: '/api/recruit/talent/hasRights?formDataId=' + talentId, method: 'POST', headers: extra });
|
|
47
|
+
if (!(hr?.data || []).includes('READ'))
|
|
48
|
+
throw rsFail('无 READ 权限');
|
|
49
|
+
const r1 = randHex32().slice(0, 6);
|
|
50
|
+
const pq = await host.request({ path: '/api/recruit/candidate/getCandidateCardPrepareQuery?talentId=' + talentId + '&randomkey_' + r1 + '=' + r1, method: 'GET', headers: extra });
|
|
51
|
+
const batchId = pq?.data?.batchId;
|
|
52
|
+
const v = randHex32().slice(0, 6);
|
|
53
|
+
// otherInfo 与 baseInfo 只依赖 batchId、互不引用 → 并行(省 1 RTT)。
|
|
54
|
+
// 两者都是只读 GET;失败时 Promise.all 抛第一个错,行为与串行等价(仅多一个无害请求)。
|
|
55
|
+
const [o, b2] = await Promise.all([
|
|
56
|
+
host.request({ path: '/api/recruit/candidate/getCandidateCardOtherInfo?talentId=' + talentId + '&batchId=' + batchId + '&v=' + v + '&randomkey_ab=ab', method: 'GET', headers: extra }),
|
|
57
|
+
host.request({ path: '/api/recruit/candidate/getCandidateCardBaseInfo?talentId=' + talentId + '&batchId=' + batchId + '&v=' + v + '&randomkey_cd=cd', method: 'GET', headers: extra }),
|
|
58
|
+
]);
|
|
59
|
+
const b = o?.data?.currentCandidateBatch || {};
|
|
60
|
+
let name = b?.talent?.name;
|
|
61
|
+
// 手机号/邮箱必须显式取:页面是「按 talent_id 联动带出」,直接调 saveFormData 不会触发联动,
|
|
62
|
+
// 不写就会落空(AI面试要求邮箱必填)。取 BaseInfo 的 talent.telephone / talent.email。
|
|
63
|
+
let mobile = '';
|
|
64
|
+
let email = '';
|
|
65
|
+
const tb = b2?.data?.talent || {};
|
|
66
|
+
if (!name)
|
|
67
|
+
name = tb.hrm?.name || tb.name;
|
|
68
|
+
mobile = String(tb.telephone || tb.mobile || '').trim();
|
|
69
|
+
email = String(tb.email || '').trim();
|
|
70
|
+
return {
|
|
71
|
+
talentId,
|
|
72
|
+
name,
|
|
73
|
+
mobile,
|
|
74
|
+
email,
|
|
75
|
+
candidateManageId: b?.id || b?.candidateManageId || null,
|
|
76
|
+
positionId: b?.position?.id || null,
|
|
77
|
+
positionName: b?.position?.name,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// 候选人定位:mobile/name → talentId(人才库列表检索)。手机号优先且命中唯一即采用;
|
|
81
|
+
// 姓名可能多条 → 返回 candidates 由用户选择(绝不自动挑一个)。
|
|
82
|
+
async function locateTalent(ctx, opts) {
|
|
83
|
+
const { host, cache } = ctx;
|
|
84
|
+
const listId = cache.lists?.talent?.listId;
|
|
85
|
+
const objId = cache.forms?.talent_pool?.objId;
|
|
86
|
+
if (!listId || !objId)
|
|
87
|
+
throw rsFail('环境缓存缺少人才列表(lists.talent / forms.talent_pool)');
|
|
88
|
+
const fields = cache.fields[objId] || {};
|
|
89
|
+
const nameKey = fields.candidate_name || fields.name;
|
|
90
|
+
if (opts.mobile && !fields.telephone)
|
|
91
|
+
throw rsFail('环境缓存缺少人才手机字段(telephone)');
|
|
92
|
+
if (!opts.mobile && opts.name && !nameKey)
|
|
93
|
+
throw rsFail('环境缓存缺少人才姓名字段(candidate_name/name)');
|
|
94
|
+
const conds = {};
|
|
95
|
+
if (opts.mobile) {
|
|
96
|
+
const mf = 'field_' + fields.telephone;
|
|
97
|
+
conds[mf] = [{ [mf]: opts.mobile, [mf + '_condition_type']: 'like' }];
|
|
98
|
+
}
|
|
99
|
+
if (opts.name && !opts.mobile) {
|
|
100
|
+
const nf = 'field_' + nameKey;
|
|
101
|
+
conds[nf] = [{ [nf]: opts.name, [nf + '_condition_type']: 'like' }];
|
|
102
|
+
}
|
|
103
|
+
const body = {
|
|
104
|
+
current: 1, pageSize: 20, tableuid: randHex32(),
|
|
105
|
+
listId,
|
|
106
|
+
searchParamData: { searchType: '3', commonSearchFields: conds, type: 'and' },
|
|
107
|
+
terminal: 'PC', browser: 'Chrome', requiredMatch: 1, mapResult: 1, recheckQuery: 1,
|
|
108
|
+
isFollow: 0, isShareToMe: 0, filterCondition: {},
|
|
109
|
+
cusMenuId: cache.lists.talent.cusMenuId, urlPageTitle: '人才库',
|
|
110
|
+
menuName: cache.lists.talent.menuName || '人才管理',
|
|
111
|
+
};
|
|
112
|
+
const r = await host.request({
|
|
113
|
+
path: '/api/ebuilder/form/list/getListDatas?passid=' + objId + '&cid=' + objId,
|
|
114
|
+
body, headers: { ebBusinessId: listId },
|
|
115
|
+
});
|
|
116
|
+
const disp = r?.data?.displayData;
|
|
117
|
+
const raw = r?.data?.data || [];
|
|
118
|
+
const rows = Array.isArray(disp) && disp.length ? disp : raw;
|
|
119
|
+
return rows.map((x) => ({
|
|
120
|
+
talentId: x.form_data_id || x.id || null,
|
|
121
|
+
name: x.candidate_name || x.name || null,
|
|
122
|
+
mobile: x.telephone || null,
|
|
123
|
+
position: x.position_manage_id || x.position || null,
|
|
124
|
+
recruitStatus: x.recruit_status || null,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
// ── AI 面试方案(面试数字人配置表):objId 走 tag、listId 走菜单,全部运行时解析 ──
|
|
128
|
+
const PLAN_NAME_KEYS = ['msfa_name', 'digital_name', 'plan_name', 'scheme_name'];
|
|
129
|
+
function digitalMenuOf(cache) {
|
|
130
|
+
const hit = cache.digitalHumanMenu;
|
|
131
|
+
if (hit?.listId)
|
|
132
|
+
return hit;
|
|
133
|
+
const menus = cache.lists?.all_search || cache.menus || [];
|
|
134
|
+
return menus.find((m) => (m.menuName || '').includes('面试数字人'))
|
|
135
|
+
|| menus.find((m) => (m.menuName || '').includes('数字人配置'))
|
|
136
|
+
|| null;
|
|
137
|
+
}
|
|
138
|
+
async function digitalObjIdOf(ctx) {
|
|
139
|
+
const cached = ctx.cache.forms?.digital_human?.objId;
|
|
140
|
+
if (cached)
|
|
141
|
+
return String(cached);
|
|
142
|
+
const r = await ctx.host.request({ path: '/api/ebuilder/form/obj/getObjsByTag?appId=' + ctx.appId + '&tag=uf_rcrt_digital_human', method: 'GET' });
|
|
143
|
+
const d = r?.data;
|
|
144
|
+
return Array.isArray(d) && d.length ? String(d[0].id || '') : '';
|
|
145
|
+
}
|
|
146
|
+
// AI 面试方案候选:优先走「关联字段候选项」接口(不依赖菜单/列表,标准包未配菜单也可用),
|
|
147
|
+
// 失败再回退「面试数字人配置」列表。两种都不写死任何 id。
|
|
148
|
+
async function listDigitalPlans(opts) {
|
|
149
|
+
const { ctx, formId, layoutId, fieldId } = opts;
|
|
150
|
+
const { host, cache } = ctx;
|
|
151
|
+
// ① 关联字段候选(实测可用,返回 {id,name,ebObjId})
|
|
152
|
+
try {
|
|
153
|
+
const body = {
|
|
154
|
+
browserMultiple: false,
|
|
155
|
+
newly: 1,
|
|
156
|
+
searchValue: '',
|
|
157
|
+
formParam: JSON.stringify({ formId, layoutId, fieldId, filterItems: [], module: 'ebuilderform', dataDetails: [] }),
|
|
158
|
+
openScroll: true,
|
|
159
|
+
controlId: fieldId,
|
|
160
|
+
businessId: formId,
|
|
161
|
+
variableMap: {},
|
|
162
|
+
};
|
|
163
|
+
const r = await host.request({ path: '/api/ebuilder/form/common/browser/complete/ebuilder', body });
|
|
164
|
+
if (r?.status !== false && r?.data) {
|
|
165
|
+
const list = r.data.data || [];
|
|
166
|
+
const items = list.filter((x) => x && x.id).map((x) => ({
|
|
167
|
+
id: String(x.id), name: String(x.name || '').trim(), position: '', desc: '',
|
|
168
|
+
}));
|
|
169
|
+
return { available: true, items, source: 'associate-complete' };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch { /* 回退列表 */ }
|
|
173
|
+
// ② 列表兜底(需要菜单「面试数字人配置」)
|
|
174
|
+
const menu = digitalMenuOf(cache);
|
|
175
|
+
if (!menu?.listId) {
|
|
176
|
+
return { available: false, items: [], reason: '候选接口不可用,且当前环境未配置「面试数字人配置」列表菜单' };
|
|
177
|
+
}
|
|
178
|
+
let objId = '';
|
|
179
|
+
try {
|
|
180
|
+
const liBody = { cusMenuId: menu.cusMenuId, listId: menu.listId, urlPageTitle: menu.menuName };
|
|
181
|
+
liBody['appId_' + menu.listId] = ctx.appId;
|
|
182
|
+
const li = await host.request({ path: '/api/ebuilder/form/list/listInit', body: liBody });
|
|
183
|
+
objId = String(li?.data?.objid || '');
|
|
184
|
+
}
|
|
185
|
+
catch { /* 回退 tag 解析 */ }
|
|
186
|
+
if (!objId)
|
|
187
|
+
objId = await digitalObjIdOf(ctx).catch(() => '');
|
|
188
|
+
if (!objId) {
|
|
189
|
+
return { available: false, items: [], reason: '未能解析「面试数字人配置」对象 id(listInit / tag 均失败)' };
|
|
190
|
+
}
|
|
191
|
+
const rows = [];
|
|
192
|
+
let cur = 1;
|
|
193
|
+
const size = 100;
|
|
194
|
+
for (;;) {
|
|
195
|
+
const body = {
|
|
196
|
+
current: cur, pageSize: size, tableuid: randHex32(),
|
|
197
|
+
listId: menu.listId,
|
|
198
|
+
searchParamData: { searchType: '3', type: 'and' },
|
|
199
|
+
terminal: 'PC', browser: 'Chrome', requiredMatch: 1, mapResult: 1,
|
|
200
|
+
recheckQuery: 1, isFollow: 0, isShareToMe: 0, filterCondition: {},
|
|
201
|
+
cusMenuId: menu.cusMenuId, urlPageTitle: menu.menuName, menuName: menu.menuName,
|
|
202
|
+
};
|
|
203
|
+
const r = await host.request({
|
|
204
|
+
path: `/api/ebuilder/form/list/getListDatas?passid=${objId}&cid=${objId}`,
|
|
205
|
+
body, headers: { ebBusinessId: menu.listId },
|
|
206
|
+
});
|
|
207
|
+
const page = r?.data?.data || [];
|
|
208
|
+
rows.push(...page);
|
|
209
|
+
if (page.length < size)
|
|
210
|
+
break;
|
|
211
|
+
cur++;
|
|
212
|
+
if (cur > 20)
|
|
213
|
+
break; // 防御:最多 2000 条
|
|
214
|
+
}
|
|
215
|
+
const items = rows.map((x) => {
|
|
216
|
+
const nk = PLAN_NAME_KEYS.find((k) => String(x[k] || '').trim());
|
|
217
|
+
return {
|
|
218
|
+
id: String(x.form_data_id || x.id || ''),
|
|
219
|
+
name: String(nk ? x[nk] : '').trim(),
|
|
220
|
+
position: String(x.zwmc || '').trim(),
|
|
221
|
+
desc: String(x.zwjs || '').trim(),
|
|
222
|
+
};
|
|
223
|
+
}).filter((x) => x.id);
|
|
224
|
+
return { available: true, items, listId: menu.listId, objId, menuName: menu.menuName, source: 'list' };
|
|
225
|
+
}
|
|
226
|
+
// 方案匹配:id 精确 → 名称全等 → 名称包含;多条命中视为歧义,绝不自动取第一条
|
|
227
|
+
function pickDigitalPlan(items, key) {
|
|
228
|
+
const k = String(key || '').trim();
|
|
229
|
+
if (!k)
|
|
230
|
+
return { plan: null, ambiguous: [] };
|
|
231
|
+
const byId = items.filter((x) => x.id === k);
|
|
232
|
+
if (byId.length === 1)
|
|
233
|
+
return { plan: byId[0], ambiguous: [] };
|
|
234
|
+
const byExact = items.filter((x) => x.name === k);
|
|
235
|
+
if (byExact.length === 1)
|
|
236
|
+
return { plan: byExact[0], ambiguous: [] };
|
|
237
|
+
const byLike = items.filter((x) => x.name.includes(k));
|
|
238
|
+
if (byLike.length === 1)
|
|
239
|
+
return { plan: byLike[0], ambiguous: [] };
|
|
240
|
+
return { plan: null, ambiguous: byLike };
|
|
241
|
+
}
|
|
242
|
+
function planBrief(items) {
|
|
243
|
+
return (items || []).map((x) => x.name + (x.position ? '(岗位:' + x.position + ')' : '') + ' [id=' + x.id + ']').join(';');
|
|
244
|
+
}
|
|
245
|
+
async function buildPlan(opts) {
|
|
246
|
+
const { ctx, talentId, positionId, interviewer, type, session, start, end, email, mobile, aiPlan, rounds } = opts;
|
|
247
|
+
const { host, appId, cache } = ctx;
|
|
248
|
+
const objId = objIdOf(cache, 'interview_plan');
|
|
249
|
+
const formId = formIdOf(cache, 'interview_plan');
|
|
250
|
+
const fields = cache.fields[objId] || {};
|
|
251
|
+
const fid = (k) => fields[k];
|
|
252
|
+
for (const k of DATAKEYS)
|
|
253
|
+
if (!fid(k))
|
|
254
|
+
throw rsFail('面试计划缺少字段 ' + k + '(ds/fields 解析不到)');
|
|
255
|
+
const cand = await resolveCandidate(ctx, talentId);
|
|
256
|
+
const positionIdFinal = positionId || (cand.positionId ? String(cand.positionId) : '');
|
|
257
|
+
if (!positionIdFinal) {
|
|
258
|
+
throw rsFail('该人才尚未关联职位(简历池人才):安排面试必须先选定一个职位。'
|
|
259
|
+
+ '请从在招职位中推荐并由用户选定后,带 positionId 重试(prepare 可先出确认摘要)。');
|
|
260
|
+
}
|
|
261
|
+
const candManageId = cand.candidateManageId ? String(cand.candidateManageId) : '';
|
|
262
|
+
if (!candManageId)
|
|
263
|
+
throw rsFail('未定位到应聘管理记录(candidateManageId),请确认候选人已有应聘批次');
|
|
264
|
+
// 面试方式/轮次枚举:环境缓存 field_options 已有同名映射时直接反转使用(省 2 请求),未覆盖才回源
|
|
265
|
+
const [typeMap, sessionMap] = await Promise.all([
|
|
266
|
+
getDsOptions(host, objId, fid('interview_type')),
|
|
267
|
+
getDsOptions(host, objId, fid('interview_session')),
|
|
268
|
+
]);
|
|
269
|
+
const typeId = typeMap[type];
|
|
270
|
+
if (!typeId)
|
|
271
|
+
throw rsFail('面试方式「' + type + '」不在枚举中(' + Object.keys(typeMap).join('/') + ')');
|
|
272
|
+
const sessionId = sessionMap[session];
|
|
273
|
+
if (!sessionId)
|
|
274
|
+
throw rsFail('面试轮次「' + session + '」不在枚举中(' + Object.keys(sessionMap).join('/') + ')');
|
|
275
|
+
// 手机号/邮箱:页面按 talent_id 联动带出;直接落库必须显式写。用户显式输入优先于人才资料。
|
|
276
|
+
const emailFromTalent = String(cand.email || '').trim();
|
|
277
|
+
const mobileFromTalent = String(cand.mobile || '').trim();
|
|
278
|
+
const emailInput = String(email || '').trim();
|
|
279
|
+
const mobileInput = String(mobile || '').trim();
|
|
280
|
+
if (emailInput)
|
|
281
|
+
cand.email = emailInput;
|
|
282
|
+
if (mobileInput)
|
|
283
|
+
cand.mobile = mobileInput;
|
|
284
|
+
const emailSource = emailInput ? 'user' : (emailFromTalent ? 'talent' : 'none');
|
|
285
|
+
const mobileSource = mobileInput ? 'user' : (mobileFromTalent ? 'talent' : 'none');
|
|
286
|
+
// AI 面试:邮箱必填(服务端按邮箱发面试通知/录屏链接)。缺失时阻断创建,不静默写空、不降级。
|
|
287
|
+
const isAI = /AI|人工智能/i.test(String(type));
|
|
288
|
+
if (isAI && !cand.email) {
|
|
289
|
+
throw rsFail('AI面试必须填写候选人邮箱(必填):该人才资料未维护邮箱(talentId=' + talentId + ')。'
|
|
290
|
+
+ '请用户提供邮箱后重试(email 参数);或先到人才资料补全邮箱再安排。');
|
|
291
|
+
}
|
|
292
|
+
if (cand.email && !EMAIL_RE.test(cand.email)) {
|
|
293
|
+
throw rsFail('候选人邮箱格式不正确:' + cand.email + '。请提供有效邮箱后重试。');
|
|
294
|
+
}
|
|
295
|
+
if (!cand.mobile) {
|
|
296
|
+
throw rsFail('未取到候选人手机号(talentId=' + talentId + '),请先在人才资料补全手机号,或用 mobile 参数指定');
|
|
297
|
+
}
|
|
298
|
+
// 面试官解析与 AI 方案解析互不依赖 → 提前启动、并行等待(省 1 RTT)。
|
|
299
|
+
// 包装成永不 reject 的 promise:即便 AI 方案校验先抛错提前退出,也不会产生 unhandledRejection;
|
|
300
|
+
// 真正 await 时若失败再抛原错,保持与串行完全一致的错误语义。
|
|
301
|
+
const interviewerTask = (async () => {
|
|
302
|
+
if (interviewer) {
|
|
303
|
+
// 指定了姓名但人员库里查不到时,报"找不到",不要落到下面"未指定"的兜底文案(会误导成没传参数)。
|
|
304
|
+
const id = await resolvePersonId(host, fid('interviewer'), interviewer);
|
|
305
|
+
if (!id)
|
|
306
|
+
throw rsFail(`面试官「${interviewer}」在人员库中查不到(可能姓名写错、不在本租户,或不是在职人员)`);
|
|
307
|
+
return { id, name: interviewer };
|
|
308
|
+
}
|
|
309
|
+
const cu = await resolveCurrentUser(host);
|
|
310
|
+
return cu ? { id: cu.id, name: cu.name } : { id: null, name: interviewer };
|
|
311
|
+
})().then((value) => ({ ok: true, value }), (error) => ({ ok: false, error }));
|
|
312
|
+
// AI 面试方案(digital_id)——与邮箱同为 AI 面试必填。未指定时不自动取第一条。
|
|
313
|
+
let aiPlanPicked = null;
|
|
314
|
+
let aiPlanOptions = { available: false, items: [] };
|
|
315
|
+
let layoutId = '';
|
|
316
|
+
const digitalFid = fid('digital_id');
|
|
317
|
+
let interviewerId = null;
|
|
318
|
+
let interviewerName = interviewer;
|
|
319
|
+
if (isAI) {
|
|
320
|
+
if (!digitalFid)
|
|
321
|
+
throw rsFail('面试计划表单缺少「AI面试方案」字段(dataKey=digital_id),无法安排 AI 面试');
|
|
322
|
+
layoutId = await getFormLayout(host, formId);
|
|
323
|
+
// 方案候选与面试官并行(方案依赖 layoutId,故在其后)
|
|
324
|
+
const [plans, ivr] = await Promise.all([listDigitalPlans({ ctx, formId, layoutId, fieldId: digitalFid }), interviewerTask]);
|
|
325
|
+
if (!ivr.ok)
|
|
326
|
+
throw ivr.error;
|
|
327
|
+
interviewerId = ivr.value.id;
|
|
328
|
+
interviewerName = ivr.value.name;
|
|
329
|
+
aiPlanOptions = plans;
|
|
330
|
+
if (!aiPlanOptions.available) {
|
|
331
|
+
throw rsFail('AI面试必须选择「AI面试方案」,但' + aiPlanOptions.reason + ';请先在该环境维护面试数字人配置');
|
|
332
|
+
}
|
|
333
|
+
if (!aiPlanOptions.items.length) {
|
|
334
|
+
throw rsFail('「面试数字人配置」暂无可选方案,请先在「面试数字人配置」中新增方案后再安排 AI 面试');
|
|
335
|
+
}
|
|
336
|
+
if (aiPlan) {
|
|
337
|
+
const { plan, ambiguous } = pickDigitalPlan(aiPlanOptions.items, aiPlan);
|
|
338
|
+
if (plan)
|
|
339
|
+
aiPlanPicked = plan;
|
|
340
|
+
else if (ambiguous.length > 1)
|
|
341
|
+
throw rsFail('AI面试方案「' + aiPlan + '」命中多个:' + planBrief(ambiguous) + ',请指明具体方案');
|
|
342
|
+
else
|
|
343
|
+
throw rsFail('未找到 AI面试方案「' + aiPlan + '」。可选:' + planBrief(aiPlanOptions.items));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
const ivr = await interviewerTask;
|
|
348
|
+
if (!ivr.ok)
|
|
349
|
+
throw ivr.error;
|
|
350
|
+
interviewerId = ivr.value.id;
|
|
351
|
+
interviewerName = ivr.value.name;
|
|
352
|
+
}
|
|
353
|
+
if (!interviewerId)
|
|
354
|
+
throw rsFail('面试官未指定且无法解析当前登录用户,请用 interviewer 参数指定');
|
|
355
|
+
const dataDetails = [
|
|
356
|
+
{ formField: { id: fid('subject') }, content: (cand.positionName ? cand.positionName + '-' : '') + cand.name + '的面试' },
|
|
357
|
+
{ formField: { id: fid('start_time') }, content: start },
|
|
358
|
+
{ formField: { id: fid('end_time') }, content: end },
|
|
359
|
+
{ formField: { id: fid('interview_type') }, dataOptions: [{ optionId: typeId, content: type }] },
|
|
360
|
+
{ formField: { id: fid('interview_session') }, dataOptions: [{ optionId: sessionId, content: session }] },
|
|
361
|
+
{ formField: { id: fid('interviewer') }, dataOptions: [{ optionId: interviewerId, content: interviewerName }] },
|
|
362
|
+
{ formField: { id: fid('mobile') }, content: cand.mobile },
|
|
363
|
+
...(cand.email ? [{ formField: { id: fid('email') }, content: cand.email }] : []),
|
|
364
|
+
{ formField: { id: fid('position_manage_id') }, dataOptions: [{ optionId: positionIdFinal, content: cand.positionName }] },
|
|
365
|
+
{ formField: { id: fid('talent_id') }, dataOptions: [{ optionId: talentId, content: cand.name }] },
|
|
366
|
+
{ formField: { id: fid('candidate_manage_id') }, dataOptions: [{ optionId: candManageId, content: candManageId }] },
|
|
367
|
+
];
|
|
368
|
+
if (aiPlanPicked) {
|
|
369
|
+
dataDetails.push({ formField: { id: digitalFid }, dataOptions: [{ optionId: aiPlanPicked.id, content: aiPlanPicked.name }] });
|
|
370
|
+
}
|
|
371
|
+
// ① 表单默认值优先(用户 2026-11-06 定稿):CLI 走 saveFormData 直写,不触发表单渲染,
|
|
372
|
+
// 页面点「保存」会自动带出的 defaultDetails 必须显式并入提交体,否则「状态」等字段落库为空。
|
|
373
|
+
// 布局元数据回源(有进程内 memo),不读可能过期的磁盘选项缓存。
|
|
374
|
+
const meta = await getFormLayoutMeta(host, formId).catch(() => null);
|
|
375
|
+
const invFields = {};
|
|
376
|
+
for (const [k, v] of Object.entries(fields))
|
|
377
|
+
invFields[String(v)] = k;
|
|
378
|
+
// AI 专属字段由 aiPlan / 面试方式联动控制,不能拿页面默认值覆盖;轮次由下面单独处理(仅当默认里没有时)
|
|
379
|
+
const EXCLUDE_DEFAULTS = new Set(['digital_id', 'interview_type', 'interview_paper_id', 'send_channel']);
|
|
380
|
+
const defaultsApplied = [];
|
|
381
|
+
for (const d of (meta?.defaultDetails || [])) {
|
|
382
|
+
const did = String(d.fieldId || '');
|
|
383
|
+
if (!did || dataDetails.some((x) => String(x.formField.id) === did))
|
|
384
|
+
continue;
|
|
385
|
+
const dk = invFields[did] || '';
|
|
386
|
+
if (EXCLUDE_DEFAULTS.has(dk))
|
|
387
|
+
continue;
|
|
388
|
+
const o = (d.dataOptions || [])[0];
|
|
389
|
+
if (o?.optionId)
|
|
390
|
+
dataDetails.push({ formField: { id: did }, dataOptions: [{ optionId: String(o.optionId), content: o.content || '' }] });
|
|
391
|
+
else if (d.content !== undefined && d.content !== '')
|
|
392
|
+
dataDetails.push({ formField: { id: did }, content: String(d.content) });
|
|
393
|
+
else
|
|
394
|
+
continue;
|
|
395
|
+
defaultsApplied.push(dk || did);
|
|
396
|
+
}
|
|
397
|
+
// ② 轮次 interview_rounds(ebbrowser 关联字段,值=数据字典表记录 id,跨环境必变,运行时按名解析)。
|
|
398
|
+
// 2026-11-06 真机实测:defaultDetails 无该字段、viewLinkages 只有 hide/edit/readonly/required/show
|
|
399
|
+
// (无 value 赋值联动)、initDetails 为空 ⇒ 页面联动不可用,按用户裁定默认「第一轮」。
|
|
400
|
+
const roundsName = String(rounds || '第一轮').trim();
|
|
401
|
+
let roundsWarning = null;
|
|
402
|
+
const roundsFid = fid('interview_rounds');
|
|
403
|
+
if (roundsFid && !dataDetails.some((x) => String(x.formField.id) === String(roundsFid))) {
|
|
404
|
+
const hit = (cache.dict?.raw || []).find((r) => String(r.selection_name || '').trim() === roundsName
|
|
405
|
+
&& ['one', 'two', 'three', 'four'].includes(String(r.browser_key || '')));
|
|
406
|
+
if (hit)
|
|
407
|
+
dataDetails.push({ formField: { id: roundsFid }, dataOptions: [{ optionId: String(hit.option_id), content: roundsName }] });
|
|
408
|
+
else
|
|
409
|
+
roundsWarning = '数据字典未找到轮次「' + roundsName + '」(browserKey one/two/three/four),已跳过该字段,不臆造';
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
host: ctx.host,
|
|
413
|
+
objId, formId, appId, dataDetails, cand, typeId, sessionId, interviewerId, isAI, layoutId,
|
|
414
|
+
typeOptions: Object.fromEntries(Object.entries(typeMap).map(([n, id]) => [String(id), n])),
|
|
415
|
+
aiPlanPicked, aiPlanOptions,
|
|
416
|
+
summary: {
|
|
417
|
+
action: '安排面试',
|
|
418
|
+
talentId,
|
|
419
|
+
// 单独给一个纯姓名字段:batch 结果表必须用人名,不能拿 talentId 充当「候选人」
|
|
420
|
+
// (W8:旧版 batch.apply 的 resultTable 显示 100005840000020214,同条 viewLink 却写「李伟」)
|
|
421
|
+
candidateName: cand.name,
|
|
422
|
+
talent: cand.name + '(talentId=' + talentId + ')',
|
|
423
|
+
position: cand.positionName, type, session,
|
|
424
|
+
time: start + ' ~ ' + end, interviewer: interviewerName,
|
|
425
|
+
mobile: cand.mobile + '(来源:' + (mobileSource === 'user' ? '本次指定' : '人才资料') + ')',
|
|
426
|
+
email: (cand.email || '(未提供)') + '(来源:' + (emailSource === 'user' ? '本次指定' : emailSource === 'talent' ? '人才资料' : '缺失') + ')',
|
|
427
|
+
aiPlan: isAI
|
|
428
|
+
? (aiPlanPicked ? aiPlanPicked.name + '(id=' + aiPlanPicked.id + ')' : '未选择(AI面试必填,需用户指定)')
|
|
429
|
+
: '(非 AI 面试,不适用)',
|
|
430
|
+
rounds: roundsName,
|
|
431
|
+
defaultsApplied: defaultsApplied.length ? defaultsApplied : undefined,
|
|
432
|
+
roundsWarning: roundsWarning || undefined,
|
|
433
|
+
isAIInterview: isAI,
|
|
434
|
+
},
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
// 保存按钮动作链:system 由 saveFormData 完成,其余按 showOrder 顺序逐条执行
|
|
438
|
+
async function resolveSaveActions(plan) {
|
|
439
|
+
const layoutId = plan.layoutId || await getFormLayout(plan.host, plan.formId);
|
|
440
|
+
const acts = pickSaveButtonActions(await getFormButtons(plan.host, plan.objId, layoutId));
|
|
441
|
+
return acts.filter((a) => a.actionType !== 'system');
|
|
442
|
+
}
|
|
443
|
+
async function callAssignedInterview(host, formDataId) {
|
|
444
|
+
const r = await host.request({ path: '/api/recruit/candidate/assignedInterview?formDataId=' + formDataId, method: 'POST' });
|
|
445
|
+
// 页面判断用松散比较 res.code == '200',保持一致(code 可能是数字或字符串)
|
|
446
|
+
const ok = String(r?.code) === '200' || r?.status === true || r?.success === true;
|
|
447
|
+
if (!ok)
|
|
448
|
+
throw rsFail('分配面试(assignedInterview)失败:' + (r?.msg || JSON.stringify(r).slice(0, 200)));
|
|
449
|
+
return r?.data || {};
|
|
450
|
+
}
|
|
451
|
+
async function execSaveActions(plan, formDataId) {
|
|
452
|
+
const host = plan.host;
|
|
453
|
+
const executed = [];
|
|
454
|
+
const warnings = [];
|
|
455
|
+
let assigned = null;
|
|
456
|
+
let actions = [];
|
|
457
|
+
try {
|
|
458
|
+
actions = await resolveSaveActions(plan);
|
|
459
|
+
}
|
|
460
|
+
catch (e) {
|
|
461
|
+
warnings.push('读取「保存」按钮动作链失败:' + e.message + ';已按「保存 + 分配面试」兜底执行');
|
|
462
|
+
}
|
|
463
|
+
const hasAssigned = actions.some((a) => ASSIGNED_API_RE.test(a.ecode || ''));
|
|
464
|
+
if (!actions.length)
|
|
465
|
+
warnings.push('未解析到「保存」按钮的后续动作(该环境可能未配置,或按钮配置接口不可用);已按「保存 + 分配面试」兜底');
|
|
466
|
+
for (const a of actions) {
|
|
467
|
+
const base = { order: a.showOrder, name: a.name, type: a.actionType };
|
|
468
|
+
if (a.actionType === 'esb') {
|
|
469
|
+
const r = await runEsb(host, { objId: plan.objId, dataIds: formDataId, esbActionIds: a.id });
|
|
470
|
+
const ok = r?.status !== false;
|
|
471
|
+
executed.push({ ...base, ok, msg: r?.successMsg || r?.failMsg || '' });
|
|
472
|
+
if (!ok)
|
|
473
|
+
throw rsFail('「保存」后续动作「' + (a.name || a.id) + '」执行失败:' + (r?.failMsg || '未知原因'));
|
|
474
|
+
}
|
|
475
|
+
else if (a.actionType === 'jsCode') {
|
|
476
|
+
if (ASSIGNED_API_RE.test(a.ecode || '')) {
|
|
477
|
+
assigned = await callAssignedInterview(host, formDataId);
|
|
478
|
+
executed.push({ ...base, ok: true, msg: '等价调用 assignedInterview(分配面试)' });
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
executed.push({ ...base, ok: null, msg: '自定义脚本动作,服务端无法等价执行,已跳过' });
|
|
482
|
+
warnings.push('动作「' + (a.name || a.id) + '」为自定义 jsCode,未执行;如需该效果请在页面点保存');
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
executed.push({ ...base, ok: null, msg: '非服务端动作(' + a.actionType + '),已跳过' });
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (!hasAssigned) {
|
|
490
|
+
assigned = await callAssignedInterview(host, formDataId);
|
|
491
|
+
executed.push({ order: 999, name: '分配面试(兜底)', type: 'api', ok: true, msg: '该环境未把分配面试配置为保存动作' });
|
|
492
|
+
warnings.push('该环境「保存」动作链未解析到 assignedInterview,已按招聘业务契约兜底调用');
|
|
493
|
+
}
|
|
494
|
+
return { executed, warnings, assigned };
|
|
495
|
+
}
|
|
496
|
+
// 读取表单联动声明,算出「当前面试方式下必填、但本次未提供且无默认值」的字段(只读提示,不阻断)
|
|
497
|
+
async function resolveRequiredHint(plan, ctx) {
|
|
498
|
+
const fields = ctx.cache.fields[plan.objId] || {};
|
|
499
|
+
const meta = await getFormLayoutMeta(ctx.host, plan.formId);
|
|
500
|
+
if (!meta)
|
|
501
|
+
return { available: false, required: [], missing: [] };
|
|
502
|
+
return computeRequiredHint({
|
|
503
|
+
meta, fields,
|
|
504
|
+
typeName: plan.summary.type,
|
|
505
|
+
typeOptionId: plan.typeId,
|
|
506
|
+
typeOptions: plan.typeOptions || {},
|
|
507
|
+
dataDetails: plan.dataDetails,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
// 人才卡片详情 URL(EB 详情页):{baseUrl}/sp/ebdpage/view/{ebdDetailPageId}?talentId={id}
|
|
511
|
+
function resolveTalentCardUrl(ctx, talentId) {
|
|
512
|
+
const pid = ctx.cache.ebdDetailPageId;
|
|
513
|
+
if (!pid || !talentId) {
|
|
514
|
+
// 缓存缺 ebdDetailPageId(首次运行/换环境)时禁止返回 null:退化为 EB 卡片单页,
|
|
515
|
+
// objId 从环境缓存 talent_pool 取,跨环境动态解析,绝不写死。
|
|
516
|
+
const forms = ctx.cache.forms || {};
|
|
517
|
+
const tobj = String(forms.talent_pool?.objId || forms.talent?.objId || '');
|
|
518
|
+
return tobj && talentId ? buildCardUrl(ctx.baseUrl, tobj, String(talentId)) : null;
|
|
519
|
+
}
|
|
520
|
+
return `${ctx.baseUrl}/sp/ebdpage/view/${pid}?talentId=${talentId}${talentLinkExtra(ctx.cache)}`;
|
|
521
|
+
}
|
|
522
|
+
// 面试管理列表 URL:优先环境缓存菜单,回退 allMenus 解析(别名匹配,跨环境不写死)
|
|
523
|
+
async function resolveInterviewListUrl(ctx) {
|
|
524
|
+
const { host, appId, baseUrl, cache } = ctx;
|
|
525
|
+
const cachedMenu = cache.lists?.interview;
|
|
526
|
+
if (cachedMenu?.listId && cachedMenu.combinationId) {
|
|
527
|
+
return `${baseUrl}/ebdapp/view/${appId}/combination/${cachedMenu.combinationId}-${cachedMenu.listId || cachedMenu.cusMenuId}/search/${cachedMenu.pageId || cachedMenu.cusMenuId}?terminal=PC&cusMenuId=${cachedMenu.cusMenuId}`;
|
|
528
|
+
}
|
|
529
|
+
const r = await host.request({ path: `/api/cusapp/app/allMenus?isFront=1&appId=${appId}&terminalType=PC`, method: 'GET' });
|
|
530
|
+
const flat = [];
|
|
531
|
+
(function walk(ns) { for (const n of (ns || []))
|
|
532
|
+
if (n && typeof n === 'object') {
|
|
533
|
+
flat.push(n);
|
|
534
|
+
walk(n.children || n.childs);
|
|
535
|
+
} })(r?.data?.cusAppMenus || r?.data);
|
|
536
|
+
const node = findMenuNode(flat, ['面试管理', '面试安排列表', '面试安排'], (n) => n.combinationId && n.id && n.pageId);
|
|
537
|
+
if (!node)
|
|
538
|
+
return null;
|
|
539
|
+
return `${baseUrl}/ebdapp/view/${appId}/combination/${node.combinationId}-${node.id}/search/${node.pageId}?terminal=PC&cusMenuId=${node.id}`;
|
|
540
|
+
}
|
|
541
|
+
// 🔴 面试方式默认值(2026-11-07 统一):四个入口此前三种默认——prefill 用「AI面试」、prepare/apply/batch 用
|
|
542
|
+
// 「现场面试」、而表单 defaultValues.interview_type 又是「视频面试」,同一件事三份摘要互相打脸。
|
|
543
|
+
// 现统一为「现场面试」:它不需要邮箱与 AI 方案,缺省路径不会因必填缺失而中途失败。
|
|
544
|
+
// 表单默认值仍在 prepare 的 requiredHint.defaultValues 中原样保留,用户要别的就显式传 type。
|
|
545
|
+
const DEFAULT_INTERVIEW_TYPE = '现场面试';
|
|
546
|
+
// 默认时间:与页面「选 AI面试」联动一致 —— AI=当前时间~+7天,其它=1小时。分钟精度。
|
|
547
|
+
function nowAndEnd(type) {
|
|
548
|
+
const isAI = /AI|人工智能/i.test(String(type || ''));
|
|
549
|
+
const d = new Date();
|
|
550
|
+
const f = (x) => String(x).padStart(2, '0');
|
|
551
|
+
const fmt = (x) => x.getFullYear() + '-' + f(x.getMonth() + 1) + '-' + f(x.getDate()) + ' ' + f(x.getHours()) + ':' + f(x.getMinutes());
|
|
552
|
+
const s = fmt(d);
|
|
553
|
+
const e = fmt(new Date(d.getTime() + (isAI ? 7 * 24 * 3600 * 1000 : 3600 * 1000)));
|
|
554
|
+
return { s, e, isAI };
|
|
555
|
+
}
|
|
556
|
+
function shiftTime(str, addMs) {
|
|
557
|
+
const m = /^(\d{4})-(\d{1,2})-(\d{1,2})[ T](\d{1,2}):(\d{2})$/.exec(String(str || '').trim());
|
|
558
|
+
if (!m)
|
|
559
|
+
return null;
|
|
560
|
+
const d = new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]), Number(m[4]), Number(m[5]));
|
|
561
|
+
if (Number.isNaN(d.getTime()))
|
|
562
|
+
return null;
|
|
563
|
+
const t = new Date(d.getTime() + addMs);
|
|
564
|
+
const f = (x) => String(x).padStart(2, '0');
|
|
565
|
+
return t.getFullYear() + '-' + f(t.getMonth() + 1) + '-' + f(t.getDate()) + ' ' + f(t.getHours()) + ':' + f(t.getMinutes());
|
|
566
|
+
}
|
|
567
|
+
function makeCtx(env) {
|
|
568
|
+
return (async () => {
|
|
569
|
+
const host = env.host;
|
|
570
|
+
const session = await host.getSession();
|
|
571
|
+
const cache = await env.recruitContext();
|
|
572
|
+
return { host, baseUrl: session.baseUrl.replace(/\/+$/, ''), appId: cache.appId, cache };
|
|
573
|
+
})();
|
|
574
|
+
}
|
|
575
|
+
async function locateTalentId(ctx, args) {
|
|
576
|
+
if (args.talentId)
|
|
577
|
+
return String(args.talentId);
|
|
578
|
+
if (!args.mobile && !args.name) {
|
|
579
|
+
throw rsValidationError('talent_required', '请提供 talentId,或 mobile/name 之一用于定位候选人');
|
|
580
|
+
}
|
|
581
|
+
const cands = await locateTalent(ctx, { mobile: args.mobile, name: args.name });
|
|
582
|
+
if (!cands.length) {
|
|
583
|
+
throw rsFail('人才库未找到' + (args.mobile ? '手机号为 ' + args.mobile : '姓名为 ' + args.name) + '的候选人(检索条件:人才库列表,关键词 like)', { located: false, candidates: [] });
|
|
584
|
+
}
|
|
585
|
+
if (cands.length > 1) {
|
|
586
|
+
throw rsFail('匹配到多条同' + (args.mobile ? '手机号' : '姓名') + '候选人,请用户选择后再安排面试(绝不自动挑一个)', { located: false, needChoice: true, candidates: cands });
|
|
587
|
+
}
|
|
588
|
+
return String(cands[0].talentId);
|
|
589
|
+
}
|
|
590
|
+
const baseInput = {
|
|
591
|
+
talentId: { type: 'string', description: '人才 id(与 mobile/name 三选一)' },
|
|
592
|
+
mobile: { type: 'string', pattern: '^\\d{6,20}$', description: '手机号定位(唯一命中自动采用)' },
|
|
593
|
+
name: { type: 'string', description: '姓名定位(多条会要求用户选择)' },
|
|
594
|
+
positionId: { type: 'string', description: '应聘职位 id(简历池人才必填)' },
|
|
595
|
+
interviewer: { type: 'string', description: '面试官姓名(缺省=当前登录用户)' },
|
|
596
|
+
type: { type: 'string', description: '面试方式(现场面试/视频面试/电话面试/AI面试;含 AI 时邮箱与方案必填)' },
|
|
597
|
+
session: { type: 'string', description: '面试阶段(初试/复试/…)' },
|
|
598
|
+
rounds: { type: 'string', description: '面试轮次(第一轮/第二轮/第三轮/第四轮;缺省=页面默认值或第一轮,按数据字典运行时解析)' },
|
|
599
|
+
start: { type: 'string', pattern: '^\\d{4}-\\d{1,2}-\\d{1,2}[ T]\\d{1,2}:\\d{2}$', description: '开始时间 YYYY-MM-DD HH:mm(缺省=当前时间)' },
|
|
600
|
+
end: { type: 'string', pattern: '^\\d{4}-\\d{1,2}-\\d{1,2}[ T]\\d{1,2}:\\d{2}$', description: '结束时间(缺省=AI +7天 / 其它 +1小时)' },
|
|
601
|
+
email: { type: 'string', description: '候选人邮箱(AI 面试必填;补录值优先于人才资料)' },
|
|
602
|
+
aiPlan: { type: 'string', description: 'AI 面试方案名或 id(AI 面试必填;不传则 prepare 列出候选)' },
|
|
603
|
+
};
|
|
604
|
+
async function prepare(args, env, opts = {}) {
|
|
605
|
+
const ctx = await makeCtx(env);
|
|
606
|
+
if (!opts.skipPermissionProbe) {
|
|
607
|
+
const perm = await probeCreatePermission(ctx.host, objIdOf(ctx.cache, 'interview_plan'));
|
|
608
|
+
if (perm === 'denied')
|
|
609
|
+
throw rsFail('当前账号没有「面试计划」表单的创建权限,已阻断(未写入任何数据)');
|
|
610
|
+
}
|
|
611
|
+
const talentId = await locateTalentId(ctx, args);
|
|
612
|
+
const auto = nowAndEnd(String(args.type || DEFAULT_INTERVIEW_TYPE));
|
|
613
|
+
const startTime = args.start || auto.s;
|
|
614
|
+
const endTime = args.end || (args.start ? (shiftTime(String(args.start), auto.isAI ? 7 * 24 * 3600 * 1000 : 3600 * 1000) || auto.e) : auto.e);
|
|
615
|
+
const plan = await buildPlan({
|
|
616
|
+
ctx, talentId,
|
|
617
|
+
positionId: args.positionId ? String(args.positionId) : undefined,
|
|
618
|
+
interviewer: args.interviewer ? String(args.interviewer) : undefined,
|
|
619
|
+
type: String(args.type || DEFAULT_INTERVIEW_TYPE), session: String(args.session || '初试'),
|
|
620
|
+
start: String(startTime), end: String(endTime),
|
|
621
|
+
email: args.email ? String(args.email) : undefined,
|
|
622
|
+
mobile: args.mobile ? String(args.mobile) : undefined,
|
|
623
|
+
aiPlan: args.aiPlan ? String(args.aiPlan) : undefined,
|
|
624
|
+
rounds: args.rounds ? String(args.rounds) : undefined,
|
|
625
|
+
});
|
|
626
|
+
plan.host = ctx.host;
|
|
627
|
+
const aiPlanCandidates = plan.isAI
|
|
628
|
+
? (plan.aiPlanOptions.items || []).map((x) => ({ id: x.id, name: x.name, position: x.position }))
|
|
629
|
+
: [];
|
|
630
|
+
// 注:不再在 prepare 阶段解析「保存」按钮动作链——该信息属内部执行明细,
|
|
631
|
+
// 输出纪律明确禁止展示(openai.yaml:不展示 saveActions 等);apply 时由 execSaveActions 自解析。
|
|
632
|
+
// 省 1 个 RTT(getFormButtons)。
|
|
633
|
+
const requiredHint = await resolveRequiredHint(plan, ctx).catch(() => null);
|
|
634
|
+
if (requiredHint?.missing?.length)
|
|
635
|
+
requiredHint.missingLabels = requiredHint.missing.map(labelOf);
|
|
636
|
+
// 页面默认方案(defaultDetails 里 digital_id 的值)——标到候选上,方便用户直接说"用默认"
|
|
637
|
+
const defPlan = plan.isAI ? requiredHint?.defaultValues?.digital_id : null;
|
|
638
|
+
if (defPlan?.optionId) {
|
|
639
|
+
for (const x of aiPlanCandidates)
|
|
640
|
+
if (String(x.id) === String(defPlan.optionId))
|
|
641
|
+
x.isDefault = true;
|
|
642
|
+
}
|
|
643
|
+
const defaultAiPlan = defPlan?.optionId ? { id: defPlan.optionId, name: defPlan.content } : undefined;
|
|
644
|
+
const willSubmit = { formId: plan.formId, objId: plan.objId, dataDetails: plan.dataDetails };
|
|
645
|
+
const { createHash } = await import('node:crypto');
|
|
646
|
+
const fp = createHash('sha256').update(JSON.stringify(willSubmit)).digest('hex');
|
|
647
|
+
const continuation = await env.continuation.issue({ operation: 'ehr.recruit.stage.interview.arrange.apply', fingerprint: fp,
|
|
648
|
+
enumMaps: await dsOptionsSnapshot(), timeWindow: { start: String(startTime), end: String(endTime) },
|
|
649
|
+
// 🔴 参数快照(2026-11-07 修复):协议文档写的是「apply 带 confirm:true + continuation」,
|
|
650
|
+
// 但 applyCore 原来只从 args 取 talentId/type/session…,Agent 少传任一项就直接报 talent_required。
|
|
651
|
+
// 现把 prepare 用过的参数一并签进 continuation,apply 可只带 confirm + continuation;
|
|
652
|
+
// 若 apply 显式传了同名字段,仍以显式值为准(batch 场景每人 talentId 不同,靠这条生效)。
|
|
653
|
+
argsSnapshot: {
|
|
654
|
+
talentId, type: String(args.type || DEFAULT_INTERVIEW_TYPE), session: String(args.session || '初试'),
|
|
655
|
+
positionId: args.positionId ? String(args.positionId) : undefined,
|
|
656
|
+
interviewer: args.interviewer ? String(args.interviewer) : undefined,
|
|
657
|
+
aiPlan: args.aiPlan ? String(args.aiPlan) : undefined,
|
|
658
|
+
email: args.email ? String(args.email) : undefined,
|
|
659
|
+
mobile: args.mobile ? String(args.mobile) : undefined,
|
|
660
|
+
rounds: args.rounds ? String(args.rounds) : undefined,
|
|
661
|
+
},
|
|
662
|
+
});
|
|
663
|
+
return rsSuccess('ehr.recruit.stage.interview.arrange.prepare', {
|
|
664
|
+
mode: 'prepare', ...plan.summary,
|
|
665
|
+
needAiPlan: plan.isAI && !plan.aiPlanPicked,
|
|
666
|
+
aiPlans: plan.isAI ? aiPlanCandidates : undefined,
|
|
667
|
+
defaultAiPlan,
|
|
668
|
+
aiPlanHint: plan.isAI && !plan.aiPlanPicked
|
|
669
|
+
? 'AI面试方案为必填:请把 aiPlans 列给用户选择(isDefault=true 为页面默认方案),确认后带 aiPlan 重跑 apply'
|
|
670
|
+
: undefined,
|
|
671
|
+
requiredHint,
|
|
672
|
+
// 面试方式来源透明化:不传 type 时用 CLI 统一默认,同时把表单默认值一并给出,
|
|
673
|
+
// 两者不同就给 typeNote,避免"摘要说现场面试、表单默认写视频面试"这种自相矛盾没人发现。
|
|
674
|
+
typeSource: args.type ? 'explicit' : 'default',
|
|
675
|
+
formDefaultInterviewType: requiredHint?.defaultValues?.interview_type?.content,
|
|
676
|
+
typeNote: (!args.type
|
|
677
|
+
&& requiredHint?.defaultValues?.interview_type?.content
|
|
678
|
+
&& String(requiredHint.defaultValues.interview_type.content) !== DEFAULT_INTERVIEW_TYPE)
|
|
679
|
+
? `本次未指定 type,按 CLI 默认「${DEFAULT_INTERVIEW_TYPE}」提交;页面表单默认是「${requiredHint.defaultValues.interview_type.content}」,如需与该默认一致请显式传 type`
|
|
680
|
+
: undefined,
|
|
681
|
+
willSubmit,
|
|
682
|
+
// 🔴 2026-11-07:prepare 协议约定 preview(人类可读确认摘要),本 op 此前未提供,
|
|
683
|
+
// 确认链只剩 willSubmit 明细。这里用 summary 全量 + 两处需用户裁决的提示拼出预览。
|
|
684
|
+
preview: {
|
|
685
|
+
...plan.summary,
|
|
686
|
+
needAiPlan: plan.isAI && !plan.aiPlanPicked,
|
|
687
|
+
note: plan.isAI && !plan.aiPlanPicked
|
|
688
|
+
? 'AI 面试方案未选定:apply 会逐人阻断,需先选 aiPlan 重新 prepare'
|
|
689
|
+
: '确认姓名、职位、面试方式、轮次、面试官与时间窗后再 apply',
|
|
690
|
+
},
|
|
691
|
+
}, {
|
|
692
|
+
continuation,
|
|
693
|
+
fingerprint: fp,
|
|
694
|
+
confirmHint: '用户明确确认后,携带 confirm:true 与本 continuation 调用 ehr.recruit.stage.interview.arrange.apply(AI 面试需先选定 aiPlan)',
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
async function apply(args, env) {
|
|
698
|
+
if (args.confirm !== true)
|
|
699
|
+
throw rsConfirmationError('ehr.recruit.stage.interview.arrange.apply', { hint: '写操作必须显式 confirm:true' });
|
|
700
|
+
if (!args.continuation)
|
|
701
|
+
throw rsValidationError('continuation_required', '缺少 continuation(来自 prepare 的 meta)');
|
|
702
|
+
const payload = await env.continuation.verify(String(args.continuation), 'ehr.recruit.stage.interview.arrange.apply');
|
|
703
|
+
return applyCore(args, env, payload);
|
|
704
|
+
}
|
|
705
|
+
/** 单个候选人的落库执行体(供单条 apply 与批量 apply 复用;payload 由调用方校验)。 */
|
|
706
|
+
async function applyCore(args, env, payload) {
|
|
707
|
+
restoreDsOptions(payload.enumMaps);
|
|
708
|
+
const ctx = await makeCtx(env);
|
|
709
|
+
// 合并 prepare 快照与 apply 显式参数:显式优先(batch 每个候选人的 talentId 各不相同)。
|
|
710
|
+
// 这样 apply 只带 confirm + continuation 也能跑完,与协议文档一致。
|
|
711
|
+
const merged = { ...(payload.argsSnapshot || {}), ...args };
|
|
712
|
+
const talentId = await locateTalentId(ctx, merged);
|
|
713
|
+
const auto = nowAndEnd(String(merged.type || DEFAULT_INTERVIEW_TYPE));
|
|
714
|
+
// prepare 已把时间窗口放进 continuation:apply 复用它,避免两次运行时刻不同导致 fingerprint 漂移
|
|
715
|
+
const startTime = merged.start || payload.timeWindow?.start || auto.s;
|
|
716
|
+
const endTime = merged.end || (merged.start ? (shiftTime(String(merged.start), auto.isAI ? 7 * 24 * 3600 * 1000 : 3600 * 1000) || auto.e) : (payload.timeWindow?.end || auto.e));
|
|
717
|
+
const plan = await buildPlan({
|
|
718
|
+
ctx, talentId,
|
|
719
|
+
positionId: merged.positionId ? String(merged.positionId) : undefined,
|
|
720
|
+
interviewer: merged.interviewer ? String(merged.interviewer) : undefined,
|
|
721
|
+
type: String(merged.type || DEFAULT_INTERVIEW_TYPE), session: String(merged.session || '初试'),
|
|
722
|
+
start: String(startTime), end: String(endTime),
|
|
723
|
+
email: merged.email ? String(merged.email) : undefined,
|
|
724
|
+
mobile: merged.mobile ? String(merged.mobile) : undefined,
|
|
725
|
+
aiPlan: merged.aiPlan ? String(merged.aiPlan) : undefined,
|
|
726
|
+
rounds: merged.rounds ? String(merged.rounds) : undefined,
|
|
727
|
+
});
|
|
728
|
+
plan.host = ctx.host;
|
|
729
|
+
// AI 面试方案必填:未选定直接阻断,不落库、不执行动作链
|
|
730
|
+
if (plan.isAI && !plan.aiPlanPicked) {
|
|
731
|
+
throw rsFail('AI面试必须选择「AI面试方案」(必填),当前未指定。可选方案:'
|
|
732
|
+
+ (plan.aiPlanOptions.items?.length ? planBrief(plan.aiPlanOptions.items) : '(无)')
|
|
733
|
+
+ '。请让用户选择后带 aiPlan 重试。');
|
|
734
|
+
}
|
|
735
|
+
const willSubmit = { formId: plan.formId, objId: plan.objId, dataDetails: plan.dataDetails };
|
|
736
|
+
const { createHash } = await import('node:crypto');
|
|
737
|
+
if (payload.fingerprint !== createHash('sha256').update(JSON.stringify(willSubmit)).digest('hex')) {
|
|
738
|
+
throw rsValidationError('fingerprint_mismatch', '待提交内容与 prepare 确认摘要不一致,请重新 prepare 确认后再 apply');
|
|
739
|
+
}
|
|
740
|
+
const formDataId = await saveFormData(ctx.host, {
|
|
741
|
+
appId: plan.appId, formId: plan.formId, objId: plan.objId,
|
|
742
|
+
name: '面试管理-' + plan.cand.name + ' ' + plan.summary.time, dataDetails: plan.dataDetails,
|
|
743
|
+
});
|
|
744
|
+
const actionsRun = await execSaveActions(plan, formDataId);
|
|
745
|
+
// 第三层门禁:写完回查关键字段(后端对无效 optionId 会静默丢弃仍返回 success)
|
|
746
|
+
// union_status 可能被动作链推进,只要求非空;其余字段严格比对提交值。
|
|
747
|
+
const verification = await verifySubmitted({
|
|
748
|
+
host: ctx.host, formId: plan.formId, objId: plan.objId, dataId: formDataId,
|
|
749
|
+
expected: expectedFields(plan.dataDetails, ctx.cache.fields[plan.objId] || {}, ['interview_type', 'interview_session', 'interview_rounds', 'digital_id', 'email', 'union_status'], ['union_status']),
|
|
750
|
+
});
|
|
751
|
+
if (verification.mismatches.length)
|
|
752
|
+
invalidateEnvCache(ctx.baseUrl, ctx.appId);
|
|
753
|
+
const verifyWarnings = verification.mismatches.map((m) => '落库回查不一致:' + m.label + ' 期望 ' + m.expected + ',实际 ' + m.actual + '(该字段可能未写入)');
|
|
754
|
+
const detailUrl = buildCardUrl(ctx.baseUrl, plan.objId, formDataId);
|
|
755
|
+
// 列表链接只打开列表;详情单页由 viewLink 单独给出,不再用「列表+滑出详情」组合地址。
|
|
756
|
+
const listLocateUrl = buildListUrl(ctx.baseUrl, (ctx.cache.lists?.interview?.listId) || '');
|
|
757
|
+
return rsSuccess('ehr.recruit.stage.interview.arrange.apply', {
|
|
758
|
+
mode: 'apply', result: verification.mismatches.length ? 'partial' : 'success', interviewFormId: formDataId,
|
|
759
|
+
interviewCardUrl: detailUrl,
|
|
760
|
+
// 🔴 回填落库实际采用的关键值(W9):旧版 apply 输出里没有 time,Agent 无法核对
|
|
761
|
+
// 「输出时间 vs 落库时间」,曾出现差 2 分钟而无人发现。现在 time 直接取本次提交进表单的
|
|
762
|
+
// dataDetails 时间值(与回查同一来源),所以与落库一致。
|
|
763
|
+
time: plan.summary.time,
|
|
764
|
+
talent: plan.summary.talent,
|
|
765
|
+
position: plan.summary.position,
|
|
766
|
+
type: plan.summary.type,
|
|
767
|
+
session: plan.summary.session,
|
|
768
|
+
interviewer: plan.summary.interviewer,
|
|
769
|
+
viewLink: detailUrl ? `[查看 ${plan.cand.name || ''} 的面试安排详情](${detailUrl})` : null,
|
|
770
|
+
listLocateLink: listLocateUrl ? `[打开面试管理列表](${listLocateUrl})` : null,
|
|
771
|
+
agentNote: '产物 = 两个 Markdown 链接(平台实证可点击):① viewLink 面试安排详情单页 ② listLocateLink 面试管理列表(只打开列表,不打开详情)。按顺序原样放回答正文,缺哪个只给另一个、不输出半截。不要包 browsertool / <artifact> 标签。',
|
|
772
|
+
aiPlan: plan.isAI && plan.aiPlanPicked ? { id: plan.aiPlanPicked.id, name: plan.aiPlanPicked.name } : undefined,
|
|
773
|
+
saveActions: actionsRun.executed,
|
|
774
|
+
verification: { checked: verification.checked, mismatches: verification.mismatches, unavailable: verification.unavailable || null },
|
|
775
|
+
warnings: [...(actionsRun.warnings || []), ...verifyWarnings],
|
|
776
|
+
assigned: actionsRun.assigned || {},
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
async function prefill(args, env) {
|
|
780
|
+
const ctx = await makeCtx(env);
|
|
781
|
+
const talentId = await locateTalentId(ctx, args);
|
|
782
|
+
const objId = objIdOf(ctx.cache, 'interview_plan');
|
|
783
|
+
const formId = formIdOf(ctx.cache, 'interview_plan');
|
|
784
|
+
const fields = ctx.cache.fields[objId] || {};
|
|
785
|
+
const typeKey = String(args.type || DEFAULT_INTERVIEW_TYPE);
|
|
786
|
+
const typeFid = fields.interview_type;
|
|
787
|
+
if (!typeFid)
|
|
788
|
+
throw rsFail('面试计划缺少字段 interview_type(ds/fields 解析不到)');
|
|
789
|
+
const typeMap = await getDsOptions(ctx.host, objId, typeFid);
|
|
790
|
+
const typeId = typeMap[typeKey];
|
|
791
|
+
if (!typeId)
|
|
792
|
+
throw rsFail('面试方式「' + typeKey + '」不在枚举中(' + Object.keys(typeMap).join('/') + ')');
|
|
793
|
+
const cardUrl = resolveTalentCardUrl(ctx, talentId);
|
|
794
|
+
const listUrl = await resolveInterviewListUrl(ctx).catch(() => null);
|
|
795
|
+
const jsExpr = `(() => { const W = window.WeFormSDK; const i = W && W.getWeFormInstance('ebuilderform', '${formId}');`
|
|
796
|
+
+ ` if (!i) return 'no-form-instance(请先在人才卡片点「安排面试」打开面试安排表单)';`
|
|
797
|
+
+ ` try { i.changeFieldValue('field${typeFid}', { value: '${typeId}' }); return 'ok 面试方式=${typeKey}'; }`
|
|
798
|
+
+ ` catch (e) { return 'err:' + e.message; } })()`;
|
|
799
|
+
return rsSuccess('ehr.recruit.stage.interview.arrange.prefill', {
|
|
800
|
+
mode: 'prefill',
|
|
801
|
+
action: '安排面试(打开表单 + 选面试方式,人工核对保存;不落库)',
|
|
802
|
+
talentId,
|
|
803
|
+
interviewFormId: formId,
|
|
804
|
+
interviewType: typeKey,
|
|
805
|
+
interviewTypeOptionId: typeId,
|
|
806
|
+
talentCardUrl: cardUrl,
|
|
807
|
+
interviewListUrl: listUrl,
|
|
808
|
+
jsExpr,
|
|
809
|
+
steps: [
|
|
810
|
+
'1) 浏览器打开 talentCardUrl(需已登录该环境)→ 进入该候选人卡片',
|
|
811
|
+
'2) 点卡片上的「安排面试」→ 打开面试安排表单(主题/候选人/职位由表单默认值自动带入)',
|
|
812
|
+
'3) 在页面上下文执行 jsExpr → 选中「面试方式=' + typeKey + '」并触发联动(AI面试方案/面试官/开始结束时间自动带入)',
|
|
813
|
+
'4) 由 HR 核对(可按需调整)后点「保存」完成面试安排;本模式不写任何数据',
|
|
814
|
+
'5)(可选)打开 interviewListUrl 查看面试管理列表',
|
|
815
|
+
],
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
// ── 批量约面(2026-11-06)──────────────────────────────────────────────────────
|
|
819
|
+
// 后端没有批量端点:assignedInterview 只收单个 formDataId,页面「多选约面」也是前端弹窗 + 循环。
|
|
820
|
+
// 这里做的是「一次确认、逐人执行」的编排:先逐人 prepare 出摘要与指纹,用户确认一次,
|
|
821
|
+
// 再逐人走完整的保存 + 动作链 + 回查,最后汇总成功/失败。非原子,结果可能是 partial。
|
|
822
|
+
const BATCH_MAX = 30;
|
|
823
|
+
function normalizeCandidateList(raw) {
|
|
824
|
+
if (!Array.isArray(raw) || !raw.length) {
|
|
825
|
+
throw rsValidationError('candidates_required', 'candidates 必须是非空数组,元素形如 {talentId} / {mobile} / {name}');
|
|
826
|
+
}
|
|
827
|
+
if (raw.length > BATCH_MAX) {
|
|
828
|
+
throw rsValidationError('candidates_too_many', `一次最多处理 ${BATCH_MAX} 人(当前 ${raw.length} 人);请分批执行`);
|
|
829
|
+
}
|
|
830
|
+
return raw.map((x, i) => {
|
|
831
|
+
const o = (x && typeof x === 'object') ? x : {};
|
|
832
|
+
if (!o.talentId && !o.mobile && !o.name) {
|
|
833
|
+
throw rsValidationError('candidate_invalid', `第 ${i + 1} 个候选人缺少 talentId/mobile/name`);
|
|
834
|
+
}
|
|
835
|
+
return o;
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
async function batchPrepare(args, env) {
|
|
839
|
+
const list = normalizeCandidateList(args.candidates);
|
|
840
|
+
const type = String(args.type || DEFAULT_INTERVIEW_TYPE);
|
|
841
|
+
const auto = nowAndEnd(type);
|
|
842
|
+
const startTime = String(args.start || auto.s);
|
|
843
|
+
const endTime = String(args.end || (args.start ? (shiftTime(String(args.start), auto.isAI ? 7 * 24 * 3600 * 1000 : 3600 * 1000) || auto.e) : auto.e));
|
|
844
|
+
const shared = {};
|
|
845
|
+
for (const k of ['positionId', 'interviewer', 'type', 'session', 'rounds', 'aiPlan', 'email']) {
|
|
846
|
+
if (args[k] !== undefined && args[k] !== null && String(args[k]).trim() !== '')
|
|
847
|
+
shared[k] = String(args[k]);
|
|
848
|
+
}
|
|
849
|
+
shared.type = type;
|
|
850
|
+
shared.start = startTime;
|
|
851
|
+
shared.end = endTime;
|
|
852
|
+
const items = [];
|
|
853
|
+
const seen = new Set();
|
|
854
|
+
for (let i = 0; i < list.length; i++) {
|
|
855
|
+
const c = list[i];
|
|
856
|
+
const label = String(c.name || c.mobile || c.talentId || `第${i + 1}人`);
|
|
857
|
+
try {
|
|
858
|
+
const r = await prepare({ ...shared, ...c }, env, { skipPermissionProbe: i > 0 });
|
|
859
|
+
const d = r.data || {};
|
|
860
|
+
const talentId = String(d.talentId || '');
|
|
861
|
+
if (talentId && seen.has(talentId)) {
|
|
862
|
+
items.push({ index: i + 1, label, talentId, status: 'duplicate', message: '与前面的候选人重复,已跳过' });
|
|
863
|
+
continue;
|
|
864
|
+
}
|
|
865
|
+
if (talentId)
|
|
866
|
+
seen.add(talentId);
|
|
867
|
+
const meta = r.meta || {};
|
|
868
|
+
// 结果表里的人名:优先用 prepare 解析出的真实姓名(d.candidateName),
|
|
869
|
+
// 退而用调用方传的 name → mobile → talentId。旧版直接拿 talentId 当 label,
|
|
870
|
+
// 从列表勾选(只传 talentId)时整张结果表都是 id,看不出是谁(W8)。
|
|
871
|
+
const resolvedName = String(d.candidateName || '').trim();
|
|
872
|
+
items.push({
|
|
873
|
+
index: i + 1, label: resolvedName || label, talentId, status: 'ready',
|
|
874
|
+
args: { ...shared, ...c },
|
|
875
|
+
fingerprint: String(meta.fingerprint || ''),
|
|
876
|
+
timeWindow: { start: startTime, end: endTime },
|
|
877
|
+
message: d.needAiPlan ? 'AI面试方案未选(apply 会阻断)' : undefined,
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
catch (e) {
|
|
881
|
+
items.push({ index: i + 1, label, status: 'failed', message: e?.message || 'prepare 失败' });
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
const ready = items.filter((x) => x.status === 'ready');
|
|
885
|
+
if (!ready.length) {
|
|
886
|
+
return rsSuccess('ehr.recruit.stage.interview.arrange.batch.prepare', {
|
|
887
|
+
mode: 'batch-prepare', total: items.length, ready: 0, failed: items.length,
|
|
888
|
+
items: items.map(({ args, fingerprint, timeWindow, ...rest }) => rest),
|
|
889
|
+
hint: '没有任何候选人可执行,逐条看 items[].message 修正后重试',
|
|
890
|
+
preview: {
|
|
891
|
+
action: '批量安排面试 — 无可执行项',
|
|
892
|
+
total: items.length,
|
|
893
|
+
ready: 0,
|
|
894
|
+
failed: items.length,
|
|
895
|
+
reasons: items.map((x) => `${x.index}. ${x.label}:${x.message || x.status}`),
|
|
896
|
+
},
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
const { createHash } = await import('node:crypto');
|
|
900
|
+
const fp = createHash('sha256').update(JSON.stringify(ready.map((x) => [x.talentId, x.fingerprint]))).digest('hex');
|
|
901
|
+
const continuation = await env.continuation.issue({
|
|
902
|
+
operation: 'ehr.recruit.stage.interview.arrange.batch.apply',
|
|
903
|
+
fingerprint: fp,
|
|
904
|
+
enumMaps: await dsOptionsSnapshot(),
|
|
905
|
+
items: ready.map((x) => ({ index: x.index, label: x.label, talentId: x.talentId, args: x.args, fingerprint: x.fingerprint, timeWindow: x.timeWindow })),
|
|
906
|
+
});
|
|
907
|
+
return rsSuccess('ehr.recruit.stage.interview.arrange.batch.prepare', {
|
|
908
|
+
mode: 'batch-prepare',
|
|
909
|
+
total: items.length,
|
|
910
|
+
ready: ready.length,
|
|
911
|
+
failed: items.filter((x) => x.status === 'failed').length,
|
|
912
|
+
duplicates: items.filter((x) => x.status === 'duplicate').length,
|
|
913
|
+
shared: { type, session: shared.session, rounds: shared.rounds, interviewer: shared.interviewer, time: startTime + ' ~ ' + endTime, aiPlan: shared.aiPlan },
|
|
914
|
+
items: items.map(({ args, fingerprint, timeWindow, ...rest }) => rest),
|
|
915
|
+
note: '确认摘要后带 confirm:true 与 meta.continuation 调 batch.apply;逐人执行,可能是 partial',
|
|
916
|
+
// 🔴 2026-11-07:本 op 此前无 preview。批量场景用户要看的是「这批到底谁会被约、谁被跳过、为什么」,
|
|
917
|
+
// 所以 preview 用逐行名单而不是数字汇总。
|
|
918
|
+
preview: {
|
|
919
|
+
action: '批量安排面试(逐人执行,结果可能 partial)',
|
|
920
|
+
total: items.length,
|
|
921
|
+
ready: ready.length,
|
|
922
|
+
failed: items.filter((x) => x.status === 'failed').length,
|
|
923
|
+
duplicates: items.filter((x) => x.status === 'duplicate').length,
|
|
924
|
+
shared: { type, session: shared.session, rounds: shared.rounds, interviewer: shared.interviewer, time: startTime + ' ~ ' + endTime, aiPlan: shared.aiPlan },
|
|
925
|
+
candidates: items.map((x) => `${x.index}. ${x.label} — ${x.status}${x.message ? ':' + x.message : ''}`),
|
|
926
|
+
},
|
|
927
|
+
}, {
|
|
928
|
+
continuation,
|
|
929
|
+
fingerprint: fp,
|
|
930
|
+
confirmHint: '用户明确确认整批名单后,携带 confirm:true 与本 continuation 调用 ehr.recruit.stage.interview.arrange.batch.apply',
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
async function batchApply(args, env) {
|
|
934
|
+
if (args.confirm !== true) {
|
|
935
|
+
throw rsConfirmationError('ehr.recruit.stage.interview.arrange.batch.apply', { hint: '批量写操作必须显式 confirm:true' });
|
|
936
|
+
}
|
|
937
|
+
if (!args.continuation)
|
|
938
|
+
throw rsValidationError('continuation_required', '缺少 continuation(来自 batch.prepare 的 meta)');
|
|
939
|
+
const batch = await env.continuation.verify(String(args.continuation), 'ehr.recruit.stage.interview.arrange.batch.apply');
|
|
940
|
+
const items = Array.isArray(batch.items) ? batch.items : [];
|
|
941
|
+
if (!items.length)
|
|
942
|
+
throw rsValidationError('batch_empty', 'continuation 中没有可执行的候选人');
|
|
943
|
+
const results = [];
|
|
944
|
+
for (const it of items) {
|
|
945
|
+
const payload = { fingerprint: it.fingerprint, timeWindow: it.timeWindow, enumMaps: batch.enumMaps };
|
|
946
|
+
try {
|
|
947
|
+
const r = await applyCore({ ...(it.args || {}), confirm: true }, env, payload);
|
|
948
|
+
const d = r.data || {};
|
|
949
|
+
results.push({
|
|
950
|
+
index: it.index,
|
|
951
|
+
talentId: it.talentId,
|
|
952
|
+
name: it.label,
|
|
953
|
+
candidateName: it.label,
|
|
954
|
+
status: d.result === 'partial' ? 'partial' : 'success',
|
|
955
|
+
interviewFormId: d.interviewFormId,
|
|
956
|
+
cardUrl: d.interviewCardUrl,
|
|
957
|
+
viewLink: d.viewLink,
|
|
958
|
+
warnings: d.warnings && d.warnings.length ? d.warnings : undefined,
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
catch (e) {
|
|
962
|
+
results.push({ index: it.index, talentId: it.talentId, name: it.label, candidateName: it.label, status: 'failed', message: e?.message || '执行失败' });
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const ok = results.filter((x) => x.status === 'success').length;
|
|
966
|
+
const partial = results.filter((x) => x.status === 'partial').length;
|
|
967
|
+
const failed = results.filter((x) => x.status === 'failed').length;
|
|
968
|
+
const lines = [
|
|
969
|
+
'| # | 候选人 | 结果 | 说明 |',
|
|
970
|
+
'|---|---|---|---|',
|
|
971
|
+
...results.map((x) => `| ${x.index} | ${x.name} | ${x.status === 'success' ? '成功' : x.status === 'partial' ? '部分成功' : '失败'} | ${x.message || (x.warnings?.length ? x.warnings.join(';') : x.cardUrl ? '已创建面试安排' : '')} |`),
|
|
972
|
+
];
|
|
973
|
+
return rsSuccess('ehr.recruit.stage.interview.arrange.batch.apply', {
|
|
974
|
+
mode: 'batch-apply',
|
|
975
|
+
result: failed || partial ? 'partial' : 'success',
|
|
976
|
+
total: results.length,
|
|
977
|
+
succeeded: ok,
|
|
978
|
+
partial,
|
|
979
|
+
failed,
|
|
980
|
+
items: results,
|
|
981
|
+
resultTable: lines.join('\n'),
|
|
982
|
+
agentNote: '把 resultTable 原样放回答正文(这是本次批量约面的结果清单);失败/部分成功的条目要连同 message 一起说清楚,不要只报总数。',
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
export const interviewArrangeOperations = [
|
|
986
|
+
{
|
|
987
|
+
name: 'ehr.recruit.stage.interview.arrange.prepare',
|
|
988
|
+
resource: 'recruit.interview',
|
|
989
|
+
method: 'prepare',
|
|
990
|
+
action: 'interview.arrange.prepare',
|
|
991
|
+
summary: '安排面试确认摘要:定位候选人(talentId/手机号/姓名三选一)、解析面试方式/轮次枚举、AI 面试时列候选方案(绝不自动取第一条)与联动必填核对,不写入',
|
|
992
|
+
capability: 'recruit.interview.arrange',
|
|
993
|
+
risk: 'write',
|
|
994
|
+
requiresConfirmation: true,
|
|
995
|
+
inputSchema: schemaOf(baseInput, {}),
|
|
996
|
+
handler: prepare,
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
name: 'ehr.recruit.stage.interview.arrange.apply',
|
|
1000
|
+
resource: 'recruit.interview',
|
|
1001
|
+
method: 'apply',
|
|
1002
|
+
action: 'interview.arrange.apply',
|
|
1003
|
+
summary: '用户确认后安排面试:saveFormData → 按「保存」按钮动作链执行(ESB 日程/分配面试/AI 面试提醒),与页面点保存等价;返回双链接',
|
|
1004
|
+
capability: 'recruit.interview.arrange',
|
|
1005
|
+
risk: 'write',
|
|
1006
|
+
requiresConfirmation: true,
|
|
1007
|
+
inputSchema: schemaOf({ ...baseInput, confirm: { type: 'boolean' }, continuation: { type: 'string' } }, {}),
|
|
1008
|
+
handler: apply,
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
name: 'ehr.recruit.stage.interview.arrange.prefill',
|
|
1012
|
+
resource: 'recruit.interview',
|
|
1013
|
+
method: 'prefill',
|
|
1014
|
+
action: 'interview.arrange.prefill',
|
|
1015
|
+
summary: '预填模式(人工保存):输出人才卡片 URL + 面试管理列表 URL + 选面试方式的 jsExpr,触发表单联动后由 HR 核对保存,不落库',
|
|
1016
|
+
capability: 'recruit.interview.arrange',
|
|
1017
|
+
risk: 'read',
|
|
1018
|
+
inputSchema: schemaOf(baseInput, {}),
|
|
1019
|
+
handler: prefill,
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
name: 'ehr.recruit.stage.interview.arrange.batch.prepare',
|
|
1023
|
+
resource: 'recruit.interview',
|
|
1024
|
+
method: 'prepare',
|
|
1025
|
+
action: 'interview.arrange.batch.prepare',
|
|
1026
|
+
summary: '批量约面确认摘要:逐人定位候选人、解析面试方式/轮次与必填项,输出名单与失败原因(重复自动跳过),不写入;一次最多 30 人',
|
|
1027
|
+
capability: 'recruit.interview.arrange',
|
|
1028
|
+
risk: 'write',
|
|
1029
|
+
requiresConfirmation: true,
|
|
1030
|
+
inputSchema: schemaOf({
|
|
1031
|
+
candidates: { type: 'array', description: '候选人数组,元素为 {talentId} / {mobile} / {name} 之一;最多 30 人', items: { type: 'object' } },
|
|
1032
|
+
...baseInput,
|
|
1033
|
+
}, { required: ['candidates'] }),
|
|
1034
|
+
handler: batchPrepare,
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
name: 'ehr.recruit.stage.interview.arrange.batch.apply',
|
|
1038
|
+
resource: 'recruit.interview',
|
|
1039
|
+
method: 'apply',
|
|
1040
|
+
action: 'interview.arrange.batch.apply',
|
|
1041
|
+
summary: '用户确认名单后逐人安排面试(同一套保存+动作链+落库回查),返回逐人结果清单与 Markdown 表格;非原子批量,结果可能为 partial',
|
|
1042
|
+
capability: 'recruit.interview.arrange',
|
|
1043
|
+
risk: 'write',
|
|
1044
|
+
requiresConfirmation: true,
|
|
1045
|
+
inputSchema: schemaOf({ confirm: { type: 'boolean' }, continuation: { type: 'string' } }, { required: ['confirm', 'continuation'] }),
|
|
1046
|
+
handler: batchApply,
|
|
1047
|
+
},
|
|
1048
|
+
];
|
|
1049
|
+
void randomUUID;
|