feat: 新增风险图谱算法与系统仪表盘及操作反馈体系

后端新增风险图谱算法模块、风险观察与反馈服务、规则 DSL
校验器和可解释性引擎,完善系统仪表盘和财务仪表盘统计,
优化 agent 运行和编排执行链路,清理旧开发文档,前端新增
系统趋势、负载热力图等多种仪表盘图表组件,完善操作反馈
对话框和工作台日期选择器,优化报销创建和审批详情交互,
补充单元测试覆盖。
This commit is contained in:
caoxiaozhu
2026-05-30 15:46:51 +08:00
parent 4c59941ec6
commit 7989f3a159
314 changed files with 30073 additions and 20626 deletions

View File

@@ -0,0 +1,130 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
import {
ASSISTANT_SCOPE_SESSION_APPLICATION,
ASSISTANT_SCOPE_SESSION_EXPENSE,
ASSISTANT_SCOPE_SESSION_KNOWLEDGE,
inferAssistantScopeTarget
} from '../src/utils/assistantSessionScope.js'
import {
resolveWorkbenchSessionTypeFromOntology
} from '../src/utils/workbenchAssistantIntent.js'
const appShellRouteView = readFileSync(
fileURLToPath(new URL('../src/views/AppShellRouteView.vue', import.meta.url)),
'utf8'
)
const appShellComposable = readFileSync(
fileURLToPath(new URL('../src/composables/useAppShell.js', import.meta.url)),
'utf8'
)
const assistantScript = readFileSync(
fileURLToPath(new URL('../src/views/scripts/TravelReimbursementCreateView.js', import.meta.url)),
'utf8'
)
test('workbench prompt applies travel phrases to application assistant scope', () => {
assert.equal(inferAssistantScopeTarget('申请出差'), ASSISTANT_SCOPE_SESSION_APPLICATION)
assert.equal(
inferAssistantScopeTarget('去北京出差3天支撑国网仿生产环境部署'),
ASSISTANT_SCOPE_SESSION_APPLICATION
)
assert.equal(
inferAssistantScopeTarget('去国网出差3天协助仿生产环境部署'),
ASSISTANT_SCOPE_SESSION_APPLICATION
)
assert.equal(
inferAssistantScopeTarget('下周去上海支撑客户系统上线预计3天'),
ASSISTANT_SCOPE_SESSION_APPLICATION
)
assert.equal(
inferAssistantScopeTarget('安排去深圳客户现场验收项目'),
ASSISTANT_SCOPE_SESSION_APPLICATION
)
assert.equal(
inferAssistantScopeTarget('准备去国网现场做仿生产环境部署差旅3天'),
ASSISTANT_SCOPE_SESSION_APPLICATION
)
assert.equal(
inferAssistantScopeTarget('我要报销去北京的费用'),
ASSISTANT_SCOPE_SESSION_EXPENSE
)
assert.equal(
inferAssistantScopeTarget('我要报销去北京出差的费用'),
ASSISTANT_SCOPE_SESSION_EXPENSE
)
assert.equal(
inferAssistantScopeTarget('去北京出差报销标准是多少'),
ASSISTANT_SCOPE_SESSION_KNOWLEDGE
)
assert.notEqual(
inferAssistantScopeTarget('昨天去北京出差花了1000元'),
ASSISTANT_SCOPE_SESSION_APPLICATION
)
assert.match(appShellComposable, /fetchOntologyParse/)
assert.match(appShellComposable, /resolveWorkbenchSessionTypeFromOntology/)
assert.match(appShellComposable, /resolveWorkbenchSessionTypeFallback/)
assert.match(appShellRouteView, /:initial-session-type="smartEntryContext\.sessionType"/)
assert.match(assistantScript, /initialSessionType:\s*\{[\s\S]*type:\s*String/)
})
test('workbench model routing maps ontology result before entering assistant', () => {
const travelOntology = {
scenario: 'expense',
intent: 'draft',
entities: [
{ type: 'expense_type', normalized_value: 'travel' }
]
}
const reimbursementOntology = {
scenario: 'expense',
intent: 'draft',
entities: [
{ type: 'expense_type', normalized_value: 'travel' }
]
}
const applicationOntology = {
scenario: 'expense',
intent: 'draft',
entities: [
{ type: 'document_type', normalized_value: 'expense_application' },
{ type: 'workflow_stage', normalized_value: 'pre_approval' }
]
}
assert.equal(
resolveWorkbenchSessionTypeFromOntology(
travelOntology,
'下周去上海支撑客户系统上线预计3天',
ASSISTANT_SCOPE_SESSION_EXPENSE
),
ASSISTANT_SCOPE_SESSION_APPLICATION
)
assert.equal(
resolveWorkbenchSessionTypeFromOntology(
reimbursementOntology,
'我要报销去北京出差的费用',
ASSISTANT_SCOPE_SESSION_APPLICATION
),
ASSISTANT_SCOPE_SESSION_EXPENSE
)
assert.equal(
resolveWorkbenchSessionTypeFromOntology(
{ scenario: 'expense', intent: 'query', entities: reimbursementOntology.entities },
'去北京出差报销标准是多少',
ASSISTANT_SCOPE_SESSION_KNOWLEDGE
),
ASSISTANT_SCOPE_SESSION_KNOWLEDGE
)
assert.equal(
resolveWorkbenchSessionTypeFromOntology(
applicationOntology,
'国网仿生产环境部署',
ASSISTANT_SCOPE_SESSION_EXPENSE
),
ASSISTANT_SCOPE_SESSION_APPLICATION
)
})