|
|
|
@@ -0,0 +1,49 @@
|
|
|
|
|
import { arrangeSchedule, definitionIssues, scheduleNodeTypes } from '@/views/datagov/dataops/scheduling/canvas';
|
|
|
|
|
const store = 'schedule-review-state';
|
|
|
|
|
const fixture = {
|
|
|
|
|
summary: { scheduleId: '9007199254740993', name: '交易数据 · 每日质量分流', orgId: '2', status: 'DRAFT', version: 1 },
|
|
|
|
|
description: '合成数据验证',
|
|
|
|
|
nodes: [
|
|
|
|
|
{ nodeKey: 'clean', name: '订单标准化清洗', type: 'TRANSFORMATION', referenceId: '103' },
|
|
|
|
|
{ nodeKey: 'condition', name: '检查上游处理状态', type: 'CONDITION', condition: { field: 'PARENT_STATUS', operator: 'EQ', values: ['SUCCEEDED'] } },
|
|
|
|
|
{ nodeKey: 'quality', name: '订单金额完整性', type: 'QUALITY_RULE', referenceId: '104' },
|
|
|
|
|
{ nodeKey: 'code', name: '异常记录归档', type: 'CODE_OBJECT', referenceId: '102' },
|
|
|
|
|
{ nodeKey: 'batch', name: '订单明细采集', type: 'BATCH_JOB', referenceId: '101' },
|
|
|
|
|
{ nodeKey: 'dependency', name: '等待客户维度更新', type: 'DEPENDENT', dependency: { scheduleId: '9007199254740994', businessDateOffsetDays: 0 } }
|
|
|
|
|
],
|
|
|
|
|
edges: [
|
|
|
|
|
{ edgeKey: 'a', sourceNodeKey: 'clean', targetNodeKey: 'condition', branchOutcome: 'DEFAULT' },
|
|
|
|
|
{ edgeKey: 'b', sourceNodeKey: 'condition', targetNodeKey: 'quality', branchOutcome: 'TRUE' },
|
|
|
|
|
{ edgeKey: 'c', sourceNodeKey: 'condition', targetNodeKey: 'code', branchOutcome: 'FALSE' },
|
|
|
|
|
{ edgeKey: 'd', sourceNodeKey: 'batch', targetNodeKey: 'clean', branchOutcome: 'DEFAULT' },
|
|
|
|
|
{ edgeKey: 'e', sourceNodeKey: 'dependency', targetNodeKey: 'condition', branchOutcome: 'DEFAULT' }
|
|
|
|
|
],
|
|
|
|
|
triggers: [], parameters: [], calendar: { timeZone: 'Asia/Shanghai', includedDates: [], excludedDates: [] },
|
|
|
|
|
strategy: { maxConcurrency: 1, priority: 'MEDIUM', timeoutMinutes: 60, retryCount: 0, retryIntervalSeconds: 30, failureStrategy: 'END' }, definitionSha256: 'a'.repeat(64)
|
|
|
|
|
};
|
|
|
|
|
function read() { const saved = sessionStorage.getItem(store); return saved ? JSON.parse(saved) : { detail: fixture, layout: { layoutVersion: '1', definitionSha256: fixture.definitionSha256, positions: arrangeSchedule(fixture.nodes, fixture.edges), viewport: null, stale: false, droppedNodeKeys: [] }, receipts: {}, layoutReceipts: {} }; }
|
|
|
|
|
const put = state => sessionStorage.setItem(store, JSON.stringify(state));
|
|
|
|
|
export async function getSchedule() { return { data: read().detail }; }
|
|
|
|
|
export async function listSchedules() { return { data: { rows: [{ scheduleId: '9007199254740994', name: '客户维度更新', status: 'READY' }] } }; }
|
|
|
|
|
export async function getScheduleLayout() { const s = read(); return { data: { ...s.layout, stale: s.layout.definitionSha256 !== s.detail.definitionSha256 } }; }
|
|
|
|
|
export async function getScheduleCapabilities() { return { data: { adapterConfigured: true, nodes: scheduleNodeTypes.map(t => ({ type: t.value, executable: !['BATCH_JOB', 'CODE_OBJECT'].includes(t.value), message: ['BATCH_JOB', 'CODE_OBJECT'].includes(t.value) ? '执行入口待接通,可保存定义' : '已接入定义;实际结果需运行观测' })), capabilityVersion: 'fixture', maxNodes: 200, maxEdges: 500, notices: [] } }; }
|
|
|
|
|
export async function updateSchedule(id, definition, key) {
|
|
|
|
|
const s = read(); if (s.receipts[key]) return { data: s.detail };
|
|
|
|
|
const { version, name, ...body } = definition;
|
|
|
|
|
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(body)));
|
|
|
|
|
const hash = [...new Uint8Array(digest)].map(b => b.toString(16).padStart(2, '0')).join('');
|
|
|
|
|
s.detail = { ...body, summary: { ...s.detail.summary, scheduleId: id, name, version: Number(version) + 1 }, definitionSha256: hash };
|
|
|
|
|
s.receipts[key] = true; put(s); return { data: s.detail };
|
|
|
|
|
}
|
|
|
|
|
export const createSchedule = (definition, key) => updateSchedule('9007199254740993', { ...definition, version: 0 }, key);
|
|
|
|
|
export async function saveScheduleLayout(id, command, key) {
|
|
|
|
|
const s = read(); if (s.layoutReceipts[key]) return { data: s.layoutReceipts[key] };
|
|
|
|
|
s.layout = { layoutVersion: String(Number(s.layout.layoutVersion) + 1), definitionSha256: command.definitionSha256, positions: command.positions, viewport: command.viewport, stale: false, droppedNodeKeys: [] };
|
|
|
|
|
s.layoutReceipts[key] = s.layout; put(s);
|
|
|
|
|
if (sessionStorage.getItem('schedule-review-interrupt')) { sessionStorage.removeItem('schedule-review-interrupt'); throw new Error('Simulated lost response'); }
|
|
|
|
|
return { data: s.layout };
|
|
|
|
|
}
|
|
|
|
|
export async function getScheduleReceipt(action, resource, key) { const s = read(); return { data: { found: !!s.receipts[key], definition: s.receipts[key] ? s.detail : null } }; }
|
|
|
|
|
export async function getScheduleLayoutReceipt(id, key) { const s = read(); return { data: { found: !!s.layoutReceipts[key], layout: s.layoutReceipts[key] || null } }; }
|
|
|
|
|
export async function validateSchedule() { const s = read(); const definition = { ...s.detail, name: s.detail.summary.name }; const issues = definitionIssues(definition); definition.nodes.filter(n => ['BATCH_JOB', 'CODE_OBJECT'].includes(n.type)).forEach(n => issues.push({ code: 'OWNER_UNSUPPORTED', phase: 'EXECUTION', severity: 'ERROR', nodeKey: n.nodeKey, location: '/nodes', message: '该任务类型的调度执行入口待接通,可保留定义' })); return { data: { valid: !issues.length, issues, definitionSha256: s.detail.definitionSha256 } }; }
|
|
|
|
|
export async function readySchedule(id, version, key) { const s = read(); s.detail.summary.status = 'READY'; s.receipts[key] = true; put(s); return { data: s.detail }; }
|