Files
Neo-ZQYY/db/zqyy_app/migrations/2026-03-31__task_stats_tables.sql
Neo 6f8f12314f feat: 累积功能变更 — 聊天集成、租户管理、小程序更新、ETL 增强、迁移脚本
包含多个会话的累积代码变更:
- backend: AI 聊天服务、触发器调度、认证增强、WebSocket、调度器最小间隔
- admin-web: ETL 状态页、任务管理、调度配置、登录优化
- miniprogram: 看板页面、聊天集成、UI 组件、导航更新
- etl: DWS 新任务(finance_area_daily/board_cache)、连接器增强
- tenant-admin: 项目初始化
- db: 19 个迁移脚本(etl_feiqiu 11 + zqyy_app 8)
- packages/shared: 枚举和工具函数更新
- tools: 数据库工具、报表生成、健康检查
- docs: PRD/架构/部署/合约文档更新

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 00:03:48 +08:00

48 lines
2.1 KiB
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 任务统计表2026-03-31
-- B: 按助教+月份汇总表
-- C: 关系指数表新增历史总计字段
BEGIN;
-- ═══════════════════════════════════════════════════════════
-- B: 新建 biz.dws_assistant_task_monthly按月汇总
-- ═══════════════════════════════════════════════════════════
CREATE TABLE IF NOT EXISTS biz.dws_assistant_task_monthly (
id BIGSERIAL PRIMARY KEY,
site_id BIGINT NOT NULL,
assistant_id BIGINT NOT NULL,
stat_month DATE NOT NULL, -- 月份第一天,如 2026-03-01
-- 创建数
recall_created INT NOT NULL DEFAULT 0,
follow_up_created INT NOT NULL DEFAULT 0,
relationship_created INT NOT NULL DEFAULT 0,
total_created INT NOT NULL DEFAULT 0,
-- 完成数
recall_completed INT NOT NULL DEFAULT 0,
follow_up_completed INT NOT NULL DEFAULT 0,
total_completed INT NOT NULL DEFAULT 0,
-- 其他状态
abandoned_count INT NOT NULL DEFAULT 0,
transferred_count INT NOT NULL DEFAULT 0,
-- 时间戳
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (site_id, assistant_id, stat_month)
);
COMMENT ON TABLE biz.dws_assistant_task_monthly IS '助教任务月度统计汇总';
COMMENT ON COLUMN biz.dws_assistant_task_monthly.stat_month IS '统计月份(月初日期)';
COMMENT ON COLUMN biz.dws_assistant_task_monthly.recall_created IS '当月创建的召回任务数high_priority + priority';
COMMENT ON COLUMN biz.dws_assistant_task_monthly.recall_completed IS '当月完成的召回任务数';
CREATE INDEX IF NOT EXISTS idx_task_monthly_site_month
ON biz.dws_assistant_task_monthly (site_id, stat_month DESC);
CREATE INDEX IF NOT EXISTS idx_task_monthly_assistant
ON biz.dws_assistant_task_monthly (assistant_id, stat_month DESC);
COMMIT;
-- ROLLBACK:
-- DROP TABLE IF EXISTS biz.dws_assistant_task_monthly;