feat: 增强知识库索引与设置页面模块化拆分
扩展知识库索引任务和 RAG 检索支持增量入库和文档去重,优 化本体检测和规则匹配精度,前端设置页面拆分为 LLM、邮件 和 Hermes 员工同步子面板并重构样式,新增日志详情组件和 知识入库日志模型,补充单元测试覆盖。
This commit is contained in:
150
web/src/utils/hermesEmployeeSettingsModel.js
Normal file
150
web/src/utils/hermesEmployeeSettingsModel.js
Normal file
@@ -0,0 +1,150 @@
|
||||
/** 数字员工设置:面向管理员的简明任务列表(频率固定,仅可调执行时间) */
|
||||
export const HERMES_SIMPLE_TASKS = [
|
||||
{
|
||||
id: 'knowledgeAggregation',
|
||||
label: '知识库同步',
|
||||
hint: '同步制度文档与知识索引',
|
||||
frequency: 'daily',
|
||||
frequencyLabel: '每天'
|
||||
},
|
||||
{
|
||||
id: 'ruleReviewDigest',
|
||||
label: '规则待审提醒',
|
||||
hint: '汇总待审规则并推送管理员',
|
||||
frequency: 'daily',
|
||||
frequencyLabel: '每天'
|
||||
},
|
||||
{
|
||||
id: 'riskSummary',
|
||||
label: '风险每日巡检',
|
||||
hint: '扫描报销、付款等风险信号',
|
||||
frequency: 'daily',
|
||||
frequencyLabel: '每天'
|
||||
},
|
||||
{
|
||||
id: 'archiveDigest',
|
||||
label: '归档周报',
|
||||
hint: '汇总已归档报销单',
|
||||
frequency: 'weekly',
|
||||
frequencyLabel: '每周一',
|
||||
weekday: 1
|
||||
},
|
||||
{
|
||||
id: 'dailyStats',
|
||||
label: '日报统计',
|
||||
hint: '生成昨日报销与审批数据',
|
||||
frequency: 'daily',
|
||||
frequencyLabel: '每天'
|
||||
},
|
||||
{
|
||||
id: 'monthlyStats',
|
||||
label: '月报统计',
|
||||
hint: '每月 1 号生成上月汇总',
|
||||
frequency: 'monthly',
|
||||
frequencyLabel: '每月 1 日',
|
||||
monthDay: 1
|
||||
},
|
||||
{
|
||||
id: 'yearlyStats',
|
||||
label: '年报统计',
|
||||
hint: '每年 1 月 1 号生成上年汇总',
|
||||
frequency: 'yearly',
|
||||
frequencyLabel: '每年 1 月 1 日',
|
||||
month: 1,
|
||||
monthDay: 1
|
||||
}
|
||||
]
|
||||
|
||||
function buildDefaultSchedules() {
|
||||
const defaults = {
|
||||
knowledgeAggregation: { enabled: true, frequency: 'daily', time: '00:00', weekday: 1, monthDay: 1, month: 1 },
|
||||
ruleReviewDigest: { enabled: true, frequency: 'daily', time: '18:00', weekday: 5, monthDay: 1, month: 1 },
|
||||
riskSummary: { enabled: true, frequency: 'daily', time: '09:00', weekday: 1, monthDay: 1, month: 1 },
|
||||
archiveDigest: { enabled: false, frequency: 'weekly', time: '10:30', weekday: 1, monthDay: 1, month: 1 },
|
||||
dailyStats: { enabled: true, frequency: 'daily', time: '08:30', weekday: 1, monthDay: 1, month: 1 },
|
||||
monthlyStats: { enabled: true, frequency: 'monthly', time: '09:00', weekday: 1, monthDay: 1, month: 1 },
|
||||
yearlyStats: { enabled: false, frequency: 'yearly', time: '10:00', weekday: 1, monthDay: 1, month: 1 }
|
||||
}
|
||||
|
||||
for (const task of HERMES_SIMPLE_TASKS) {
|
||||
const schedule = defaults[task.id]
|
||||
if (!schedule) {
|
||||
continue
|
||||
}
|
||||
schedule.frequency = task.frequency
|
||||
if (task.weekday != null) {
|
||||
schedule.weekday = task.weekday
|
||||
}
|
||||
if (task.monthDay != null) {
|
||||
schedule.monthDay = task.monthDay
|
||||
}
|
||||
if (task.month != null) {
|
||||
schedule.month = task.month
|
||||
}
|
||||
}
|
||||
|
||||
return defaults
|
||||
}
|
||||
|
||||
export function buildDefaultHermesEmployeeForm() {
|
||||
return {
|
||||
masterEnabled: true,
|
||||
notifyOnFailure: true,
|
||||
capabilities: {
|
||||
knowledgeAggregation: true,
|
||||
ruleReviewDigest: true,
|
||||
riskSummary: true,
|
||||
archiveDigest: false,
|
||||
dailyStats: true,
|
||||
monthlyStats: true,
|
||||
yearlyStats: false
|
||||
},
|
||||
schedules: buildDefaultSchedules()
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeHermesEmployeeForm(override = {}) {
|
||||
const defaults = buildDefaultHermesEmployeeForm()
|
||||
const schedules = { ...defaults.schedules }
|
||||
|
||||
for (const [key, value] of Object.entries(override?.schedules || {})) {
|
||||
schedules[key] = { ...defaults.schedules[key], ...value }
|
||||
}
|
||||
|
||||
for (const task of HERMES_SIMPLE_TASKS) {
|
||||
if (schedules[task.id]) {
|
||||
schedules[task.id].frequency = task.frequency
|
||||
if (task.weekday != null) {
|
||||
schedules[task.id].weekday = task.weekday
|
||||
}
|
||||
if (task.monthDay != null) {
|
||||
schedules[task.id].monthDay = task.monthDay
|
||||
}
|
||||
if (task.month != null) {
|
||||
schedules[task.id].month = task.month
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...defaults,
|
||||
...override,
|
||||
capabilities: {
|
||||
...defaults.capabilities,
|
||||
...(override?.capabilities || {})
|
||||
},
|
||||
schedules
|
||||
}
|
||||
}
|
||||
|
||||
export function isHermesTaskEnabled(form, taskId) {
|
||||
return Boolean(form?.masterEnabled && form?.capabilities?.[taskId] && form?.schedules?.[taskId]?.enabled)
|
||||
}
|
||||
|
||||
export function countEnabledHermesTasks(form) {
|
||||
return HERMES_SIMPLE_TASKS.filter((task) => isHermesTaskEnabled(form, task.id)).length
|
||||
}
|
||||
|
||||
export function isHermesEmployeeSettingsReady(form) {
|
||||
return Boolean(!form?.masterEnabled || countEnabledHermesTasks(form) > 0)
|
||||
}
|
||||
Reference in New Issue
Block a user