feat: 新增智脑决策中心模块(决策中心/AI员工组织/知识资产)
- 新增 DecisionsPage、AgentsPage、KnowledgePage 三个页面 - 新增 DecisionCard、DecisionDrawer、DecisionSummary、KnowledgeCard、LoopHealthBar、AgentCard 组件 - 新增 decision-aggregator 决策聚合逻辑和 agents 数据 - Layout 导航重构:新增智脑决策分组,调整系统配置和经营本体分组 - BossPage 集成决策摘要和闭环健康度,利润机会池支持警告样式 - TasksPage 增强任务展示 - 抽屉式详情统一改为居中弹窗风格 - data.ts 后端调整 - run.md 更新数据库连接说明 - 新增玄谋智脑实际版建设方案文档 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1156,13 +1156,17 @@ router.get('/overview/profit-opportunity', async (req: AuthRequest, res) => {
|
||||
SELECT * FROM analytics.mv_dish_sku_abc_monthly WHERE month_start = $1
|
||||
),
|
||||
-- 食材成本差异:改用 mv_store_theoretical_actual_cost_monthly(门店级理论vs实际成本)
|
||||
-- 注意:排除理论成本口径异常门店(theoretical_cost_rate_pct < 10 或 comparison_status = '理论成本口径异常')
|
||||
-- 这些门店POS系统未配置BOM,理论成本为0,差异=全部实际成本,会严重虚高利润机会
|
||||
cost_diff AS (
|
||||
SELECT
|
||||
count(*) FILTER (WHERE food_cost_variance > 0) AS over_cost_stores,
|
||||
round(sum(food_cost_variance) FILTER (WHERE food_cost_variance > 0)::numeric, 2) AS total_positive_variance,
|
||||
round(sum(theoretical_cost)::numeric, 2) AS total_theoretical_cost,
|
||||
round(sum(actual_food_cost)::numeric, 2) AS total_actual_cost,
|
||||
round(sum(sales_received)::numeric, 2) AS total_received
|
||||
count(*) FILTER (WHERE food_cost_variance > 0 AND theoretical_cost_rate_pct >= 10) AS over_cost_stores,
|
||||
round(sum(food_cost_variance) FILTER (WHERE food_cost_variance > 0 AND theoretical_cost_rate_pct >= 10)::numeric, 2) AS total_positive_variance,
|
||||
round(sum(theoretical_cost) FILTER (WHERE theoretical_cost_rate_pct >= 10)::numeric, 2) AS total_theoretical_cost,
|
||||
round(sum(actual_food_cost) FILTER (WHERE theoretical_cost_rate_pct >= 10)::numeric, 2) AS total_actual_cost,
|
||||
round(sum(sales_received) FILTER (WHERE theoretical_cost_rate_pct >= 10)::numeric, 2) AS total_received,
|
||||
count(*) FILTER (WHERE food_cost_variance > 0 AND (theoretical_cost_rate_pct < 10 OR theoretical_cost_rate_pct IS NULL)) AS excluded_stores,
|
||||
round(sum(food_cost_variance) FILTER (WHERE food_cost_variance > 0 AND (theoretical_cost_rate_pct < 10 OR theoretical_cost_rate_pct IS NULL))::numeric, 2) AS excluded_variance
|
||||
FROM analytics.mv_store_theoretical_actual_cost_monthly
|
||||
WHERE month_start = $1
|
||||
),
|
||||
@@ -1172,7 +1176,7 @@ router.get('/overview/profit-opportunity', async (req: AuthRequest, res) => {
|
||||
round(actual_food_cost_rate_pct::numeric, 2) AS actual_cost_rate,
|
||||
round(theoretical_cost_rate_pct::numeric, 2) AS theoretical_cost_rate
|
||||
FROM analytics.mv_store_theoretical_actual_cost_monthly
|
||||
WHERE month_start = $1 AND food_cost_variance > 0
|
||||
WHERE month_start = $1 AND food_cost_variance > 0 AND theoretical_cost_rate_pct >= 10
|
||||
ORDER BY food_cost_variance DESC
|
||||
LIMIT 5
|
||||
),
|
||||
@@ -1278,7 +1282,10 @@ router.get('/overview/profit-opportunity', async (req: AuthRequest, res) => {
|
||||
'owner', '商品/供应链/门店',
|
||||
'evidence', '采购价差、用量差、盘点差、报损差',
|
||||
'detail', (SELECT
|
||||
'超耗门店' || (SELECT over_cost_stores FROM cost_diff) || '家,实际食材成本' || (SELECT total_actual_cost FROM cost_diff) || '元 vs 理论成本' || (SELECT total_theoretical_cost FROM cost_diff) || '元,正差异合计' || (SELECT total_positive_variance FROM cost_diff) || '元。\n\n' ||
|
||||
'超耗门店' || (SELECT over_cost_stores FROM cost_diff) || '家(已排除' || (SELECT excluded_stores FROM cost_diff) || '家理论成本口径异常门店),实际食材成本' || (SELECT total_actual_cost FROM cost_diff) || '元 vs 理论成本' || (SELECT total_theoretical_cost FROM cost_diff) || '元,正差异合计' || (SELECT total_positive_variance FROM cost_diff) || '元。\n\n' ||
|
||||
CASE WHEN (SELECT excluded_stores FROM cost_diff) > 0 THEN
|
||||
'⚠ 口径异常说明:\n' || (SELECT excluded_stores FROM cost_diff) || '家门店(工体店、北清路店等)POS系统未配置BOM,理论成本为0,差异=' || (SELECT excluded_variance FROM cost_diff) || '元已排除,不计入利润机会。需补齐BOM配置后方可纳入分析。\n\n'
|
||||
ELSE '' END ||
|
||||
'超耗TOP5门店(需优先排查):\n' ||
|
||||
string_agg(store_name || ':差异' || diff_amount || '元(实际成本率' || actual_cost_rate || '% vs 理论' || theoretical_cost_rate || '%,实收' || received || '元)', ';\n') ||
|
||||
'\n\n行动指向:\n1)上述5家门店实际成本率均远超理论值,需逐店排查采购单价与BOM标准价差异;\n2)盘点差——核查月末盘点与系统库存一致性,差异>3%需复盘;\n3)报损差——对比报损记录与行业基准,报损率>2%的门店需检查存储和加工流程;\n4)30天目标:回收正差异的30%,预计节约' || round((SELECT total_positive_variance FROM cost_diff) * 0.30, 2) || '元。'
|
||||
|
||||
Reference in New Issue
Block a user