Files
wecom_it_smart_desk/scripts/init_quick_rules.sql
T
Simon 7864ab404b feat(scripts): 收纳运维/部署/修复/调试脚本到 scripts/ 目录
**目录结构**:
- scripts/                 顶层运维/工具脚本(20 个)
- scripts/deploy/          一键部署脚本(deploy_*.py / upload_*.py / redeploy.py 等 8 个)
- scripts/fix/             一次性修复脚本(fix_*.py / fix_*.cypher / fix_*.sql 等 9 个)
- scripts/debug/           调试脚本集合(check_*.py/sql、test_*.py、debug_*.py 等 42 个)

**ops-tools/jms_ops.py**:jumpserver-ops skill 默认路径修复
- 从 'jumpserver-automation-shareable' 改为 'jumpserver-ops'
- 同步更新注释(优先 JP_SKILL_DIR 环境变量)

**典型脚本用途**:
- scripts/deploy-v1.2.ps1 / -staging.ps1:一键部署 v1.2 到生产 / staging
- scripts/init_quick_rules.sql:quick_rules 表初始数据
- scripts/gen_admin_token.py:生成 admin JWT token(调试用)
- scripts/build-and-verify.sh:v1.1 实施验证脚本
- scripts/verify_*.sh / .py:API/quick_rules 验证
- scripts/fix/*.py:环境修复(compose、env_key、itsm_bridge 等)

合计 81 文件 + 3317 行 / - 1 行
2026-08-03 18:48:02 +08:00

111 lines
6.0 KiB
SQL
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.
-- =============================================================================
-- 企微IT智能服务台 — 快速规则初始化数据
-- =============================================================================
-- 说明:将硬编码的快速规则迁移到数据库
-- 适用:首次部署 / 从硬编码迁移到数据库
-- 日期:2026-07-27
-- =============================================================================
-- 清空现有数据(仅首次部署时使用)
-- TRUNCATE TABLE quick_rules RESTART IDENTITY;
-- --------------------------------------------------------------------------
-- 1. 打招呼关键词(来自 ai_handler.py
-- --------------------------------------------------------------------------
INSERT INTO quick_rules (rule_type, keyword, priority, is_active) VALUES
('greeting', '你好', 10, true),
('greeting', '您好', 9, true),
('greeting', 'hi', 8, true),
('greeting', 'hello', 7, true),
('greeting', '', 6, true),
('greeting', '在吗', 5, true),
('greeting', '在不在', 5, true),
('greeting', '哈喽', 4, true),
('greeting', '', 3, true),
('greeting', '早上好', 3, true),
('greeting', '下午好', 3, true),
('greeting', '晚上好', 3, true)
ON CONFLICT (rule_type, keyword) DO NOTHING;
-- --------------------------------------------------------------------------
-- 2. 业务路由预过滤关键词(来自 routing_service.py
-- --------------------------------------------------------------------------
INSERT INTO quick_rules (rule_type, category, keyword, priority, is_active) VALUES
-- 行政
('routing_prefilter', '行政', '复印机', 5, true),
('routing_prefilter', '行政', '扫描仪', 5, true),
('routing_prefilter', '行政', '保洁', 5, true),
('routing_prefilter', '行政', '名片印刷', 5, true),
-- IT服务
('routing_prefilter', 'IT服务', '打印机', 10, true),
('routing_prefilter', 'IT服务', '打印', 9, true),
('routing_prefilter', 'IT服务', '电脑', 8, true),
('routing_prefilter', 'IT服务', '网络', 8, true),
('routing_prefilter', 'IT服务', '软件', 7, true),
('routing_prefilter', 'IT服务', '重装', 7, true),
('routing_prefilter', 'IT服务', '装机', 7, true),
('routing_prefilter', 'IT服务', '显示器', 6, true),
('routing_prefilter', 'IT服务', '键盘', 5, true),
('routing_prefilter', 'IT服务', '鼠标', 5, true),
('routing_prefilter', 'IT服务', '耳机', 5, true),
('routing_prefilter', 'IT服务', '投影仪', 5, true),
('routing_prefilter', 'IT服务', '会议设备', 5, true),
-- 人力资源
('routing_prefilter', '人力资源', '工牌', 8, true),
('routing_prefilter', '人力资源', '考勤', 8, true),
('routing_prefilter', '人力资源', '入职', 7, true),
('routing_prefilter', '人力资源', '离职', 7, true),
('routing_prefilter', '人力资源', '社保', 6, true),
('routing_prefilter', '人力资源', '公积金', 6, true),
('routing_prefilter', '人力资源', '云盘', 5, true),
-- 财务
('routing_prefilter', '财务', '报销', 10, true),
('routing_prefilter', '财务', '发票', 9, true),
('routing_prefilter', '财务', '借款', 8, true),
('routing_prefilter', '财务', '工资条', 7, true),
-- 法务
('routing_prefilter', '法务', '合同', 10, true),
('routing_prefilter', '法务', '法务', 10, true),
('routing_prefilter', '法务', '知识产权', 8, true),
-- 行政-物业
('routing_prefilter', '行政-物业', '空调', 7, true),
('routing_prefilter', '行政-物业', '电梯', 7, true),
('routing_prefilter', '行政-物业', '门禁', 7, true),
('routing_prefilter', '行政-物业', '停车', 7, true)
ON CONFLICT (rule_type, keyword) DO NOTHING;
-- --------------------------------------------------------------------------
-- 3. 路由目标配置(来自 routing_service.py ROUTING_TARGETS
-- --------------------------------------------------------------------------
INSERT INTO quick_rules (rule_type, category, keyword, extra_data, priority, is_active) VALUES
('routing_target', '行政', '机票酒店前台',
'{"service_name": "机票酒店前台", "description": "受理和咨询机票、酒店、快递、访客、失物招领及行政办公相关事宜", "url": "https://work.weixin.qq.com/nl/innerkfid/ikfCtcYBwAAV00zNJGfmuA0aG1c2qCDnQ"}',
0, true),
('routing_target', '人力资源', '人力资源共享服务咨询',
'{"service_name": "人力资源共享服务咨询", "description": "咨询和处理人力资源相关问题(工牌/考勤/入离职/社保公积金等)", "url": "https://work.weixin.qq.com/nl/innerkfid/ikfCtcYBwAAvSRL5i5b_Xia8vCmFc2gRw"}',
0, true),
('routing_target', '财务', '总部报销服务台',
'{"service_name": "总部报销服务台", "description": "咨询和处理总部报销系统相关问题", "url": "https://work.weixin.qq.com/nl/innerkfid/ikfCtcYBwAAG4HC1zWJtPuALPKl2X6jcw"}',
0, true),
('routing_target', '法务', '行政法务团队',
'{"service_name": "行政法务团队", "description": "可咨询合同、合规、劳动争议、法律案件纠纷、外部检查、其他法律问题", "url": "https://work.weixin.qq.com/nl/innerkfid/ikfCtcYBwAABF746pGAY5WZ0mOTP6kGKA"}',
0, true),
('routing_target', '行政-物业', '物业服务',
'{"service_name": "物业服务", "description": "咨询和处理物业相关问题(空调/照明/门禁卡/车位/维修等)", "url": "https://work.weixin.qq.com/nl/innerkfid/ikfCtcYBwAAUtkMyOToCZqe42ZBDupVEQ"}',
0, true),
('routing_target', 'IT服务', 'IT人工坐席',
'{"service_name": "IT人工坐席", "description": "IT支持组人工服务(打印机/电脑/网络/软件安装等)", "url": "https://work.weixin.qq.com/nl/innerkfid/ikfCtcYBwAA人工坐席KFID", "is_agent": true}',
0, true)
ON CONFLICT (rule_type, keyword) DO NOTHING;
-- --------------------------------------------------------------------------
-- 验证数据
-- --------------------------------------------------------------------------
SELECT
rule_type,
COUNT(*) as count,
COUNT(CASE WHEN is_active THEN 1 END) as active_count
FROM quick_rules
GROUP BY rule_type
ORDER BY rule_type;