init
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
[General]
|
||||
# 默认使用的模型配置区域
|
||||
DEFAULT_MODEL_SECTION = qwen-80b
|
||||
# 最大重试次数
|
||||
MAX_RETRIES = 3
|
||||
# 请求超时时间
|
||||
TIMEOUT = 30
|
||||
|
||||
|
||||
[qwen-32b]
|
||||
# 模型名称
|
||||
MODEL_NAME = qwen-32b
|
||||
# API Key
|
||||
OPENAI_API_KEY = 123ffa18-3baf-4f39-9698-fdf680d15f36
|
||||
# URL
|
||||
URL = http://led-gateway.lenovo.com:30089/intranet/qwen3-coder-30b/v1
|
||||
|
||||
[qwen-80b]
|
||||
MODEL_NAME = Qwen3-Next-80B-A3B-Instruct
|
||||
OPENAI_API_KEY = 123ffa18-3baf-4f39-9698-fdf680d15f36
|
||||
URL = http://led-gateway.lenovo.com:30089/intranet/qwen3-next-80b-a3b-instruct/v1
|
||||
|
||||
[sr_api]
|
||||
url = http://ipc.lenovo.com/gateway/bgs-ai/Report/fetchData
|
||||
llzAppkey = e0578e6a-f045-4f3e-93c0-5957c8b1915e
|
||||
llzSercret = BFhItTCY5FqgtHAdn0eaxAGix/25oR8YfxYKfSPgrJb8zxYG06kBeoip0DEGjekfh43223atdBDXBwUmw18NXp/2piZamnUwlFWYFAGfpBCwy3K+921KI5ZaWRWcMCCcCKOYF/2feMg72owUhno2JXqSUcb8HBhang==
|
||||
|
||||
|
||||
[ragflow]
|
||||
url = http://led-ai-ragflow.lenovo.com
|
||||
api_key = ragflow-gOOQ93FvWdyhP3i1J1xXFKVxWucgtF0bwbthuDJk5vs
|
||||
retrieval = /api/v1/retrieval
|
||||
retrieval_top_k = 3
|
||||
cache_ttl = 600
|
||||
table_retrieval_dataset_id = 9945baf512ea11f18ccb6a681b3130b2
|
||||
sql_gen_dataset_id = ee68f53a12ec11f18e436a681b3130b2
|
||||
|
||||
[redis]
|
||||
enabled = true
|
||||
host = led-redis.lenovo.com
|
||||
port = 30398
|
||||
password = bgs123456
|
||||
database = 0
|
||||
sql_prompt_ttl = 600
|
||||
|
||||
[stream]
|
||||
progress_interval = 0.3
|
||||
|
||||
[logging_mysql]
|
||||
enabled = false
|
||||
host = 127.0.0.1
|
||||
port = 3306
|
||||
user = root
|
||||
password =
|
||||
database = more_dots
|
||||
table = structured_logs
|
||||
connect_timeout = 5
|
||||
|
||||
|
||||
[app]
|
||||
service_name = local-model-streaming-api
|
||||
host = 0.0.0.0
|
||||
port = 8000
|
||||
version = 1.0.0
|
||||
|
||||
[nacos]
|
||||
enabled = false
|
||||
server = 10.122.132.204:8848
|
||||
namespace = prod
|
||||
group_name = BGS
|
||||
username = nacos
|
||||
password = bgs20250901
|
||||
|
||||
@@ -34,12 +34,33 @@ model_section = gpt-4o
|
||||
url = http://10.122.176.97:21020
|
||||
api_key = ragflow-xxxxx
|
||||
retrieval = /api/v1/retrieval
|
||||
upload = /api/v1/documents
|
||||
# 上传模式:overwrite(覆盖更新)或 append(追加)
|
||||
upload_mode = overwrite
|
||||
retrieval_top_k = 3
|
||||
table_retrieval_dataset_id =
|
||||
sql_gen_dataset_id =
|
||||
|
||||
[redis]
|
||||
# 是否启用 Redis 缓存(用于 sql_gen_prompts)
|
||||
enabled = false
|
||||
url = redis://localhost:6379/0
|
||||
db = 0
|
||||
# SQL 提示词缓存过期秒数
|
||||
sql_prompt_ttl = 600
|
||||
|
||||
[stream]
|
||||
# /api/workflows/stream 进度事件间隔(秒)
|
||||
progress_interval = 0.3
|
||||
|
||||
[logging_mysql]
|
||||
# 是否启用结构化日志写入 MySQL
|
||||
enabled = false
|
||||
host = 127.0.0.1
|
||||
port = 3306
|
||||
user = root
|
||||
password =
|
||||
database = more_dots
|
||||
table = structured_logs
|
||||
connect_timeout = 5
|
||||
|
||||
[nacos]
|
||||
# 是否启用 Nacos 注册
|
||||
enabled = false
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
{
|
||||
"meta": {
|
||||
"domain": "订单消耗与积压统计",
|
||||
"data_source": "dwd_ai.apbo_hic_ssoc_consumption",
|
||||
"description": "此模型用于分析HIC和SSOC系统的订单消耗情况、积压订单统计及订单状态追踪,通过订单创建日期进行时间维度分析。",
|
||||
"fields_list": ["so", "soid", "original_pn", "ship_pn", "service_delivery_type", "warranty", "actual_wh", "item_status", "item_creation_date", "allocation_datetime", "backlog_status", "system_flag", "machine_type"]
|
||||
},
|
||||
"data_model_specification": {
|
||||
"core_status_fields": {
|
||||
"backlog_status": {
|
||||
"type": "varchar(64)",
|
||||
"meaning": "积压状态标识,'1'表示积压订单,其他值为非积压订单",
|
||||
"business_rule": "backlog_status = '1' 标识为积压订单"
|
||||
},
|
||||
"system_flag": {
|
||||
"type": "varchar(64)",
|
||||
"meaning": "系统来源标识",
|
||||
"values": ["HIC", "SSOC"],
|
||||
"business_rule": "区分订单来自HIC系统还是SSOC系统"
|
||||
},
|
||||
"machine_type": {
|
||||
"type": "varchar(64)",
|
||||
"meaning": "客户购买成品的系列",
|
||||
"business_rule": "用于按产品系列进行过滤和分析,例如:machine_type = '20LN'"
|
||||
}
|
||||
},
|
||||
"mandatory_display_fields": {
|
||||
"rule": "以下三个核心维度字段建议出现在SELECT子句中,特别是进行分组统计时。否则应展示fields_list中的全部字段",
|
||||
"actual_fields": ["item_creation_date", "system_flag", "backlog_status"],
|
||||
"user_alias": ["创建日期", "系统来源", "积压状态"],
|
||||
"exception_condition": "如果用户明确指定字段数≤2,且均为具体业务字段,则可以不包含全部建议字段。"
|
||||
},
|
||||
"other_fields": {
|
||||
"order_info_fields": ["so", "soid", "original_pn", "ship_pn"],
|
||||
"service_fields": ["service_delivery_type", "warranty"],
|
||||
"warehouse_fields": ["actual_wh"],
|
||||
"status_fields": ["item_status"],
|
||||
"time_fields": ["allocation_datetime"],
|
||||
"product_series_fields": ["machine_type"]
|
||||
},
|
||||
"date_field": {
|
||||
"primary_date": "item_creation_date",
|
||||
"format": "DATE类型",
|
||||
"usage": "主要的时间维度字段,用于按日期统计"
|
||||
}
|
||||
},
|
||||
"business_logic_rules": {
|
||||
"alias_handling": "将用户提到的业务术语别名转换为完整字段名后再生成SQL",
|
||||
"field_selection_logic": {
|
||||
"priority_order": [
|
||||
{
|
||||
"level": 1,
|
||||
"name": "用户指定字段",
|
||||
"rule": "首先添加用户明确提到的所有字段。"
|
||||
},
|
||||
{
|
||||
"level": 2,
|
||||
"name": "必要补充字段",
|
||||
"rule": "如果用户查询涉及时间、系统或状态分析,建议补充相关维度字段。",
|
||||
"threshold": "用户查询涉及分组统计时建议补充item_creation_date和system_flag"
|
||||
},
|
||||
{
|
||||
"level": 3,
|
||||
"name": "智能推断字段",
|
||||
"rules": [
|
||||
{
|
||||
"trigger": ["积压", "backlog", "积压订单", "待处理"],
|
||||
"add_fields": ["backlog_status"],
|
||||
"where_condition": "backlog_status = '1'"
|
||||
},
|
||||
{
|
||||
"trigger": ["系统", "来源", "HIC", "SSOC"],
|
||||
"add_fields": ["system_flag"]
|
||||
},
|
||||
{
|
||||
"trigger": ["日期", "时间", "创建时间", "item_creation"],
|
||||
"add_fields": ["item_creation_date"]
|
||||
},
|
||||
{
|
||||
"trigger": ["订单", "so", "订单号"],
|
||||
"add_fields": ["so", "soid"]
|
||||
},
|
||||
{
|
||||
"trigger": ["物料", "PN", "料号", "零件"],
|
||||
"add_fields": ["original_pn", "ship_pn"]
|
||||
},
|
||||
{
|
||||
"trigger": ["仓库", "actual_wh", "出货仓库"],
|
||||
"add_fields": ["actual_wh"]
|
||||
},
|
||||
{
|
||||
"trigger": ["状态", "item_status", "订单状态"],
|
||||
"add_fields": ["item_status"]
|
||||
},
|
||||
{
|
||||
"trigger": ["系列", "成品系列", "machine_type", "20LN", "产品类型"],
|
||||
"add_fields": ["machine_type"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"level": 4,
|
||||
"name": "时间维度处理",
|
||||
"rules": [
|
||||
{
|
||||
"condition": "用户查询涉及统计、趋势、每日等时间概念",
|
||||
"action": "必须包含item_creation_date字段"
|
||||
},
|
||||
{
|
||||
"condition": "用户指定具体日期范围",
|
||||
"action": "在WHERE条件中添加日期范围过滤"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"backlog_logic": {
|
||||
"definition": "backlog_status = '1' 表示积压订单,这是核心业务标识",
|
||||
"inclusion_rule": "当用户查询涉及积压相关分析时,默认WHERE条件包含backlog_status = '1'",
|
||||
"important_note": "统计总订单数时需要同时考虑积压和非积压状态"
|
||||
}
|
||||
},
|
||||
"aggregation_mode": {
|
||||
"trigger_keywords": ["统计", "汇总", "总数", "有多少", "数量", "按...分组", "每个", "每日", "count", "sum", "total", "group by", "趋势", "分布"],
|
||||
"column_naming_rules": {
|
||||
"aggregate_functions": {
|
||||
"COUNT": "COUNT({column}) AS {column}_count",
|
||||
"COUNT_DISTINCT": "COUNT(DISTINCT {column}) AS {column}_distinct_count",
|
||||
"SUM_CASE": "SUM(CASE WHEN {condition} THEN 1 ELSE 0 END) AS {alias}_count"
|
||||
},
|
||||
"group_by_fields": "保持原字段名",
|
||||
"examples": [
|
||||
"用户说'按日期统计积压订单数' → SELECT item_creation_date, COUNT(*) AS backlog_count WHERE backlog_status = '1' GROUP BY item_creation_date",
|
||||
"用户说'统计每个系统的订单数' → SELECT system_flag, COUNT(*) AS order_count GROUP BY system_flag",
|
||||
"用户说'按产品系列统计订单数' → SELECT machine_type, COUNT(*) AS order_count GROUP BY machine_type"
|
||||
]
|
||||
},
|
||||
"allowed_group_by_fields": ["item_creation_date", "system_flag", "backlog_status", "actual_wh", "item_status", "service_delivery_type", "warranty", "machine_type"]
|
||||
},
|
||||
"default_behavior": {
|
||||
"sorting": {
|
||||
"date_queries": "item_creation_date DESC",
|
||||
"count_queries": "按统计字段降序",
|
||||
"default": "item_creation_date DESC"
|
||||
},
|
||||
"limit": "禁止使用LIMIT",
|
||||
"backlog_filter": "当用户明确查询'积压订单'时,WHERE条件包含backlog_status = '1'"
|
||||
},
|
||||
"special_scenarios": {
|
||||
"积压率计算": "积压订单数 / 总订单数",
|
||||
"系统对比": "HIC vs SSOC 系统订单分布",
|
||||
"时间趋势": "按日/月统计订单创建趋势",
|
||||
"物料分析": "按original_pn或ship_pn统计热门物料",
|
||||
"产品系列分析": "按machine_type统计不同产品系列的订单分布"
|
||||
}
|
||||
},
|
||||
"field_mapping_reference": {
|
||||
"key_fields": {
|
||||
"backlog_status": "积压状态标识('1'=积压订单)",
|
||||
"system_flag": "系统来源(HIC/SSOC)",
|
||||
"item_creation_date": "订单创建日期(主要时间维度)",
|
||||
"so": "订单号",
|
||||
"soid": "订单ID",
|
||||
"original_pn": "原始物料号",
|
||||
"ship_pn": "出货物料号",
|
||||
"machine_type": "客户购买成品的系列"
|
||||
},
|
||||
"alias_mapping": {
|
||||
"创建日期": "item_creation_date",
|
||||
"日期": "item_creation_date",
|
||||
"系统": "system_flag",
|
||||
"来源": "system_flag",
|
||||
"积压": "backlog_status",
|
||||
"订单号": "so",
|
||||
"订单": "so",
|
||||
"物料": "original_pn",
|
||||
"料号": "original_pn",
|
||||
"PN": "original_pn",
|
||||
"出货PN": "ship_pn",
|
||||
"仓库": "actual_wh",
|
||||
"状态": "item_status",
|
||||
"系列": "machine_type",
|
||||
"成品系列": "machine_type",
|
||||
"产品类型": "machine_type",
|
||||
"机器类型": "machine_type"
|
||||
},
|
||||
"mapping_rule": "生成SQL时必须使用右侧的完整字段名,用户别名仅用于理解意图"
|
||||
},
|
||||
"examples": {
|
||||
"统计查询": {
|
||||
"user": "统计每日的订单总数和积压订单数",
|
||||
"sql": "SELECT item_creation_date, COUNT(*) AS total_orders, SUM(CASE WHEN backlog_status = '1' THEN 1 ELSE 0 END) AS backlog_orders FROM dwd_ai.apbo_hic_ssoc_consumption GROUP BY item_creation_date ORDER BY item_creation_date DESC"
|
||||
},
|
||||
"物料分析": {
|
||||
"user": "查看积压最多的物料Top 10",
|
||||
"sql": "SELECT original_pn, COUNT(*) AS backlog_count FROM dwd_ai.apbo_hic_ssoc_consumption WHERE backlog_status = '1' GROUP BY original_pn ORDER BY backlog_count DESC"
|
||||
},
|
||||
"时间范围查询": {
|
||||
"user": "查询2024年1月的所有订单",
|
||||
"sql": "SELECT so, soid, original_pn, system_flag, backlog_status, item_creation_date FROM dwd_ai.apbo_hic_ssoc_consumption WHERE item_creation_date >= '2024-01-01' AND item_creation_date <= '2024-01-31' ORDER BY item_creation_date DESC"
|
||||
},
|
||||
"复合条件查询": {
|
||||
"user": "查询SSOC系统中实际仓库为3001的非积压订单",
|
||||
"sql": "SELECT so, soid, original_pn, item_creation_date, item_status FROM dwd_ai.apbo_hic_ssoc_consumption WHERE system_flag = 'SSOC' AND actual_wh = '3001' AND backlog_status != '1' ORDER BY item_creation_date DESC"
|
||||
},
|
||||
"按日期和产品系列过滤查询": {
|
||||
"user": "查询20260115, 20LN系列的订单",
|
||||
"sql": "SELECT so, soid, machine_type, original_pn, ship_pn, service_delivery_type, warranty, actual_wh, item_status, item_creation_date, allocation_datetime, backlog_status, system_flag FROM dwd_ai.apbo_hic_ssoc_consumption WHERE machine_type = '20LN' AND item_creation_date = '2026-01-15' ORDER BY item_creation_date DESC"
|
||||
},
|
||||
"产品系列统计": {
|
||||
"user": "按产品系列统计订单总数",
|
||||
"sql": "SELECT machine_type, COUNT(*) AS order_count FROM dwd_ai.apbo_hic_ssoc_consumption GROUP BY machine_type ORDER BY order_count DESC"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"meta": {
|
||||
"domain": "订单物流节点(Milestone)追踪与查询",
|
||||
"keywords": ["milestone", "物流节点", "运输节点", "logistics node", "shipment tracking", "节点查询", "节点状态", "节点时间", "节点跟踪", "里程碑", "节点明细"],
|
||||
"description": "此模型用于查询订单在物流运输全链路中的关键节点(milestone)信息,追踪从订单创建、提货、运输到签收的完整状态流。每个订单可对应多个节点记录以反映运输进度。"
|
||||
},
|
||||
"data_model_specification": {
|
||||
"data_source": "dwd_ai.apbo_milestone_info",
|
||||
"fields_list": ["service_order_id", "soid", "part_number", "PO", "po_creation_date", "prid", "DN", "dn_date", "gi_date", "BOL", "hawb", "pickup_time", "etd", "atd", "eta", "ata", "pod", "gr_date", "status", "status_date", "service_order_creation_date", "so_eta", "topmost_pn", "commodity_code", "ship_to_country", "region", "dc_plant", "mtm", "machine_sn","machine_type", "whether_premier", "stm_planner", "category", "lenovo_ref_no"],
|
||||
"mandatory_display_fields": {
|
||||
"rule1": "字段默认全部展示。日期字段需格式化为指定字符串格式。",
|
||||
"rule2": "select时,所有NULL值使用空字符串''代替",
|
||||
"rule3": "部分字段select时的顺序如下:po,po_creation_date,prid,dn,dn_date,gi_date,bol,hawb,pickup_time,etd,atd,eta,ata,pod,gr_date",
|
||||
"rule4": "禁止使用limit"
|
||||
},
|
||||
|
||||
"optional_fields": {
|
||||
"material_fields": ["topmost_pn", "commodity_code"],
|
||||
"location_fields": ["ship_to_country", "region", "dc_plant"],
|
||||
"machine_fields": ["mtm", "machine_sn","machine_type"],
|
||||
"service_fields": ["whether_premier", "stm_planner", "lenovo_ref_no"],
|
||||
"Field_combination": ["category", "status", "status_date"]
|
||||
}
|
||||
},
|
||||
|
||||
"business_logic_rules": {
|
||||
"query_recognition_rules": {
|
||||
"milestone_keywords": ["物流节点", "运输节点", "节点", "里程碑", "milestone", "logistics node", "节点时间", "节点状态", "节点查询", "节点跟踪"],
|
||||
"filter_based_patterns": ["查询{单据号}的物流节点", "追踪{订单号}的节点信息", "显示{节点状态}的订单", "查找{节点时间}的物流记录", "获取{节点类型}的详细信息"]
|
||||
},
|
||||
"default_behavior": {
|
||||
"sorting": "status_date DESC, service_order_creation_date DESC"
|
||||
}
|
||||
},
|
||||
|
||||
"field_mapping_reference": {
|
||||
"key_identifiers": {
|
||||
"service_order_id": {"type": "varchar(20)", "desc": "主订单号,唯一标识", "example": "4020438779", "required": true, "alias": ["SO", "订单号", "服务订单", "so", "order_no", "Service Order"]},
|
||||
"soid": {"type": "varchar(22)", "desc": "服务订单明细ID=service_order_id+两位序号", "example": "402043877920", "required": true, "alias": ["SOID", "订单明细", "服务订单明细", "soid", "Service Order Item Detail"]},
|
||||
"part_number": {"type": "varchar(30)", "desc": "原始申请物料号", "example": "5CB1L57599", "required": true, "alias": ["pn", "物料号", "零件号", "Part Number", "材料号"]}
|
||||
},
|
||||
|
||||
"milestone_document_fields": {
|
||||
"bol": {"type": "varchar(50)", "desc": "提单号(Bill of Lading)", "example": "BOL20231027001", "alias": ["提单", "海运提单", "提单号", "Bill of Lading", "B/L"]},
|
||||
"dn": {"type": "varchar(50)", "desc": "发货单号(Delivery Note)", "example": "DN20231027001", "alias": ["发货单", "送货单", "DN单", "Delivery Note", "发货单据"]},
|
||||
"po": {"type": "varchar(50)", "desc": "采购单号(Purchase Order)", "example": "PO20231027001", "alias": ["采购单", "PO单", "采购订单", "Purchase Order", "采购订单号"]},
|
||||
"hawb": {"type": "varchar(50)", "desc": "空运主单号(House Air Waybill)", "example": "HAWB12345678", "alias": ["空运单", "航空运单", "HAWB", "Air Waybill", "空运提单"]},
|
||||
"prid": {"type": "varchar(50)", "desc": "运输参考ID(PRID)", "example": "PRID123456", "alias": ["运输参考号", "PRID号", "运输ID", "运输参考ID", "Shipping Reference ID"]}
|
||||
},
|
||||
|
||||
"milestone_date_fields": {
|
||||
"service_order_creation_date": {"type": "date", "desc": "服务订单创建日期", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["订单创建时间", "SO创建时间", "服务订单创建时间", "Order Creation Date"]},
|
||||
"po_creation_date": {"type": "date", "desc": "采购单创建日期", "format": "YYYY-MM-DD", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["采购单创建时间", "PO创建时间", "采购订单创建日期", "Purchase Order Creation Date"]},
|
||||
"dn_date": {"type": "date", "desc": "发货单创建日期", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["发货单日期", "DN日期", "发货时间", "Delivery Note Date"]},
|
||||
"gi_date": {"type": "date", "desc": "货物发出日期(Goods Issue)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["货物发出时间", "发货日期", "出库时间", "Goods Issue Date", "出库日期"]},
|
||||
"pickup_time": {"type": "datetime", "desc": "提货时间", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["提货日期", "取货时间", "提货时间点", "Pickup Time", "提取时间"]},
|
||||
"etd": {"type": "date", "desc": "预计出发时间(Estimated Time of Departure)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["预计出发", "计划出发时间", "ETD", "预计离港时间"]},
|
||||
"atd": {"type": "date", "desc": "实际出发时间(Actual Time of Departure)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["实际出发", "实际离港时间", "ATD", "实际出发时间"]},
|
||||
"eta": {"type": "date", "desc": "预计到达时间(Estimated Time of Arrival)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["预计到达", "计划到达时间", "ETA", "预计到港时间"]},
|
||||
"ata": {"type": "date", "desc": "实际到达时间(Actual Time of Arrival)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["实际到达", "实际到港时间", "ATA", "实际到达时间"]},
|
||||
"pod": {"type": "date", "desc": "签收单收到日期(Proof of Delivery)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["签收时间", "POD时间", "签收日期", "Proof of Delivery", "签收证明时间"]},
|
||||
"gr_date": {"type": "date", "desc": "收货日期(Goods Receipt)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["收货时间", "入库时间", "GR时间", "Goods Receipt Date", "收货日期"]},
|
||||
"status_date": {"type": "date", "desc": "状态最后更新时间", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["状态更新时间", "最后更新", "状态日期", "Status Update Date"]},
|
||||
"so_eta": {"type": "date", "desc": "订单预计到达时间(SO ETA)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["订单最终到达时间", "订单ETA", "服务订单预计到达", "Service Order ETA"]}
|
||||
},
|
||||
|
||||
"additional_fields": {
|
||||
"topmost_pn": {"type": "varchar(30)", "desc": "最优替换物料号", "example": "5CB1L57599", "alias": ["tp", "最优物料", "Topmost Part Number", "首选物料号", "最优替换零件"]},
|
||||
"commodity_code": {"type": "varchar(2)", "desc": "商品分类代码", "example": "PL", "alias": ["cc", "商品代码", "物料分类", "Commodity Code", "商品类别"]},
|
||||
"ship_to_country": {"type": "varchar(2)", "desc": "目的地国家ISO代码", "example": "PH", "alias": ["目的地国家", "收货国家", "Ship to Country", "目标国家", "送达国家"]},
|
||||
"region": {"type": "varchar(10)", "desc": "区域代码", "example": "CAP", "alias": ["区域", "地区", "Region Code", "大区", "地域代码"]},
|
||||
"dc_plant": {"type": "varchar(10)", "desc": "发货配送中心", "example": "VN01", "alias": ["配送中心", "DC", "发货中心", "Distribution Center", "发货工厂"]},
|
||||
"mtm": {"type": "varchar(20)", "desc": "机器型号,请注意与mt区分,这不是mt,这是mtm,这是mtm,这是mtm", "example": "20QUS0SQ00", "alias": ["机型", "型号", "Machine Type Model", "设备型号", "机器型号代码"]},
|
||||
"machine_sn": {"type": "varchar(50)", "desc": "机器序列号", "example": "PW01554B", "alias": ["序列号", "SN", "Machine Serial Number", "设备序列号", "机器SN"]},
|
||||
"machine_type": {"type": "varchar(2048)","desc": "机器类型, 请注意与mtm区分,这不是mtm,这是mt,这是mt,这是mt","example": "20Q1","alias": ["MT","machine type", "机器类型"]},
|
||||
"whether_premier": {"type": "tinyint", "desc": "是否Premier服务", "values": {"0": "非Premier", "1": "Premier"}, "alias": ["是否Premier", "Premier服务", "是否优先", "Whether Premier", "优先服务标识"]},
|
||||
"stm_planner": {"type": "varchar(50)", "desc": "STM计划员姓名", "alias": ["计划员", "STM计划员", "STM Planner", "服务计划员", "运输计划员"]},
|
||||
"category": {"type": "varchar(20)", "desc": "订单类别", "values": ["Standard", "Emergency", "Critical"], "alias": ["类别", "订单类型", "Category", "服务类别", "订单分类"]},
|
||||
"status": {"type": "varchar(4096)", "desc": "状态", "example": "3001:02HL023*1(Need geo verify demand:2025-10-30)", "alias": ["状态"]},
|
||||
"lenovo_ref_no": {"type": "varchar(50)", "desc": "联想内部参考号", "alias": ["联想参考号", "内部参考号", "Lenovo Reference", "联想内部编号", "参考编号"]},
|
||||
"case_number": {"type": "string", "desc": "事件编号", "example": "CS12345678", "alias": ["case", "事件号", "案例号", "Case Number", "投诉编号", "事件编号"]}
|
||||
}
|
||||
},
|
||||
|
||||
"examples": {
|
||||
"基础查询": {
|
||||
"user": "查询订单的物流节点信息",
|
||||
"sql": "SELECT service_order_id, soid, part_number, bol, dn, po, hawb, prid, CAST(service_order_creation_date AS VARCHAR(2048)) as service_order_creation_date, CAST(po_creation_date AS VARCHAR(2048)) as po_creation_date, CAST(dn_date AS VARCHAR(2048)) as dn_date, CAST(gi_date AS VARCHAR(2048)) as gi_date, CAST(pickup_time AS VARCHAR(2048)) as pickup_time, CAST(etd AS VARCHAR(2048)) as etd, CAST(atd AS VARCHAR(2048)) as atd, CAST(eta AS VARCHAR(2048)) as eta, CAST(ata AS VARCHAR(2048)) as ata, CAST(pod AS VARCHAR(2048)) as pod, CAST(gr_date AS VARCHAR(2048)) as gr_date, CAST(status_date AS VARCHAR(2048)) as status_date, CAST(so_eta AS VARCHAR(2048)) as so_eta FROM dwd_ai.apbo_milestone_info ORDER BY status_date DESC, service_order_creation_date DESC",
|
||||
"field_selection_reason": "基础查询显示所有必填的milestone字段,包括新增的service_order_creation_date, so_eta,日期字段已格式化为指定字符串格式"
|
||||
},
|
||||
"按主订单号查询": {
|
||||
"user": "SO为4019630464的milestone信息",
|
||||
"sql": "SELECT service_order_id, soid, part_number, bol, dn, po, hawb, prid, CAST(service_order_creation_date AS VARCHAR(2048)) as service_order_creation_date, CAST(po_creation_date AS VARCHAR(2048)) as po_creation_date, CAST(dn_date AS VARCHAR(2048)) as dn_date, CAST(gi_date AS VARCHAR(2048)) as gi_date, CAST(pickup_time AS VARCHAR(2048)) as pickup_time, CAST(etd AS VARCHAR(2048)) as etd, CAST(atd AS VARCHAR(2048)) as atd, CAST(eta AS VARCHAR(2048)) as eta, CAST(ata AS VARCHAR(2048)) as ata, CAST(pod AS VARCHAR(2048)) as pod, CAST(gr_date AS VARCHAR(2048)) as gr_date, CAST(status_date AS VARCHAR(2048)) as status_date, CAST(so_eta AS VARCHAR(2048)) as so_eta FROM dwd_ai.apbo_milestone_info WHERE service_order_id = '4019630464' ORDER BY status_date DESC, service_order_creation_date DESC",
|
||||
"field_selection_reason": "用户提到'SO',根据映射规则应查询service_order_id字段,包含所有必填字段,日期字段已格式化为字符串"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
{
|
||||
"meta": {
|
||||
"domain": "亚太区物料库存与用量分析",
|
||||
"keywords": ["库存", "用量", "物料分析", "亚太区", "国家用量", "历史使用量", "近期用量", "IB", "库存数量"],
|
||||
"description": "此模型用于分析亚太地区各物料在不同区域,配送中心及目的地国家的库存情况,近期用量及历史使用量。特别注意:国家字段(AU, VN, JP等)是数值型用量字段,表示该物料在该国家的历史用量,不是国家代码。",
|
||||
"data_source": "dwd_ai.apbo_region_usage_ib_report"
|
||||
},
|
||||
"data_model_specification": {
|
||||
"fields_list": ["topmost_pn", "region", "commodity_code", "dc_plant", "country_total_cnt", "AU", "NZ", "LK", "VN", "JP", "HK", "SG", "TH", "PH", "IN", "BN", "NP", "BD", "KR", "ID", "FJ", "MY", "TW", "location_name", "ib", "usage_qty_8_week", "usage_qty_52_week", "total_history_usage"],
|
||||
|
||||
"core_country_fields": {
|
||||
"list": ["AU", "NZ", "LK", "VN", "JP", "HK", "SG", "TH", "PH", "IN", "BN", "NP", "BD", "KR", "ID", "FJ", "MY", "TW"],
|
||||
"meaning": "各国家过去某几周的总使用量,字段类型为BIGINT.这些字段表示该物料在该国家的历史用量值.",
|
||||
"critical_notes": "这些字段是数值型用量字段,不是国家代码。例如:VN字段表示物料在越南的历史使用量数值,不是字符串'VN'。"
|
||||
},
|
||||
|
||||
"mandatory_display_fields": {
|
||||
"rule1": "默认查询所有字段(SELECT *)",
|
||||
"rule2": "当用户明确指定某些字段时,只查询这些字段,并保持用户提到的顺序",
|
||||
"rule3": "WHERE条件中使用的所有字段(除了国家字段的数值比较外),必须在SELECT子句中展示",
|
||||
"rule4": "国家字段是数值型,直接展示数值,不需要特殊处理",
|
||||
"rule5": "select的所有字段必须用``包裹,如select `IN`,防止与SQL关键字冲突",
|
||||
"actual_fields_order": ["topmost_pn", "region", "commodity_code", "dc_plant", "country_total_cnt", "AU", "NZ", "LK", "VN", "JP", "HK", "SG", "TH", "PH", "IN", "BN", "NP", "BD", "KR", "ID", "FJ", "MY", "TW", "location_name", "ib", "usage_qty_8_week", "usage_qty_52_week", "total_history_usage"]
|
||||
}
|
||||
},
|
||||
"business_logic_rules": {
|
||||
"query_recognition_rules": {
|
||||
"material_keywords": ["物料", "topmost_pn", "物料号", "零件号", "Part Number", "PN"],
|
||||
"region_keywords": ["region", "区域", "大区", "地区", "Region Code", "CAP", "EMEA", "AMER"],
|
||||
"commodity_keywords": ["commodity_code", "商品代码", "编码", "物料分类", "Commodity Code", "CC"],
|
||||
"inventory_keywords": ["库存", "ib", "库存数量", "库存量", "Inventory Balance"],
|
||||
"usage_keywords": ["用量", "使用量", "历史用量", "近期用量", "usage", "使用数量"],
|
||||
"location_keywords": ["dc_plant", "plant", "配送中心", "工厂", "location", "地点"],
|
||||
"country_usage_keywords": ["国家用量", "国家使用量", "country usage", "国家用量分析"],
|
||||
"specific_country_keywords": {
|
||||
"AU": ["澳大利亚", "澳洲", "AU", "Australia"],
|
||||
"VN": ["越南", "VN", "Vietnam"],
|
||||
"JP": ["日本", "JP", "Japan"],
|
||||
"HK": ["香港", "HK", "Hong Kong"],
|
||||
"SG": ["新加坡", "SG", "Singapore"],
|
||||
"TH": ["泰国", "TH", "Thailand"],
|
||||
"IN": ["印度", "IN", "India"],
|
||||
"KR": ["韩国", "KR", "Korea"],
|
||||
"ID": ["印度尼西亚", "印尼", "ID", "Indonesia"],
|
||||
"MY": ["马来西亚", "MY", "Malaysia"],
|
||||
"TW": ["台湾", "TW", "Taiwan"],
|
||||
"NZ": ["新西兰", "NZ", "New Zealand"],
|
||||
"PH": ["菲律宾", "PH", "Philippines"]
|
||||
}
|
||||
},
|
||||
|
||||
"country_field_interpretation": {
|
||||
"fundamental_rule": "国家字段(AU, VN, JP等)是数值型用量字段(BIGINT),表示该物料在该国家的历史用量,不是国家代码",
|
||||
"correct_usage": {
|
||||
"in_select": "直接展示数值,如:SELECT AU, VN, JP",
|
||||
"in_where": "不需要添加任何默认过滤条件,除非用户明确要求",
|
||||
"as_numeric": "作为数值字段处理,支持比较运算符:>, <, >=, <=, ="
|
||||
},
|
||||
"incorrect_usage": [
|
||||
"WHERE VN = 'VN' (错误:VN是数值字段,不是字符串)",
|
||||
"WHERE VN LIKE '%VN%' (错误:VN是数值字段,不支持LIKE)",
|
||||
"WHERE VN IN ('VN', 'AU') (错误:VN是数值字段,不是枚举值)"
|
||||
],
|
||||
"user_intent_interpretation": {
|
||||
"当用户说'country为VN'": "用户只是提到VN字段,但不一定要求VN>0,不需要添加过滤条件",
|
||||
"当用户说'VN国家'": "用户指的是VN字段,按字段处理",
|
||||
"当用户说'有VN用量的物料'": "需要添加WHERE VN > 0",
|
||||
"当用户说'VN用量超过100'": "需要添加WHERE VN >= 100",
|
||||
"当用户说'VN用量为0'": "需要添加WHERE VN = 0",
|
||||
"当用户说'没有VN用量的'": "需要添加WHERE VN = 0"
|
||||
}
|
||||
},
|
||||
|
||||
"field_selection_logic": {
|
||||
"priority_order": [
|
||||
{
|
||||
"level": 1,
|
||||
"name": "用户明确指定的字段",
|
||||
"rule": "精确添加用户提到的字段,按用户问题中出现的顺序排列,不添加未提及的字段"
|
||||
},
|
||||
{
|
||||
"level": 2,
|
||||
"name": "默认字段选择",
|
||||
"rule": "如果用户没有明确指定字段,默认查询所有字段(SELECT *)"
|
||||
}
|
||||
],
|
||||
|
||||
"where_condition_fields_must_in_select": {
|
||||
"rule": "WHERE条件中使用的所有字段(除了国家字段的数值比较外),必须在SELECT子句中展示",
|
||||
"purpose": "确保查询结果的完整性,用户能看到过滤依据",
|
||||
"examples": [
|
||||
"用户说'region为CAP的数据' → SELECT * ... WHERE region = 'CAP'",
|
||||
"用户说'ib大于500的物料号' → SELECT topmost_pn, ib ... WHERE ib > 500",
|
||||
"用户说'region为CAP且commodity_code为LF的物料号' → SELECT topmost_pn, region, commodity_code ... WHERE region = 'CAP' AND commodity_code = 'LF'"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"where_condition_generation": {
|
||||
"strict_rule": "只生成用户明确要求的过滤条件,不添加任何默认或假设的条件",
|
||||
"condition_types": {
|
||||
"exact_match": {
|
||||
"pattern": "{字段}为{值}",
|
||||
"sql": "{field} = '{value}'",
|
||||
"examples": ["region为CAP → region = 'CAP'", "commodity_code为LF → commodity_code = 'LF'", "dc_plant为HKGDC → dc_plant = 'HKGDC'"]
|
||||
},
|
||||
"country_field_handling": {
|
||||
"important_note": "当用户提到'country为VN'时,不需要在WHERE中添加VN > 0,除非用户明确要求过滤用量",
|
||||
"correct_interpretation": "用户只是提到VN字段,但没有要求过滤VN的值",
|
||||
"only_add_filter_when": [
|
||||
"用户明确说'有VN用量的' → WHERE VN > 0",
|
||||
"用户明确说'VN用量大于0的' → WHERE VN > 0",
|
||||
"用户明确说'VN超过100的' → WHERE VN >= 100",
|
||||
"用户明确说'VN用量为0的' → WHERE VN = 0",
|
||||
"用户明确说'没有VN用量的' → WHERE VN = 0"
|
||||
],
|
||||
"incorrect_interpretation": [
|
||||
"用户说'country为VN' → 错误:添加WHERE VN > 0",
|
||||
"用户说'VN国家' → 错误:添加WHERE VN > 0",
|
||||
"用户说'查看VN' → 错误:添加WHERE VN > 0"
|
||||
]
|
||||
},
|
||||
"range_filter": {
|
||||
"pattern": ["大于{值}", "超过{值}", "少于{值}", "小于{值}", "不低于{值}", "不超过{值}"],
|
||||
"sql_mapping": {
|
||||
"大于{值}": "{field} > {value}",
|
||||
"超过{值}": "{field} >= {value}",
|
||||
"少于{值}": "{field} < {value}",
|
||||
"小于{值}": "{field} < {value}",
|
||||
"不低于{值}": "{field} >= {value}",
|
||||
"不超过{值}": "{field} <= {value}"
|
||||
},
|
||||
"examples": [
|
||||
"库存大于500 → ib > 500",
|
||||
"VN用量超过100 → VN >= 100",
|
||||
"近期用量少于50 → usage_qty_8_week < 50"
|
||||
]
|
||||
},
|
||||
"multiple_conditions": {
|
||||
"pattern": ["且", "并且", "和", "同时", ","],
|
||||
"sql": "AND",
|
||||
"examples": [
|
||||
"region为CAP且commodity_code为LF → region = 'CAP' AND commodity_code = 'LF'",
|
||||
"库存大于500且有VN用量 → ib > 500 AND VN > 0"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"no_default_conditions": {
|
||||
"rule": "绝对不添加任何用户没有明确要求的WHERE条件",
|
||||
"examples_of_what_not_to_add": [
|
||||
"不要添加WHERE region = 'CAP'(除非用户明确要求)",
|
||||
"不要添加WHERE ib > 0(除非用户明确要求)",
|
||||
"不要添加WHERE commodity_code IS NOT NULL(除非用户明确要求)",
|
||||
"不要添加任何假设性的过滤条件"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"default_behavior": {
|
||||
"sorting": "默认按ib(库存数量)降序排列:ORDER BY ib DESC",
|
||||
"limit": "禁止使用limit",
|
||||
"select_all": "默认查询所有字段:SELECT *",
|
||||
"field_order": "当用户指定字段时,按用户提到的顺序排列字段",
|
||||
"date_handling": "本表无日期字段,不需要日期转换"
|
||||
}
|
||||
},
|
||||
"field_mapping_reference": {
|
||||
"critical_note": "此表包含亚太地区各物料的库存、近期用量及历史使用量的详细数据。特别注意:国家字段(AU, VN, JP等)是数值型用量字段,表示该物料在该国家的历史用量,不是国家代码。这些字段是BIGINT类型,支持数值比较操作。",
|
||||
|
||||
"material_identifier_fields": {
|
||||
"topmost_pn": {
|
||||
"type": "string",
|
||||
"desc": "顶级物料号,物料的唯一标识",
|
||||
"example": "5CB1L57599",
|
||||
"query_pattern": "物料为{值} → topmost_pn = '{value}'",
|
||||
"alias": ["物料号", "零件号", "Part Number", "PN", "topmost", "物料编码"]
|
||||
},
|
||||
"commodity_code": {
|
||||
"type": "string",
|
||||
"desc": "商品代码,物料分类标识",
|
||||
"example": "LF",
|
||||
"query_pattern": "commodity_code为{值} → commodity_code = '{value}'",
|
||||
"alias": ["商品编码", "物料分类", "Commodity Code", "CC", "编码", "商品类别"]
|
||||
}
|
||||
},
|
||||
|
||||
"geographic_dimension_fields": {
|
||||
"region": {
|
||||
"type": "string",
|
||||
"desc": "区域划分,如CAP(亚太区)、EMEA(欧洲中东非洲)等",
|
||||
"example": "CAP",
|
||||
"values": ["CAP", "EMEA", "AMER"],
|
||||
"query_pattern": "region为{值} → region = '{value}'",
|
||||
"alias": ["区域", "大区", "Region", "地区", "地理区域"]
|
||||
},
|
||||
"dc_plant": {
|
||||
"type": "string",
|
||||
"desc": "配送中心/工厂代码",
|
||||
"example": "HKGDC",
|
||||
"query_pattern": "dc_plant为{值} → dc_plant = '{value}'",
|
||||
"alias": ["工厂", "配送中心", "plant", "DC", "发货中心", "Distribution Center"]
|
||||
},
|
||||
"location_name": {
|
||||
"type": "string",
|
||||
"desc": "地点名称",
|
||||
"example": "Hong Kong Distribution Center",
|
||||
"alias": ["地点名称", "位置名称", "location", "地点", "场所名称"]
|
||||
}
|
||||
},
|
||||
|
||||
"country_usage_fields_section": {
|
||||
"important_note": "以下所有字段都是数值型(BIGINT),表示该物料在该国家的历史使用量,不是国家代码。这些字段支持数值比较操作(>, <, >=, <=, =, !=)。",
|
||||
"critical_warning": "绝对不要将这些字段作为字符串处理,不要使用单引号,不要使用LIKE操作符。",
|
||||
|
||||
"country_total_cnt": {
|
||||
"type": "bigint",
|
||||
"desc": "所有国家的总使用量计数",
|
||||
"calculation_note": "可能是各国家字段的汇总或其他计算逻辑",
|
||||
"alias": ["国家总计数", "总使用量", "country total", "总计"]
|
||||
},
|
||||
|
||||
"country_usage_fields": {
|
||||
"AU": {
|
||||
"type": "bigint",
|
||||
"desc": "澳大利亚的历史使用量",
|
||||
"alias": ["澳大利亚", "澳洲", "AU用量", "Australia用量"]
|
||||
},
|
||||
"NZ": {
|
||||
"type": "bigint",
|
||||
"desc": "新西兰的历史使用量",
|
||||
"alias": ["新西兰", "NZ用量", "New Zealand用量"]
|
||||
},
|
||||
"LK": {
|
||||
"type": "bigint",
|
||||
"desc": "斯里兰卡的历史使用量",
|
||||
"alias": ["斯里兰卡", "LK用量", "Sri Lanka用量"]
|
||||
},
|
||||
"VN": {
|
||||
"type": "bigint",
|
||||
"desc": "越南的历史使用量",
|
||||
"alias": ["越南", "VN用量", "Vietnam用量"]
|
||||
},
|
||||
"JP": {
|
||||
"type": "bigint",
|
||||
"desc": "日本的历史使用量",
|
||||
"alias": ["日本", "JP用量", "Japan用量"]
|
||||
},
|
||||
"HK": {
|
||||
"type": "bigint",
|
||||
"desc": "香港的历史使用量",
|
||||
"alias": ["香港", "HK用量", "Hong Kong用量"]
|
||||
},
|
||||
"SG": {
|
||||
"type": "bigint",
|
||||
"desc": "新加坡的历史使用量",
|
||||
"alias": ["新加坡", "SG用量", "Singapore用量"]
|
||||
},
|
||||
"TH": {
|
||||
"type": "bigint",
|
||||
"desc": "泰国的历史使用量",
|
||||
"alias": ["泰国", "TH用量", "Thailand用量"]
|
||||
},
|
||||
"PH": {
|
||||
"type": "bigint",
|
||||
"desc": "菲律宾的历史使用量",
|
||||
"alias": ["菲律宾", "PH用量", "Philippines用量"]
|
||||
},
|
||||
"IN": {
|
||||
"type": "bigint",
|
||||
"desc": "印度的历史使用量",
|
||||
"alias": ["印度", "IN用量", "India用量"]
|
||||
},
|
||||
"BN": {
|
||||
"type": "bigint",
|
||||
"desc": "文莱的历史使用量",
|
||||
"alias": ["文莱", "BN用量", "Brunei用量"]
|
||||
},
|
||||
"NP": {
|
||||
"type": "bigint",
|
||||
"desc": "尼泊尔的历史使用量",
|
||||
"alias": ["尼泊尔", "NP用量", "Nepal用量"]
|
||||
},
|
||||
"BD": {
|
||||
"type": "bigint",
|
||||
"desc": "孟加拉国的历史使用量",
|
||||
"alias": ["孟加拉国", "BD用量", "Bangladesh用量"]
|
||||
},
|
||||
"KR": {
|
||||
"type": "bigint",
|
||||
"desc": "韩国的历史使用量",
|
||||
"alias": ["韩国", "KR用量", "Korea用量"]
|
||||
},
|
||||
"ID": {
|
||||
"type": "bigint",
|
||||
"desc": "印度尼西亚的历史使用量",
|
||||
"alias": ["印度尼西亚", "印尼", "ID用量", "Indonesia用量"]
|
||||
},
|
||||
"FJ": {
|
||||
"type": "bigint",
|
||||
"desc": "斐济的历史使用量",
|
||||
"alias": ["斐济", "FJ用量", "Fiji用量"]
|
||||
},
|
||||
"MY": {
|
||||
"type": "bigint",
|
||||
"desc": "马来西亚的历史使用量",
|
||||
"alias": ["马来西亚", "MY用量", "Malaysia用量"]
|
||||
},
|
||||
"TW": {
|
||||
"type": "bigint",
|
||||
"desc": "台湾的历史使用量",
|
||||
"alias": ["台湾", "TW用量", "Taiwan用量"]
|
||||
}
|
||||
},
|
||||
|
||||
"query_examples": {
|
||||
"correct": [
|
||||
"WHERE VN > 0 (查询有越南用量的物料)",
|
||||
"WHERE JP >= 100 (查询日本用量超过100的物料)",
|
||||
"WHERE AU = 0 (查询没有澳大利亚用量的物料)",
|
||||
"WHERE SG < 50 (查询新加坡用量少于50的物料)"
|
||||
],
|
||||
"incorrect": [
|
||||
"WHERE VN = 'VN' (错误:VN是数值,不是字符串)",
|
||||
"WHERE JP LIKE '%JP%' (错误:JP是数值,不支持LIKE)",
|
||||
"WHERE AU IN ('AU', 'VN') (错误:AU是数值,不是枚举)"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"inventory_metrics": {
|
||||
"ib": {
|
||||
"type": "bigint",
|
||||
"desc": "库存数量(Inventory Balance)",
|
||||
"query_pattern": "库存超过{值} → ib > {value}, 库存大于{值} → ib > {value}, 库存少于{值} → ib < {value}",
|
||||
"alias": ["库存", "库存量", "库存数量", "Inventory", "库存余额", "IB"]
|
||||
}
|
||||
},
|
||||
|
||||
"usage_time_series_fields": {
|
||||
"usage_qty_8_week": {
|
||||
"type": "bigint",
|
||||
"desc": "近8周的使用量",
|
||||
"alias": ["近8周用量", "近期用量", "短期用量", "8周用量", "近期使用量"]
|
||||
},
|
||||
"usage_qty_52_week": {
|
||||
"type": "bigint",
|
||||
"desc": "近52周的使用量",
|
||||
"alias": ["近52周用量", "年度用量", "长期用量", "52周用量", "年度使用量"]
|
||||
},
|
||||
"total_history_usage": {
|
||||
"type": "bigint",
|
||||
"desc": "历史总使用量",
|
||||
"alias": ["历史总用量", "总使用量", "累计用量", "历史累计", "total usage"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"examples": {
|
||||
"简单查询-全部字段": {
|
||||
"user": "region为CAP的数据",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_region_usage_ib_report WHERE region = 'CAP' ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。WHERE条件中使用了region字段。"
|
||||
},
|
||||
|
||||
"简单查询-基础过滤": {
|
||||
"user": "region为CAP,commodity_code为LF的数据",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_region_usage_ib_report WHERE region = 'CAP' AND commodity_code = 'LF' ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。WHERE条件中使用了region和commodity_code字段。"
|
||||
},
|
||||
|
||||
"简单查询-带国家字段但不过滤": {
|
||||
"user": "region为CAP,commodity_code为LF的,country为VN的数据",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_region_usage_ib_report WHERE region = 'CAP' AND commodity_code = 'LF' ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户提到'country为VN'但没有要求过滤VN用量,所以不添加VN > 0条件。默认查询所有字段。"
|
||||
},
|
||||
|
||||
"简单查询-带国家用量过滤": {
|
||||
"user": "region为CAP,commodity_code为LF的,有VN用量的数据",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_region_usage_ib_report WHERE region = 'CAP' AND commodity_code = 'LF' AND VN > 0 ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户明确要求'有VN用量的',所以添加VN > 0条件。默认查询所有字段。"
|
||||
},
|
||||
|
||||
"简单查询-指定字段": {
|
||||
"user": "查看物料号和库存数量",
|
||||
"sql": "SELECT topmost_pn, ib FROM dwd_ai.apbo_region_usage_ib_report ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户明确指定了topmost_pn和ib字段,只查询这两个字段,按用户提到的顺序排列。"
|
||||
},
|
||||
|
||||
"简单查询-多条件组合": {
|
||||
"user": "region为CAP,commodity_code为LF,库存大于500,有VN用量的数据",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_region_usage_ib_report WHERE region = 'CAP' AND commodity_code = 'LF' AND ib > 500 AND VN > 0 ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。WHERE条件包含region、commodity_code、ib和VN字段的过滤。"
|
||||
},
|
||||
|
||||
"指定字段且包含WHERE字段": {
|
||||
"user": "region为CAP的物料号和库存",
|
||||
"sql": "SELECT topmost_pn, ib, region FROM dwd_ai.apbo_region_usage_ib_report WHERE region = 'CAP' ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户指定了topmost_pn和ib字段,但WHERE条件中使用了region字段,所以必须包含region字段在SELECT中。"
|
||||
},
|
||||
|
||||
"国家用量范围查询": {
|
||||
"user": "VN用量超过100且库存大于200的物料",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_region_usage_ib_report WHERE VN >= 100 AND ib > 200 ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。WHERE条件包含VN和ib字段的数值范围过滤。"
|
||||
},
|
||||
|
||||
"多国家用量查询": {
|
||||
"user": "有VN用量且有AU用量的物料号",
|
||||
"sql": "SELECT topmost_pn, VN, AU FROM dwd_ai.apbo_region_usage_ib_report WHERE VN > 0 AND AU > 0 ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户指定了topmost_pn字段,并提到了VN和AU用量,所以包含这些字段。WHERE条件包含VN>0和AU>0。"
|
||||
},
|
||||
|
||||
"混合条件复杂查询": {
|
||||
"user": "region为CAP,commodity_code为LF,库存大于500,有VN用量且超过50,近期用量少于100的物料信息",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_region_usage_ib_report WHERE region = 'CAP' AND commodity_code = 'LF' AND ib > 500 AND VN > 50 AND usage_qty_8_week < 100 ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。WHERE条件包含多个字段的复杂过滤。"
|
||||
},
|
||||
|
||||
"国家用量为零查询": {
|
||||
"user": "没有VN用量的物料",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_region_usage_ib_report WHERE VN = 0 ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户明确要求'没有VN用量的',所以添加VN = 0条件。默认查询所有字段。"
|
||||
},
|
||||
|
||||
"仅查看特定国家用量": {
|
||||
"user": "查看VN和JP的用量",
|
||||
"sql": "SELECT VN, JP FROM dwd_ai.apbo_region_usage_ib_report ORDER BY ib DESC",
|
||||
"field_selection_reason": "用户明确指定了VN和JP字段,只查询这两个字段。没有WHERE条件。"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
{
|
||||
"meta": {
|
||||
"domain": "TP物料多重影响分析",
|
||||
"keywords": ["multiple impact", "tp物料", "物料影响", "pal_2h", "达标状态", "不达标状态", "物料分析", "TP分析", "影响分析"],
|
||||
"description": "此模型用于分析TP物料基于pal_2h状态的详细记录和统计信息。pal_2h='N'表示不达标,pal_2h='Y'表示达标。支持明细查询和统计分析两种模式,根据不同查询意图自动切换模式。",
|
||||
"data_source": "dwd_ai.apbo_tp_multiple_impact"
|
||||
},
|
||||
|
||||
"data_model_specification": {
|
||||
"fields_list": ["topmost_pn", "service_order_id", "soid", "pal_2h"],
|
||||
"mandatory_display_fields": {
|
||||
"rule1": "所有核心字段必须出现在SELECT子句中,除非用户明确指定排除。",
|
||||
"rule2": "pal_2h字段在两种模式下都必须显示",
|
||||
"rule3": "SELECT子句中字段顺序建议为:pal_2h, topmost_pn, service_order_id, soid",
|
||||
"action": "detail_mode下显示所有字段,statistical_mode下显示分组字段和统计结果"
|
||||
},
|
||||
|
||||
"optional_fields": {
|
||||
"key_fields": ["topmost_pn", "service_order_id", "soid"],
|
||||
"status_fields": ["pal_2h"],
|
||||
"grouping_fields": ["topmost_pn", "pal_2h"]
|
||||
}
|
||||
},
|
||||
|
||||
"business_logic_rules": {
|
||||
"query_recognition_rules": {
|
||||
"detail_mode_keywords": ["有哪些", "查看", "列出", "显示", "查询", "搜索", "找出", "记录", "明细", "详情", "具体"],
|
||||
"statistical_mode_keywords": ["统计", "汇总", "总数", "有多少", "数量", "count", "条数", "计数", "分组", "分布", "占比", "比例"],
|
||||
"tp_material_keywords": ["tp", "物料", "topmost_pn", "零件", "零件号", "物料号", "TP物料"],
|
||||
"order_keywords": ["订单", "so", "service_order_id", "SOID", "soid"],
|
||||
"status_keywords": ["状态", "pal_2h", "达标", "不达标", "Y", "N", "status"]
|
||||
},
|
||||
|
||||
"default_behavior": {
|
||||
"detail_mode": {
|
||||
"sorting": "默认按topmost_pn, service_order_id排序",
|
||||
"pal_2h_display": "pal_2h字段必须显示在SELECT结果中",
|
||||
"pal_2h_filter": "用户未指定状态条件时,禁止使用pal_2h过滤"
|
||||
},
|
||||
"statistical_mode": {
|
||||
"sorting": "COUNT(*) DESC",
|
||||
"limit": "禁止使用limit",
|
||||
"pal_2h_filter": "用户未指定状态条件时,禁止使用pal_2h过滤"
|
||||
},
|
||||
"alias_handling": "将用户提到的别名转换为完整字段名后再生成SQL"
|
||||
}
|
||||
},
|
||||
|
||||
"field_mapping_reference": {
|
||||
"critical_note": "注意区分detail_mode(明细查询)和statistical_mode(统计分析)两种模式,根据用户query中的关键词自动判断模式。detail_mode禁止使用聚合函数,statistical_mode必须使用聚合函数。",
|
||||
|
||||
"key_identifiers": {
|
||||
"topmost_pn": {
|
||||
"type": "varchar",
|
||||
"desc": "TP物料编号",
|
||||
"example": "02HK965",
|
||||
"required": true,
|
||||
"alias": ["tp", "物料", "物料号", "零件号", "TP物料", "零件编号", "物料编码"]
|
||||
},
|
||||
"service_order_id": {
|
||||
"type": "varchar",
|
||||
"desc": "服务订单ID",
|
||||
"example": "4020438779",
|
||||
"required": true,
|
||||
"alias": ["so", "订单", "订单号", "service_order", "订单ID", "SO", "服务订单"]
|
||||
},
|
||||
"soid": {
|
||||
"type": "varchar",
|
||||
"desc": "SOID(服务订单明细ID)",
|
||||
"example": "402043877920",
|
||||
"required": true,
|
||||
"alias": ["SOID", "子单号", "明细ID", "订单明细", "服务订单明细"]
|
||||
}
|
||||
},
|
||||
|
||||
"status_fields": {
|
||||
"pal_2h": {
|
||||
"type": "varchar(1)",
|
||||
"desc": "状态字段:'Y'表示达标,'N'表示不达标",
|
||||
"values": {
|
||||
"Y": "达标",
|
||||
"N": "不达标",
|
||||
"NULL": "无状态"
|
||||
},
|
||||
"business_rule": "用户未指定状态条件时,默认查询不达标记录(pal_2h = 'N')",
|
||||
"alias": ["状态", "达标状态", "不达标状态", "pal_2h状态", "status", "达标标识"]
|
||||
}
|
||||
},
|
||||
|
||||
"condition_mapping": {
|
||||
"达标": "pal_2h = 'Y'",
|
||||
"不达标": "pal_2h = 'N'",
|
||||
"无状态": "pal_2h IS NULL",
|
||||
"所有状态": "pal_2h IN ('Y', 'N')",
|
||||
"有状态的": "pal_2h IN ('Y', 'N')",
|
||||
"状态完整": "pal_2h IN ('Y', 'N')"
|
||||
}
|
||||
},
|
||||
|
||||
"examples": {
|
||||
"detail_mode_examples": {
|
||||
"example1": {
|
||||
"user": "tp为02HK965的multiple impact有哪些",
|
||||
"mode": "detail_mode",
|
||||
"reason": "包含'有哪些'关键词,表示查看具体记录;未指定状态,默认查不达标",
|
||||
"sql": "SELECT pal_2h, topmost_pn, service_order_id, soid FROM dwd_ai.apbo_tp_multiple_impact WHERE topmost_pn = '02HK965' ORDER BY topmost_pn, service_order_id"
|
||||
},
|
||||
"example2": {
|
||||
"user": "查看达标的记录",
|
||||
"mode": "detail_mode",
|
||||
"reason": "包含'查看'关键词,表示查看具体记录;指定了达标状态",
|
||||
"sql": "SELECT pal_2h, topmost_pn, service_order_id, soid FROM dwd_ai.apbo_tp_multiple_impact WHERE ORDER BY topmost_pn, service_order_id"
|
||||
},
|
||||
"example3": {
|
||||
"user": "列出topmost_pn为02HK965的记录",
|
||||
"mode": "detail_mode",
|
||||
"reason": "包含'列出'关键词,表示查看具体记录;未指定状态,默认查不达标",
|
||||
"sql": "SELECT pal_2h, topmost_pn, service_order_id, soid FROM dwd_ai.apbo_tp_multiple_impact WHERE topmost_pn = '02HK965' ORDER BY topmost_pn, service_order_id"
|
||||
},
|
||||
"example4": {
|
||||
"user": "查询订单4020438779的TP物料影响",
|
||||
"mode": "detail_mode",
|
||||
"reason": "包含'查询'关键词,表示查看具体记录;未指定状态,默认查不达标",
|
||||
"sql": "SELECT pal_2h, topmost_pn, service_order_id, soid FROM dwd_ai.apbo_tp_multiple_impact WHERE service_order_id = '4020438779' ORDER BY topmost_pn, soid"
|
||||
}
|
||||
},
|
||||
|
||||
"statistical_mode_examples": {
|
||||
"example1": {
|
||||
"user": "统计不同状态的物料数量",
|
||||
"mode": "statistical_mode",
|
||||
"reason": "包含'统计'关键词,表示统计数量;统计不同状态,需要显示所有状态",
|
||||
"sql": "SELECT pal_2h, COUNT(topmost_pn) AS topmost_pn_count FROM dwd_ai.apbo_tp_multiple_impact GROUP BY pal_2h ORDER BY topmost_pn_count DESC"
|
||||
},
|
||||
"example2": {
|
||||
"user": "按topmost_pn分组统计每个物料的记录数",
|
||||
"mode": "statistical_mode",
|
||||
"reason": "包含'统计'和'分组'关键词;未指定状态,默认只统计不达标",
|
||||
"sql": "SELECT topmost_pn, pal_2h, COUNT(*) AS count FROM dwd_ai.apbo_tp_multiple_impact GROUP BY topmost_pn, pal_2h ORDER BY count DESC"
|
||||
},
|
||||
"example3": {
|
||||
"user": "汇总各TP物料的影响分布",
|
||||
"mode": "statistical_mode",
|
||||
"reason": "包含'汇总'关键词,表示统计分布;未指定状态,默认只统计不达标",
|
||||
"sql": "SELECT topmost_pn, COUNT(*) AS record_count FROM dwd_ai.apbo_tp_multiple_impact GROUP BY topmost_pn ORDER BY record_count DESC"
|
||||
}
|
||||
},
|
||||
|
||||
"edge_cases": {
|
||||
"example1": {
|
||||
"user": "有多少条tp为02HK965的记录",
|
||||
"mode": "statistical_mode",
|
||||
"reason": "包含'有多少'关键词,虽然指定了具体物料,但目的是获取数量;未指定状态,默认只统计不达标",
|
||||
"sql": "SELECT COUNT(*) AS count FROM dwd_ai.apbo_tp_multiple_impact WHERE topmost_pn = '02HK965'"
|
||||
},
|
||||
"example2": {
|
||||
"user": "显示所有状态为达标和不达标的记录",
|
||||
"mode": "detail_mode",
|
||||
"reason": "包含'显示'关键词,表示查看具体记录;明确要求查看两种状态,不使用默认值",
|
||||
"sql": "SELECT pal_2h, topmost_pn, service_order_id, soid FROM dwd_ai.apbo_tp_multiple_impact ORDER BY topmost_pn, service_order_id"
|
||||
},
|
||||
"example3": {
|
||||
"user": "统计状态为NULL的记录数量",
|
||||
"mode": "statistical_mode",
|
||||
"reason": "包含'统计'关键词,表示统计数量;明确指定NULL状态,不使用默认值",
|
||||
"sql": "SELECT COUNT(*) AS count FROM dwd_ai.apbo_tp_multiple_impact WHERE pal_2h IS NULL"
|
||||
},
|
||||
"example4": {
|
||||
"user": "查看所有状态的记录详情",
|
||||
"mode": "detail_mode",
|
||||
"reason": "包含'查看'和'详情'关键词,表示查看具体记录;要求所有状态,不使用默认值",
|
||||
"sql": "SELECT pal_2h, topmost_pn, service_order_id, soid FROM dwd_ai.apbo_tp_multiple_impact OR pal_2h IS NULL ORDER BY pal_2h, topmost_pn, service_order_id"
|
||||
},
|
||||
"example5": {
|
||||
"user": "统计每个TP物料的不同状态数量",
|
||||
"mode": "statistical_mode",
|
||||
"reason": "包含'统计'关键词,表示统计分析;统计每个物料的各状态分布",
|
||||
"sql": "SELECT topmost_pn, pal_2h, COUNT(*) AS count FROM dwd_ai.apbo_tp_multiple_impact GROUP BY topmost_pn, pal_2h ORDER BY topmost_pn, pal_2h"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"table": "example_table",
|
||||
"description": "示例表模型提示词",
|
||||
"system_prompt": "You are an expert SQL generator.",
|
||||
"business_prompt": "Generate SQL for example_table based on the user's intent.",
|
||||
"constraints": [
|
||||
"Use only fields defined in this table.",
|
||||
"Return only SQL without explanations."
|
||||
]
|
||||
}
|
||||
@@ -16,9 +16,31 @@
|
||||
"work order information",
|
||||
"recovery ETA",
|
||||
"history order",
|
||||
"Warranty type"
|
||||
"Warranty type",
|
||||
"category"
|
||||
],
|
||||
"x_table_name": [
|
||||
"xx"
|
||||
"apbo_milestone_info": [
|
||||
"GR or POD",
|
||||
"POD",
|
||||
"GR",
|
||||
"milestone status",
|
||||
"milestone",
|
||||
"物流节点",
|
||||
"shipment tracking",
|
||||
"里程碑",
|
||||
"节点明细"
|
||||
],
|
||||
"apbo_hic_ssoc_consumption": [
|
||||
"consumption消耗记录",
|
||||
"consumption order"
|
||||
],
|
||||
"apbo_tp_multiple_impact": [
|
||||
"multiple impact orders",
|
||||
"不达标的multiple impact",
|
||||
"multiple impact status"
|
||||
],
|
||||
"apbo_region_usage_ib_report": [
|
||||
"ib",
|
||||
"usage"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user