init
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# Config 模块
|
||||
|
||||
## 作用
|
||||
|
||||
维护运行配置与提示词资源,是模型、RAG、缓存与工作流参数的配置中心。
|
||||
|
||||
## 内容
|
||||
|
||||
- `config.ini` / `config.ini.example`:环境配置
|
||||
- `prompts.yaml`:系统与用户提示词模板
|
||||
- `settings.py`:配置读取入口
|
||||
- `sql_gen_prompts/`:按表维度的 SQL 提示词 JSON
|
||||
- `table_retrieval_prompts/`:表检索提示词数据
|
||||
+20
-2
@@ -1,3 +1,21 @@
|
||||
from .settings import Config
|
||||
from . import settings as _settings
|
||||
|
||||
__all__ = ["Config"]
|
||||
Config = _settings.Config
|
||||
DEFAULT_MODEL_SECTION = _settings.DEFAULT_MODEL_SECTION
|
||||
MAX_RETRIES = _settings.MAX_RETRIES
|
||||
TIMEOUT = _settings.TIMEOUT
|
||||
CONVERSATION_MAX_HISTORY_MESSAGES = _settings.CONVERSATION_MAX_HISTORY_MESSAGES
|
||||
CONVERSATION_ENABLE_MULTI_TURN = _settings.CONVERSATION_ENABLE_MULTI_TURN
|
||||
CONVERSATION_ENABLE_COMPRESSION = _settings.CONVERSATION_ENABLE_COMPRESSION
|
||||
CONVERSATION_COMPRESSION_THRESHOLD = _settings.CONVERSATION_COMPRESSION_THRESHOLD
|
||||
|
||||
__all__ = [
|
||||
"Config",
|
||||
"DEFAULT_MODEL_SECTION",
|
||||
"MAX_RETRIES",
|
||||
"TIMEOUT",
|
||||
"CONVERSATION_MAX_HISTORY_MESSAGES",
|
||||
"CONVERSATION_ENABLE_MULTI_TURN",
|
||||
"CONVERSATION_ENABLE_COMPRESSION",
|
||||
"CONVERSATION_COMPRESSION_THRESHOLD",
|
||||
]
|
||||
|
||||
+44
-5
@@ -24,6 +24,7 @@ URL = http://led-gateway.lenovo.com:30089/intranet/qwen3-next-80b-a3b-instruct/v
|
||||
url = http://ipc.lenovo.com/gateway/bgs-ai/Report/fetchData
|
||||
llzAppkey = e0578e6a-f045-4f3e-93c0-5957c8b1915e
|
||||
llzSercret = BFhItTCY5FqgtHAdn0eaxAGix/25oR8YfxYKfSPgrJb8zxYG06kBeoip0DEGjekfh43223atdBDXBwUmw18NXp/2piZamnUwlFWYFAGfpBCwy3K+921KI5ZaWRWcMCCcCKOYF/2feMg72owUhno2JXqSUcb8HBhang==
|
||||
default_rows = 1000
|
||||
|
||||
|
||||
[ragflow]
|
||||
@@ -34,21 +35,59 @@ retrieval_top_k = 3
|
||||
cache_ttl = 600
|
||||
table_retrieval_dataset_id = 9945baf512ea11f18ccb6a681b3130b2
|
||||
sql_gen_dataset_id = ee68f53a12ec11f18e436a681b3130b2
|
||||
default_table_name = apbo_eta_ful
|
||||
|
||||
[redis]
|
||||
enabled = true
|
||||
host = ipc-redis.lenovo.com
|
||||
port = 30401
|
||||
password = bgs123456
|
||||
database = 2
|
||||
sql_prompt_ttl = 600
|
||||
# 是否使用 Redis 作为 SQL 提示词主存储(启用后优先从 Redis 读取)
|
||||
sql_prompt_redis_primary = true
|
||||
|
||||
[stream]
|
||||
progress_interval = 0.3
|
||||
|
||||
[conversation]
|
||||
# 是否启用按会话自动续接上下文的多轮对话
|
||||
enable_multi_turn = false
|
||||
# 对话记忆最大消息数(默认 10 条,约 5 轮对话)
|
||||
# 每条对话包含用户消息和 AI 回复,10 条消息约等于 5 轮完整对话
|
||||
max_history_messages = 10
|
||||
# 是否启用记忆压缩(可选,未来扩展)
|
||||
enable_memory_compression = false
|
||||
# 记忆压缩阈值(超过此数量时触发压缩,未来扩展)
|
||||
compression_threshold = 8
|
||||
|
||||
[logging_mysql]
|
||||
enabled = true
|
||||
entity_debug_enabled = false
|
||||
host = 10.122.132.204
|
||||
port = 3306
|
||||
user = root
|
||||
password = bgs20250901
|
||||
database = ipc_apbo
|
||||
table = structured_logs
|
||||
messages_table = ipc_apbo.messages
|
||||
conversation_table = ipc_apbo.conversations
|
||||
connect_timeout = 5
|
||||
|
||||
|
||||
[app]
|
||||
service_name = local-model-streaming-api
|
||||
service_name = apbo-boat-agent
|
||||
host = 0.0.0.0
|
||||
port = 8000
|
||||
port = 26004
|
||||
version = 1.0.0
|
||||
|
||||
[nacos]
|
||||
enabled = false
|
||||
enabled = true
|
||||
server = 10.122.132.204:8848
|
||||
namespace = prod
|
||||
group_name = BGS
|
||||
namespace = apbo_dev
|
||||
group_name = apbo
|
||||
username = nacos
|
||||
password = bgs20250901
|
||||
# 可选:仅用于 Nacos 注册的端口(不影响应用监听端口 app.port)
|
||||
register_port = 26004
|
||||
|
||||
|
||||
@@ -37,11 +37,52 @@ retrieval = /api/v1/retrieval
|
||||
retrieval_top_k = 3
|
||||
table_retrieval_dataset_id =
|
||||
sql_gen_dataset_id =
|
||||
# 当表检索未命中时,使用该默认表继续生成 SQL
|
||||
default_table_name = apbo_eta_ful
|
||||
|
||||
[redis]
|
||||
# 是否启用 Redis 缓存(用于 sql_gen_prompts)
|
||||
enabled = false
|
||||
url = redis://localhost:6379/0
|
||||
db = 0
|
||||
# SQL 提示词缓存过期秒数
|
||||
sql_prompt_ttl = 600
|
||||
# 是否使用 Redis 作为 SQL 提示词主存储(启用后优先从 Redis 读取,支持热更新)
|
||||
sql_prompt_redis_primary = false
|
||||
|
||||
[stream]
|
||||
# /api/workflows/stream 进度事件间隔(秒)
|
||||
progress_interval = 0.3
|
||||
|
||||
[conversation]
|
||||
# 是否启用按会话自动续接上下文的多轮对话
|
||||
enable_multi_turn = false
|
||||
# 对话记忆最大消息数(默认 10 条,约 5 轮对话)
|
||||
# 每条对话包含用户消息和 AI 回复,10 条消息约等于 5 轮完整对话
|
||||
max_history_messages = 10
|
||||
# 是否启用记忆压缩(可选,未来扩展)
|
||||
enable_memory_compression = false
|
||||
# 记忆压缩阈值(超过此数量时触发压缩,未来扩展)
|
||||
compression_threshold = 8
|
||||
|
||||
[logging_mysql]
|
||||
# 是否启用结构化日志写入 MySQL
|
||||
enabled = false
|
||||
# 是否输出 conversations/messages 实体读写阶段调试日志到控制台
|
||||
entity_debug_enabled = false
|
||||
host = 127.0.0.1
|
||||
port = 3306
|
||||
user = root
|
||||
password =
|
||||
database = more_dots
|
||||
# 结构化日志表
|
||||
table = structured_logs
|
||||
# 消息落库表(Messages 实体)
|
||||
messages_table = ipc_apbo.messages
|
||||
# 会话表名(用于 conversation_id 创建/校验/更新时间)
|
||||
conversation_table = ipc_apbo.conversations
|
||||
connect_timeout = 5
|
||||
|
||||
[nacos]
|
||||
# 是否启用 Nacos 注册
|
||||
enabled = false
|
||||
@@ -57,6 +98,9 @@ cluster_name = DEFAULT
|
||||
username =
|
||||
# 密码(可选)
|
||||
password =
|
||||
# 可选:仅用于 Nacos 注册的端口(不影响应用监听端口 app.port)
|
||||
# 未配置时默认使用 app.port
|
||||
register_port = 26004
|
||||
# 心跳间隔(秒)
|
||||
heartbeat_interval = 5
|
||||
# 权重
|
||||
|
||||
@@ -19,6 +19,18 @@ user:
|
||||
You are a translation and normalization assistant.
|
||||
Convert the user's input to a clear, grammatically correct English sentence suitable for SQL intent.
|
||||
If the input is already English, polish it.
|
||||
|
||||
Apply the following business glossary mappings when the terms appear as standalone business keywords:
|
||||
- BO -> backlog order
|
||||
- SO -> service order id
|
||||
- WO -> service order id
|
||||
- ETA信息 -> eta information
|
||||
- 明细 -> detail
|
||||
- 汇总 -> aggregate summary
|
||||
- 排名前N -> top N ranking
|
||||
|
||||
Keep country codes, region codes, model names, order numbers, and field aliases unchanged when possible.
|
||||
Expand business abbreviations according to the glossary above.
|
||||
Return only the final English sentence without extra explanations.
|
||||
|
||||
business:
|
||||
|
||||
+87
-22
@@ -1,34 +1,58 @@
|
||||
import os
|
||||
import configparser
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class Config:
|
||||
"""从 config.ini 读取的应用配置"""
|
||||
|
||||
_config = configparser.ConfigParser()
|
||||
_root_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
_config_path = os.path.join(_root_dir, 'config', 'config.ini')
|
||||
|
||||
# 在类初始化时加载配置
|
||||
if not os.path.exists(_config_path):
|
||||
raise FileNotFoundError(
|
||||
f"Configuration file not found at: {_config_path}. "
|
||||
"Please copy 'config/config.ini.example' to 'config/config.ini' and fill in your details."
|
||||
)
|
||||
|
||||
try:
|
||||
with open(_config_path, "r", encoding="utf-8") as f:
|
||||
_config.read_file(f)
|
||||
except UnicodeDecodeError:
|
||||
with open(_config_path, "r", encoding="gbk") as f:
|
||||
_config.read_file(f)
|
||||
|
||||
# 通用设置
|
||||
DEFAULT_MODEL_SECTION: str = _config.get('General', 'DEFAULT_MODEL_SECTION', fallback='gpt-4o')
|
||||
MAX_RETRIES: int = _config.getint('General', 'MAX_RETRIES', fallback=3)
|
||||
TIMEOUT: int = _config.getint('General', 'TIMEOUT', fallback=30)
|
||||
|
||||
_config_loaded = False
|
||||
DEFAULT_MODEL_SECTION = "gpt-4o"
|
||||
MAX_RETRIES = 3
|
||||
TIMEOUT = 30
|
||||
CONVERSATION_MAX_HISTORY_MESSAGES = 10
|
||||
CONVERSATION_ENABLE_MULTI_TURN = False
|
||||
CONVERSATION_ENABLE_COMPRESSION = False
|
||||
CONVERSATION_COMPRESSION_THRESHOLD = 8
|
||||
|
||||
@classmethod
|
||||
def _get_config_path(cls) -> Path:
|
||||
"""获取配置文件路径(支持环境变量覆盖)"""
|
||||
env_path = os.getenv("CONFIG_PATH")
|
||||
if env_path:
|
||||
return Path(env_path)
|
||||
|
||||
project_root = Path(__file__).parent.parent
|
||||
return project_root / 'config' / 'config.ini'
|
||||
|
||||
@classmethod
|
||||
def _load_config(cls):
|
||||
"""懒加载配置"""
|
||||
if cls._config_loaded:
|
||||
return
|
||||
|
||||
config_path = cls._get_config_path()
|
||||
|
||||
if not config_path.exists():
|
||||
raise FileNotFoundError(
|
||||
f"Configuration file not found at: {config_path}. "
|
||||
"Please copy 'config/config.ini.example' to 'config/config.ini' and fill in your details."
|
||||
)
|
||||
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
cls._config.read_file(f)
|
||||
|
||||
cls._config_loaded = True
|
||||
|
||||
@classmethod
|
||||
def reload(cls):
|
||||
"""重新加载配置(支持热重载)"""
|
||||
cls._config_loaded = False
|
||||
cls._load_config()
|
||||
_refresh_runtime_constants()
|
||||
|
||||
@classmethod
|
||||
def get_model_config(cls, section: Optional[str] = None) -> dict:
|
||||
"""
|
||||
@@ -71,6 +95,47 @@ class Config:
|
||||
raise ValueError(f"Configuration validation failed: {e}")
|
||||
|
||||
|
||||
DEFAULT_MODEL_SECTION = Config.DEFAULT_MODEL_SECTION
|
||||
MAX_RETRIES = Config.MAX_RETRIES
|
||||
TIMEOUT = Config.TIMEOUT
|
||||
CONVERSATION_MAX_HISTORY_MESSAGES = Config.CONVERSATION_MAX_HISTORY_MESSAGES
|
||||
CONVERSATION_ENABLE_MULTI_TURN = Config.CONVERSATION_ENABLE_MULTI_TURN
|
||||
CONVERSATION_ENABLE_COMPRESSION = Config.CONVERSATION_ENABLE_COMPRESSION
|
||||
CONVERSATION_COMPRESSION_THRESHOLD = Config.CONVERSATION_COMPRESSION_THRESHOLD
|
||||
|
||||
|
||||
def _refresh_runtime_constants() -> None:
|
||||
"""同步模块级常量与 Config 类属性,兼容两种访问方式。"""
|
||||
global DEFAULT_MODEL_SECTION
|
||||
global MAX_RETRIES
|
||||
global TIMEOUT
|
||||
global CONVERSATION_MAX_HISTORY_MESSAGES
|
||||
global CONVERSATION_ENABLE_MULTI_TURN
|
||||
global CONVERSATION_ENABLE_COMPRESSION
|
||||
global CONVERSATION_COMPRESSION_THRESHOLD
|
||||
|
||||
DEFAULT_MODEL_SECTION = Config._config.get('General', 'DEFAULT_MODEL_SECTION', fallback='gpt-4o')
|
||||
MAX_RETRIES = Config._config.getint('General', 'MAX_RETRIES', fallback=3)
|
||||
TIMEOUT = Config._config.getint('General', 'TIMEOUT', fallback=30)
|
||||
CONVERSATION_MAX_HISTORY_MESSAGES = Config._config.getint('conversation', 'max_history_messages', fallback=10)
|
||||
CONVERSATION_ENABLE_MULTI_TURN = Config._config.getboolean('conversation', 'enable_multi_turn', fallback=False)
|
||||
CONVERSATION_ENABLE_COMPRESSION = Config._config.getboolean('conversation', 'enable_memory_compression', fallback=False)
|
||||
CONVERSATION_COMPRESSION_THRESHOLD = Config._config.getint('conversation', 'compression_threshold', fallback=8)
|
||||
|
||||
Config.DEFAULT_MODEL_SECTION = DEFAULT_MODEL_SECTION
|
||||
Config.MAX_RETRIES = MAX_RETRIES
|
||||
Config.TIMEOUT = TIMEOUT
|
||||
Config.CONVERSATION_MAX_HISTORY_MESSAGES = CONVERSATION_MAX_HISTORY_MESSAGES
|
||||
Config.CONVERSATION_ENABLE_MULTI_TURN = CONVERSATION_ENABLE_MULTI_TURN
|
||||
Config.CONVERSATION_ENABLE_COMPRESSION = CONVERSATION_ENABLE_COMPRESSION
|
||||
Config.CONVERSATION_COMPRESSION_THRESHOLD = CONVERSATION_COMPRESSION_THRESHOLD
|
||||
|
||||
|
||||
# 在类定义完成后加载配置
|
||||
Config._load_config()
|
||||
_refresh_runtime_constants()
|
||||
|
||||
|
||||
# 如有需要可在导入时做初始校验,
|
||||
# 但已移到 main.py 以便更可控地执行。
|
||||
# 如需在导入时校验,可在此调用 Config.validate_config()
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
本目录存放业务 SQL 提示词(JSON 格式)。
|
||||
|
||||
约定:每个 JSON 文件对应一个数据库表模型。
|
||||
示例文件:order.json、customer.json 等。
|
||||
@@ -3,59 +3,105 @@
|
||||
"domain": "订单物料最新状态与历史变更查询",
|
||||
"description": "此模型用于查询订单物料的最新状态和ETA相关信息,支持查询历史变更记录。该表包含最新状态数据(data_flag='Newest')和历史变更数据(data_flag='Changelog')的联合结果。所有日期字段在查询时自动转换为字符类型。通过data_flag区分最新状态和历史变更,实现订单全生命周期追踪。",
|
||||
"data_source": "dwd_ai.apbo_eta_ful",
|
||||
"system_flag_limit": "任何条件下,都不允许在SELECT子句中查询is_passdue, is_dummy, data_flag字段,仅用于WHERE过滤,该规则优先级最高!"
|
||||
"system_flag_limit": "任何条件下,都不允许在SELECT子句中查询data_flag字段,仅用于WHERE过滤,且update_date和data_flag两个字段在where条件中互斥,使用了update_date则不使用data_flag,该规则优先级最高!"
|
||||
},
|
||||
"data_model_specification": {
|
||||
"fields_list": [
|
||||
"service_order_id", "soid", "part_number", "topmost_pn", "commodity_code", "ship_to_country",
|
||||
"region", "dc_plant", "mtm", "machine_sn", "machine_type", "whether_premier", "stm_planner",
|
||||
"category", "lenovo_ref_no", "case_number", "service_order_creation_date", "eta", "so_eta",
|
||||
"status", "status_date", "update_date", "parts_sales", "warranty", "aging_day", "action",
|
||||
"is_passdue", "is_dummy", "data_flag", "model", "aging_range", "recovery_day", "recovery_range",
|
||||
"order_type", "key_lenovo_ref_no", "service_type", "customer", "life_cycle", "hawb", "bol", "dn", "po", "prid"
|
||||
"service_order_id", "soid", "part_number", "topmost_pn", "commodity_code", "ship_to_country",
|
||||
"region", "dc_plant", "mtm", "machine_sn", "machine_type", "whether_premier", "stm_planner",
|
||||
"category", "lenovo_ref_no", "case_number", "service_order_creation_date", "eta", "so_eta",
|
||||
"status", "status_date", "update_date", "parts_sales", "warranty", "aging_day", "action",
|
||||
"data_flag", "model", "aging_range", "recovery_day", "recovery_range",
|
||||
"order_type", "key_lenovo_ref_no", "service_type", "customer", "life_cycle", "owner", "bu", "multiple_flag", "country_dc_premier_stock", "potential_ww_stock", "potential_opo_stock", "potential_other_dc_stock", "potential_reverse_stock", "hawb", "bol", "dn", "po", "prid"
|
||||
],
|
||||
"mandatory_display_fields": {
|
||||
"rule1": "默认展示字段(按以下顺序):service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date",
|
||||
"rule2": "用户明确提到的字段优先原则:如果用户问题中明确提到了某些字段,这些字段应在SELECT子句中排在最前面,按用户问题中出现的顺序排列",
|
||||
"rule3": "字段去重:用户提到的字段和默认字段有重叠时,每个字段只出现一次",
|
||||
"rule4": "日期字段必须转换为字符类型:cast(column as varchar(4096)) as column",
|
||||
"rule5": "where子句中出现的字段,必须加入select中查询展示",
|
||||
"rule6": "禁止使用limit",
|
||||
"rule7": "请确认生成的sql中,用户使用的是mt(machine_type)还是mtm, 注意!! MTM SN = machine_sn, MT SN = machine_sn, mt = machine_type",
|
||||
"rule8": "当用户要求:展示所有信息,所有字段,全字段等需求时候,额外加入展示的字段:machine_type,case_number,status_date,aging_day,is_passdue,is_dummy,data_flag,recovery_day,recovery_range,hawb,bol,dn,po,prid",
|
||||
"rule9": "where条件禁止使用status字段过滤",
|
||||
"rule10": "用户输入了汇总,统计,分组等关键词,但未明确统计方式时候,默认使用count(*)进行汇总,注意group by必须和聚合函数成对出现,聚合查询后默认按照聚合的值从小到大排序",
|
||||
"rule11": "如果用户输入的关键字有:VN,AU,IN,HK,PH,KR,ID,TW,MO,FJ,LK,MY,SG,NZ,TH,JP,BD,则视为国家字段的数值过滤条件,增加ship_to_country = '国家代码'",
|
||||
"rule12": "MM/DD类似格式日期转换为 like '%-MM-DD%' ,DD等格式转换为 like '%-DD%'",
|
||||
"rule13": "用户指定日期时,去掉data_flag = 'Newest'的过滤条件,如:查询2026年1月26的eta信息,则where子句中不包含data_flag = 'Newest',而是update_date = '2025-12-31'",
|
||||
"rule14": "聚合查询中,如未使用group by进行分组,select中默认增加使用update_date字段"
|
||||
"default_fields": "service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, owner, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date",
|
||||
"date_cast_rule": "日期字段必须转换为字符类型:cast(column as varchar(4096)) as column"
|
||||
},
|
||||
"optional_fields": {
|
||||
"key_identifier_fields": ["service_order_id", "soid", "part_number","topmost_pn", "commodity_code"],
|
||||
"milestone_date_fields": ["eta", "so_eta", "status_date", "update_date", "service_order_creation_date"],
|
||||
"location_fields": ["ship_to_country", "region", "dc_plant"],
|
||||
"machine_fields": ["mtm", "machine_sn", "machine_type", "model"],
|
||||
"service_fields": ["whether_premier", "stm_planner", "category", "lenovo_ref_no", "case_number", "key_lenovo_ref_no", "service_type"],
|
||||
"service_fields": ["whether_premier", "stm_planner", "category", "lenovo_ref_no", "case_number", "key_lenovo_ref_no", "service_type", "owner"],
|
||||
"status_fields": ["status", "status_date"],
|
||||
"additional_fields": ["parts_sales", "warranty", "aging_day", "action", "aging_range", "recovery_day", "recovery_range", "order_type", "customer", "life_cycle", "hawb", "bol", "dn", "po", "prid"],
|
||||
"system_filter_fields": ["is_passdue", "is_dummy", "data_flag"]
|
||||
"additional_fields": ["parts_sales", "warranty", "aging_day", "action", "aging_range", "recovery_day", "recovery_range", "order_type", "customer", "life_cycle", "owner", "bu", "multiple_flag", "country_dc_premier_stock", "potential_ww_stock", "potential_opo_stock", "potential_other_dc_stock", "potential_reverse_stock", "hawb", "bol", "dn", "po", "prid"],
|
||||
"system_filter_fields": ["data_flag"]
|
||||
}
|
||||
},
|
||||
"business_logic_rules": {
|
||||
"soid_or_service_order_id": "禁止使用WHERE soid = 'xxx'或WHERE service_order_id = 'xxx'单独过滤,必须使用(service_order_id = 'xxx' or soid = 'xxx')进行过滤",
|
||||
"sorting": "默认使用如下字段排序: soid, eta desc",
|
||||
"query_recognition_rules": {
|
||||
"detail_mode_triggers": ["明细", "明细查询", "详细", "具体", "记录"],
|
||||
"aggregate_mode_triggers": ["聚合", "统计", "汇总", "count", "计数", "数量", "多少", "几个", "分组", "summary", "group by","summarize by","summarize","aggregate by","aggregate","sum", "求和", "总计", "合计"],
|
||||
"aggregate_mode_enforcement": "当用户问题命中任意aggregate_mode_triggers关键字时,必须强制使用聚合模式:SELECT子句必须包含count(soid) as qty,分组字段必须加入GROUP BY。如用户指定了具体维度,按该维度分组;如未指定,默认按part_number分组"
|
||||
},
|
||||
"field_selection_logic": {
|
||||
"priority_order": [
|
||||
{
|
||||
"level": 0,
|
||||
"name": "明细模式",
|
||||
"rule": "默认模式;未命中聚合关键词时",
|
||||
"action": "使用明细字段与默认展示字段"
|
||||
},
|
||||
{
|
||||
"level": 1,
|
||||
"name": "聚合模式",
|
||||
"rule": "命中聚合关键词(如:聚合/统计/count/汇总/分组/sum/求和/总计/合计)时,必须使用聚合模式",
|
||||
"action": "使用聚合字段(count(soid) as qty)与分组维度"
|
||||
}
|
||||
]
|
||||
},
|
||||
"aggregate_rules": {
|
||||
"metric_definitions": {
|
||||
"qty": "count(soid)",
|
||||
"premier_qty": "sum(if(whether_premier='Premier',1,0))"
|
||||
},
|
||||
"count_distinct_rule": "当用户指定对某列进行count统计时(如:统计SO数量、统计PN数量、统计订单数等),必须使用 count(distinct 列名) 而非 count(列名),以避免重复计数。例如:统计SO数量 → count(distinct service_order_id),统计PN数量 → count(distinct part_number)",
|
||||
"group_by_rule": "所有非聚合字段必须出现在 GROUP BY",
|
||||
"default_sorting": "qty DESC",
|
||||
"fallback_group_by": "聚合查询中,如未使用group by进行分组,select中默认增加使用update_date字段"
|
||||
},
|
||||
"default_behavior": {
|
||||
"detail_sorting": "soid, eta desc",
|
||||
"aggregate_sorting": "qty DESC",
|
||||
"limit": "如用户未要求,默认不加limit"
|
||||
},
|
||||
"alias_usage": "WHERE子句中支持使用字段别名进行查询,SELECT子句中使用原始字段名或别名均可",
|
||||
"select_alias_rename_rule": "生成SQL时,若用户在问题中使用了字段别名/字段名表达(如 country、tp、topmost、owner_name 等),SELECT子句需按用户表述进行重命名:SELECT 原始字段 AS 用户字段名,并保持用户字段出现顺序",
|
||||
"date_conversion": "所有日期字段必须使用cast(column as varchar(4096)) as column转为字符类型",
|
||||
"default_filters": ["is_dummy = '0'", "data_flag = 'Newest'"],
|
||||
"default_filters": ["data_flag = 'Newest'"],
|
||||
"data_flag_keyword_rule": "当用户问题包含'最新'、'Newest'、'latest'、'recent'等关键词时,使用 data_flag = 'Newest' 进行过滤",
|
||||
"eta_info_keyword_rule": "当用户问题包含'eta信息'时,仅展示eta信息指定字段",
|
||||
"eta_info_display_fields": "service_order_id as \"Service Order ID\", soid as \"SOID\", cast(service_order_creation_date as varchar(4096)) as \"Service Order Creation Date\", ship_to_country as \"Ship To Country\", part_number as \"Part Number\", topmost_pn as \"Topmost_PN\", commodity_code as \"Commodity_Code\", category as \"Category\", cast(eta as varchar(4096)) as \"ETA\", cast(so_eta as varchar(4096)) as \"SO ETA\", key_lenovo_ref_no as \"key_Lenovo Ref No\", order_type as \"order_type\", stm_planner as \"STM Planner\", region as \"Region\", dc_plant as \"DC Plant\", mtm as \"MTM\", machine_sn as \"Machine SN\", whether_premier as \"Whether_Premier\", service_type as \"Service_type\", warranty as \"Warranty\", parts_sales as \"Parts_sales\", customer as \"Customer\", life_cycle as \"TM_lifecycle\", model as \"Model\", aging_range as \"Aging_range\", lenovo_ref_no as \"Lenovo Ref No\", action as \"Action\", cast(update_date as varchar(4096)) as \"Update_date\"",
|
||||
"potential_stock_keyword_rule": "当用户问题包含'potential_stock'或'潜在库存'或'潜在stock'或'潜在库存信息'关键字时,必须同时查询以下所有库存字段:potential_ww_stock, potential_opo_stock, potential_other_dc_stock, potential_reverse_stock",
|
||||
"premier_qty_keyword_rule": "当用户问题包含'premier qty'、'premier_qty'、'premier数量'、'premier计数'、'premier统计'等关键词时,必须在SELECT中使用 sum(if(whether_premier='Premier',1,0)) as premier_qty 进行统计",
|
||||
"sub_rule_keyword_rule": "当用户问题包含'sub rule'、'Sub Rule'、'SUB RULE'、'sub_rule'、'不接受sub'、'Not accept sub'等关键词时,必须在WHERE子句中添加 action = 'Not accept sub' 进行精确过滤。该条件与data_flag = 'Newest'一起使用,生成格式为:WHERE ... AND action = 'Not accept sub' AND data_flag = 'Newest'",
|
||||
"passdue_keyword_rule": "当用户问题包含'passdue'、'past due'、'Passdue'、'PASSDUE'、'past_due'、'逾期'、'超期'、'过期'、'延误'等关键词时,必须在WHERE子句中添加 cast(update_date as date) - cast(eta as date) > 0 进行过滤,表示订单已超过预计到达日期。该条件使用日期类型减法比较,确保日期格式正确。生成格式为:WHERE ... AND cast(update_date as date) - cast(eta as date) > 0 AND data_flag = 'Newest'",
|
||||
"null_handling": "日期字段转换时保留NULL值",
|
||||
"model_query_rule": "查询model字段时必须使用like匹配,如: model like '%X13%'",
|
||||
"field_extraction_rule": "使用正则表达式和关键词匹配提取用户明确提到的字段,建立字段别名映射表",
|
||||
"field_order_rule": "用户提到的字段按问题中出现顺序排列在最前面,然后补充默认展示字段中未提及的字段",
|
||||
"topmost_pn and part_number_distinction": "确保区分topmost_pn(tp,tm,topmost)和part_number(pn)字段,避免混淆",
|
||||
"todays_date_handling": "当用户查询包含“今天”或“当前日期”的信息时,替换为系统当前日期进行过滤"
|
||||
"where_field_must_select": "where子句中出现的字段,必须加入select中查询展示",
|
||||
"no_status_filter": "where条件禁止使用status字段过滤",
|
||||
"country_code_mapping": "如果用户输入的关键字有:VN,AU,IN,HK,PH,KR,ID,TW,MO,FJ,LK,MY,SG,NZ,TH,JP,BD,则视为国家字段的数值过滤条件,增加ship_to_country = '国家代码'",
|
||||
"date_like_rule": "MM/DD类似格式日期转换为 like '%-MM-DD%' ,DD等格式转换为 like '%-DD%'",
|
||||
"topmost_pn_and_part_number_distinction": "确保区分topmost_pn(tp,tm,topmost,TOPMOST,TM)和part_number(pn)字段,避免混淆",
|
||||
"alias_priority_rules": "别名匹配需大小写不敏感;tm/TM/topmost/TOPMOST/topmost pn均映射为topmost_pn;mtm只映射mtm,不得与tm混淆",
|
||||
"order_type_warranty_disambiguation": "order_type与warranty可能共享值集合(如MDOA/OPT/CLW/DOA/FOC/OOW/OBL/ADW)。生成SQL时必须根据用户问题中的字段名或语义确认过滤目标字段;若用户未明确字段名且值仅命中该集合,不得擅自选择字段,需优先使用上下文关键词(订单类型/保修/质保)进行判断",
|
||||
"todays_date_handling": "当用户查询包含'今天'或'当前日期'或'today'的信息时,使用update_date = substr(now(),1,10)进行过滤",
|
||||
"top_n_rules": {
|
||||
"recognition_triggers": ["top", "Top", "TOP", "前", "最高", "最大", "最小", "排名"],
|
||||
"require_limit": "识别为TopN查询时,必须使用LIMIT N",
|
||||
"require_order_by": "识别为TopN查询时,必须包含ORDER BY排序字段",
|
||||
"default_limit": "用户未明确N时,默认使用LIMIT 10",
|
||||
"default_order_by": "用户未指定排序字段时,默认使用count(soid)作为排序键",
|
||||
"dimension_topn_rule": "当用户表达为'by {维度} top N'或'按{维度} top N'时,只能选择该维度字段 + qty(count(soid)),禁止选择其他明细字段;必须对该维度GROUP BY,并使用count(soid) as qty排序:ORDER BY qty DESC",
|
||||
"dimension_topn_default": "TopN查询默认使用用户指定的维度 + count(soid) as qty 作为排序结果",
|
||||
"dimension_topn_where_rule": "维度过滤条件仅用于WHERE(如 model 使用lower(model) like '%x%'),但SELECT仍只保留维度字段 + qty"
|
||||
}
|
||||
},
|
||||
"field_mapping_reference": {
|
||||
"critical_note": "此表包含最新状态数据和历史变更数据的联合,通过data_flag区分。最新数据(Newest)每条订单只有一条记录,历史数据(Changelog)每条订单有多条记录。所有日期字段在查询时自动转换为字符类型。请注意检查用户是否使用了字段的alias,不要忽略!!!系统字段(is_passdue, data_flag)仅用于WHERE过滤,不显示在SELECT结果中。用户提到的字段应优先显示在SELECT子句最前面。",
|
||||
"critical_note": "此表包含最新状态数据和历史变更数据的联合,通过data_flag区分。最新数据(Newest)每条订单只有一条记录,历史数据(Changelog)每条订单有多条记录。所有日期字段在查询时自动转换为字符类型。请注意检查用户是否使用了字段的alias,不要忽略!!!系统字段(data_flag)仅用于WHERE过滤,不显示在SELECT结果中。用户提到的字段应优先显示在SELECT子句最前面。",
|
||||
"critical_note1": {"type":"字段类型", "desc":"字段描述", "format": "数据格式", "query_format": "查询时数据格式" ,"example":"字段示例值", "values":"枚举值", "alias":"字段别名"},
|
||||
"key_identifiers": {
|
||||
"service_order_id": {
|
||||
@@ -77,14 +123,14 @@
|
||||
"alias": ["pn", "part", "parts", "物料号", "零件号", "Part Number", "材料号", "物料编码", "零件编码"]
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"milestone_date_fields": {
|
||||
"service_order_creation_date": {
|
||||
"type": "datetime",
|
||||
"desc": "开单日期",
|
||||
"desc": "开单日期/开单时间,即这条记录的创建时间,即 Backlog Order 的创建/新增时间,即 BO 的创建/新增时间。业务含义:当前数据的 update_date 与 service_order_creation_date 相减即为该订单的存续时间(订单从创建到当前状态的时间跨度)",
|
||||
"format": "YYYY-MM-DD HH:MM:SS",
|
||||
"query_format": "作为字符串展示",
|
||||
"alias": ["create_date", "创建时间", "下单时间", "开单日期", "SO创建时间", "开单时间", "Order Creation Date", "created_date", "创建日期"]
|
||||
"alias": ["create_date", "创建时间", "create 时间", "开单日期", "SO创建时间", "开单时间", "Order Creation Date", "created_date", "创建日期", "存续时间", "订单时长", "BO创建时间", "BO新增时间", "Backlog Order创建时间", "Backlog Order新增时间", "记录创建时间", "记录新增时间"]
|
||||
},
|
||||
"eta": {
|
||||
"type": "date",
|
||||
@@ -115,19 +161,60 @@
|
||||
"alias": ["更新时间", "更新日期", "历史数据状态更新日期", "修改时间"]
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"additional_fields": {
|
||||
"bu": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "业务单元",
|
||||
"alias": ["bu", "BU", "业务单元", "业务线"]
|
||||
},
|
||||
"multiple_flag": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "多重影响标识",
|
||||
"alias": ["multiple_flag", "multi_flag", "多重标识", "多标识"]
|
||||
},
|
||||
"country_dc_premier_stock": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "国家DC Premier库存",
|
||||
"alias": ["country_dc_premier_stock", "premier_stock", "premier stock","国家DC优先库存", "国家DC优先库存量"]
|
||||
},
|
||||
"potential_ww_stock": {
|
||||
"type": "varchar(63355)",
|
||||
"desc": "潜在全球库存",
|
||||
"alias": ["potential_ww_stock", "ww_stock", "潜在全球库存", "潜在WW库存"]
|
||||
},
|
||||
"potential_opo_stock": {
|
||||
"type": "varchar(63355)",
|
||||
"desc": "潜在OPO库存",
|
||||
"alias": ["potential_opo_stock", "opo_stock", "潜在OPO库存", "OPO库存"]
|
||||
},
|
||||
"potential_other_dc_stock": {
|
||||
"type": "varchar(63355)",
|
||||
"desc": "潜在其他DC库存",
|
||||
"alias": ["potential_other_dc_stock", "other_dc_stock", "潜在其他DC库存", "其他DC库存"]
|
||||
},
|
||||
"potential_reverse_stock": {
|
||||
"type": "varchar(63355)",
|
||||
"desc": "潜在逆向库存",
|
||||
"alias": ["potential_reverse_stock", "reverse_stock", "潜在逆向库存", "逆向库存"]
|
||||
},
|
||||
"owner": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "负责人/归属人, 查询时必须转换为小写并使用like匹配, 如: lower(owner) like '%senilaf%' ",
|
||||
"example": "senilaf",
|
||||
"alias": ["owner", "负责人", "归属人", "owner_name", "责任人", "持有人"]
|
||||
},
|
||||
"topmost_pn": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "最紧缺物料号, 注意与pn区分, 这是topmost pn, 这是topmost pn, 这是topmost pn, 不是PN",
|
||||
"example": "5CB1L57599",
|
||||
"alias": ["tp","tm", "最紧缺物料号", "Topmost Part Number", "topmost", "topmost pn"]
|
||||
"alias": ["tp", "tm", "TM", "TOPMOST", "Topmost", "Topmost Part Number", "topmost", "topmost pn", "TOPMOST PN", "topmost_pn", "top-most"]
|
||||
},
|
||||
"commodity_code": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "商品编码",
|
||||
"example": "PL",
|
||||
"alias": ["commodity", "商品代码", "编码", "cc", "物料分类", "Commodity Code", "商品类别", "物料类型", "商品编码"]
|
||||
"alias": ["commodity", "商品代码", "CC", "cc", "物料分类", "Commodity Code", "商品类别", "物料类型", "商品编码"]
|
||||
},
|
||||
"ship_to_country": {
|
||||
"type": "varchar(4096)",
|
||||
@@ -167,7 +254,7 @@
|
||||
},
|
||||
"model": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "Lenovo的机型, 禁止使用model = 'model_name', 查询时必须转换为小写并使用like匹配,如: lower(model) like '%X13%'",
|
||||
"desc": "Lenovo的机型, 禁止使用model = 'model_name', 查询时model_name必须转换为小写并使用like匹配,如: lower(model) like '%x13%'",
|
||||
"example": ["Yoga 7 16IAH7", "X13 GEN3", "T16 Gen4 AMD", "Legion 7 16ACHg6"],
|
||||
"alias": ["model", "机型", "型号", "Model", "设备型号", "机器型号"]
|
||||
},
|
||||
@@ -190,7 +277,7 @@
|
||||
},
|
||||
"whether_premier": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "优先级标识,默认查询 'Premier'",
|
||||
"desc": "优先级标识,默认查询 'Premier'。当用户需要统计Premier订单数量时,使用 sum(if(whether_premier='Premier',1,0)) as premier_qty",
|
||||
"values": ["Starndard", "Premier"],
|
||||
"alias": ["premier", "优质服务", "是否优质", "是否Premier", "Premier服务", "是否优先", "Whether Premier", "优先服务标识", "VIP服务"]
|
||||
},
|
||||
@@ -210,9 +297,16 @@
|
||||
"desc": "零件销售信息",
|
||||
"alias": ["零件销售", "销售信息", "部件销售", "配件销售", "销售数据"]
|
||||
},
|
||||
"action": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "操作/动作标识,用于标识订单当前执行的操作类型。当用户提到'sub rule'时,该字段精确匹配 action = 'Not accept sub'",
|
||||
"example": "Not accept sub",
|
||||
"alias": ["action", "操作", "动作", "Action", "操作类型", "sub rule", "Sub Rule", "SUB RULE", "sub_rule", "不接受sub", "Not accept sub"]
|
||||
},
|
||||
"warranty": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "保修信息",
|
||||
"values": ["MDOA", "OPT", "CLW", "DOA", "FOC", "OOW", "OBL", "ADW"],
|
||||
"alias": ["保修", "保修信息", "质保", "保修条款", "保修状态"]
|
||||
},
|
||||
"aging_day": {
|
||||
@@ -239,12 +333,6 @@
|
||||
"values": ["0-7D", "8-14D", "15-21D", "22-28D", "28D+", "null"],
|
||||
"alias": ["账龄天数", "账龄", "recovery range", "账期分类", "账龄分类", "天数分类"]
|
||||
},
|
||||
"action": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "操作/规则",
|
||||
"example": "Not accept sub",
|
||||
"alias": ["sub_rule", "操作", "规则", "限制规则", "操作类型", "处理规则"]
|
||||
},
|
||||
"order_type":{
|
||||
"type": "varchar(4096)",
|
||||
"desc": "订单类型",
|
||||
@@ -275,30 +363,40 @@
|
||||
"type": "varchar(4096)",
|
||||
"desc": "house air way bill",
|
||||
"examples": ["DIM042186899"],
|
||||
"alias": ["分运单号", "运单号", "代理运单", "分运单", "house air way bill"]
|
||||
"alias": ["hawb", "HAWB", "Hawb", "分运单号", "运单号", "代理运单", "分运单", "house air way bill", "house airway bill", "house air waybill", "house airway waybill", "air way bill", "air waybill", "HAWB No", "HAWB NO", "HAWB号码", "HAWB号", "分运单", "分运单编号", "分运单号码"]
|
||||
},
|
||||
"bol": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "bill of lading",
|
||||
"examples": ["OOLU2678082490"],
|
||||
"alias": ["bol", "BOL", "Bol", "bill of lading", "B/L", "b/l", "提单", "提单号", "提单编号", "海运提单", "货运提单", "BOL No", "BOL NO", "BOL号", "BOL号码"]
|
||||
},
|
||||
"dn": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "delivery note / delivery number",
|
||||
"examples": ["0081234567"],
|
||||
"alias": ["dn", "DN", "Dn", "delivery note", "delivery number", "delivery no", "送货单", "送货单号", "交货单", "交货单号", "出货单", "出货单号", "DN No", "DN NO", "DN号", "DN号码"]
|
||||
},
|
||||
"po": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "purchase order",
|
||||
"examples": ["4501234567"],
|
||||
"alias": ["po", "PO", "Po", "purchase order", "purchase order number", "采购单", "采购单号", "采购订单", "采购订单号", "PO No", "PO NO", "PO号", "PO号码"]
|
||||
},
|
||||
"prid": {
|
||||
"type": "varchar(4096)",
|
||||
"desc": "采购申请/内部请求标识",
|
||||
"examples": ["PR12345678"],
|
||||
"alias": ["prid", "PRID", "Prid", "pr id", "PR ID", "purchase request id", "采购申请号", "采购申请编号", "申请单号", "请求单号", "内部请求号", "PRID号", "PRID号码"]
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"system_flag_fields": {
|
||||
"is_passdue": {
|
||||
"type": "varchar(64)",
|
||||
"desc": "是否逾期:'1'表示逾期,'0'表示正常",
|
||||
"business_rule": "根据用户要求过滤, 禁止出现在SELECT中",
|
||||
"display_rule": "仅用于WHERE过滤,不显示",
|
||||
"alias": ["passdue", "逾期标志", "是否逾期", "overdue", "超期标志", "逾期标识"]
|
||||
},
|
||||
"is_dummy": {
|
||||
"type": "varchar(64)",
|
||||
"desc": "是否为虚拟/测试数据:'1'表示是dummy数据,'0'表示真实数据",
|
||||
"business_rule": "默认过滤掉dummy数据(is_dummy='0'),除非用户指定, 禁止出现在SELECT中",
|
||||
"display_rule": "仅用于WHERE过滤,不显示",
|
||||
"alias": ["dummy", "虚拟标志", "是否虚拟", "测试数据", "假数据标识", "模拟数据"]
|
||||
},
|
||||
"data_flag": {
|
||||
"type": "varchar(64)",
|
||||
"desc": "数据标志:'Newest'表示最新状态,'Changelog'表示历史变更",
|
||||
"example": "Newest",
|
||||
"business_rule": "默认查询最新状态(Newest),查询历史时使用Changelog, 禁止出现在SELECT中",
|
||||
"business_rule": "默认查询最新状态(Newest),查询历史时使用Changelog, 禁止出现在SELECT中,where条件中出现update_date则不使用data_flag进行过滤",
|
||||
"display_rule": "仅用于WHERE过滤,不显示",
|
||||
"alias": ["数据标志", "数据类型", "数据状态", "记录类型", "数据分类"]
|
||||
}
|
||||
@@ -306,59 +404,84 @@
|
||||
},
|
||||
"examples": {
|
||||
"newest_status_all_fields": {
|
||||
"user": "请查询SO:4020986743的全部字段",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE (service_order_id = '4020986743' or soid = '4020986743') AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"user": "How about the ETA of 4020731111 and 4020947030?",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE (service_order_id in ('4020731111', '4020947030') or soid in ('4020731111', '4020947030')) AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "默认查询最新状态,按默认展示字段顺序显示所有字段(除系统字段),日期字段转换为字符类型"
|
||||
},
|
||||
"history_records_all_fields": {
|
||||
"user": "查看2025年12月31的so为4020438779的历史变更记录",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE (service_order_id = '4020438779' or soid = '4020438779') AND cast(update_date as varchar(4096)) like '%2025-12-31%' AND is_dummy = '0' AND data_flag = 'Changelog' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "查询历史变更记录,按默认展示字段顺序显示所有字段(除系统字段),日期字段转换为字符类型"
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE service_order_id = '4020438779' AND cast(update_date as varchar(4096)) like '%2025-12-31%' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "查询历史变更记录,按默认展示字段顺序显示所有字段(除系统字段),日期字段转换为字符类型,且用户指定了update_date进行过滤,去掉data_flag = 'Newest'的默认过滤条件"
|
||||
},
|
||||
"specific_fields_query": {
|
||||
"user": "查询SO为4020438779的country, eta, order_type",
|
||||
"sql": "SELECT ship_to_country, cast(eta as varchar(4096)) as eta, order_type, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, part_number, topmost_pn, commodity_code, category, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE (service_order_id = '4020438779' or soid = '4020438779') AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"sql": "SELECT ship_to_country, cast(eta as varchar(4096)) as eta, order_type, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, part_number, topmost_pn, commodity_code, category, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE service_order_id = '4020438779' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "用户提到的字段(ship_to_country, eta, order_type)优先显示在最前面,然后补充其他默认展示字段"
|
||||
},
|
||||
"aggragate_query": {
|
||||
"user": "by country, key_Lenovo Ref No, eta 汇总REGION=CAP passdue 信息, 并从小到大排序",
|
||||
"sql": "SELECT region, ship_to_country, key_lenovo_ref_no, cast(eta as varchar(4096)) as eta, count(1) FROM dwd_ai.apbo_eta_ful WHERE is_passdue = '1' AND is_dummy = '0' AND data_flag = 'Newest' AND region = 'CAP' group by region, ship_to_country, key_lenovo_ref_no, cast(eta as varchar(4096)) ORDER BY count(1) ASC",
|
||||
"field_selection_reason": "查询特定账龄的订单,按默认展示字段顺序显示,日期字段转换为字符类型"
|
||||
"user": "by country, key_Lenovo Ref No, eta 汇总REGION=CAP 信息, 并从小到大排序",
|
||||
"sql": "SELECT region, ship_to_country, key_lenovo_ref_no, cast(eta as varchar(4096)) as eta, count(soid) as qty FROM dwd_ai.apbo_eta_ful WHERE data_flag = 'Newest' AND region = 'CAP' group by region, ship_to_country, key_lenovo_ref_no, cast(eta as varchar(4096)) ORDER BY qty DESC",
|
||||
"field_selection_reason": "聚合查询,qty默认降序排序"
|
||||
},
|
||||
"overdue_orders_all_fields": {
|
||||
"user": "查询所有passdue/逾期的订单",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE is_passdue = '1' AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "查询逾期订单,按默认展示字段顺序显示,日期字段转换为字符类型"
|
||||
"topn_by_topmost_pn_model_qty": {
|
||||
"user": "by topmost_pn, model 查询 top 10",
|
||||
"sql": "SELECT topmost_pn, model, count(soid) as qty FROM dwd_ai.apbo_eta_ful WHERE data_flag = 'Newest' GROUP BY topmost_pn, model ORDER BY qty DESC LIMIT 10",
|
||||
"field_selection_reason": "按维度TopN,仅输出维度字段+qty"
|
||||
},
|
||||
"topn_by_country_qty": {
|
||||
"user": "CC为LT ,by country 查询 top 20",
|
||||
"sql": "SELECT commodity_code,ship_to_country, count(soid) as qty FROM dwd_ai.apbo_eta_ful WHERE data_flag = 'Newest' AND commodity_code = 'LT'GROUP BY commodity_code, ship_to_country ORDER BY qty DESC LIMIT 20",
|
||||
"field_selection_reason": "按维度TopN,默认使用维度+qty排序,仅输出维度字段+qty"
|
||||
},
|
||||
"Machine_sn_query": {
|
||||
"user": "SN PF4C8CBL的order 信息",
|
||||
"sql": "SELECT machine_sn, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE machine_sn = 'PF4C8CBL' AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"sql": "SELECT machine_sn, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE machine_sn = 'PF4C8CBL' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "用户提到的字段(machine_sn)优先显示在最前面,然后补充其他默认展示字段"
|
||||
},
|
||||
"status_query": {
|
||||
"user": "查询状态为wrong order的订单",
|
||||
"sql": "SELECT status, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE status = 'wrong order' AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"sql": "SELECT status, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE status = 'wrong order' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "用户提到的字段(status)优先显示在最前面,然后补充其他默认展示字段"
|
||||
},
|
||||
"multiple_fields_query": {
|
||||
"user": "查看SN为PF4C8CBL的订单状态和机器型号",
|
||||
"sql": "SELECT machine_sn, status, model, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE machine_sn = 'PF4C8CBL' AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"sql": "SELECT machine_sn, status, model, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE machine_sn = 'PF4C8CBL' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "用户提到的字段(machine_sn, status, model)按问题中出现的顺序优先显示在最前面,然后补充其他默认展示字段"
|
||||
},
|
||||
"model_query_all_fields": {
|
||||
"user": "查询机型包含X13的订单",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE model like '%X13%' AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE lower(model) like '%x13%' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "查询特定机型的订单,使用like匹配model字段,按默认展示字段顺序显示"
|
||||
},
|
||||
"order_type_query_all_fields": {
|
||||
"user": "查询订单类型为MDOA的订单",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE order_type = 'MDOA' AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE order_type = 'MDOA' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "查询特定订单类型的订单,按默认展示字段顺序显示"
|
||||
},
|
||||
"passdue_info_query": {
|
||||
"user": "region = ANZ 的passdue 信息",
|
||||
"sql": "SELECT region, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE is_passdue = '1' AND is_dummy = '0' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "查询逾期订单的详细信息,按默认展示字段顺序显示"
|
||||
"region_info_query": {
|
||||
"user": "region = ANZ 的信息",
|
||||
"sql": "SELECT region, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE data_flag = 'Newest' AND region = 'ANZ' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "按区域查询,按默认展示字段顺序显示"
|
||||
},
|
||||
"sub_rule_query": {
|
||||
"user": "查询sub rule的订单",
|
||||
"sql": "SELECT action, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE action = 'Not accept sub' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "用户提到'sub rule',触发sub_rule_keyword_rule,在WHERE中添加 action = 'Not accept sub' 进行精确过滤"
|
||||
},
|
||||
"sub_rule_with_country_query": {
|
||||
"user": "查询country为VN的sub rule订单信息",
|
||||
"sql": "SELECT action, ship_to_country, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE action = 'Not accept sub' AND ship_to_country = 'VN' AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "用户提到'sub rule'且指定country=VN,WHERE中同时包含 action = 'Not accept sub' 和 ship_to_country = 'VN'"
|
||||
},
|
||||
"passdue_query": {
|
||||
"user": "查询passdue的订单",
|
||||
"sql": "SELECT service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, ship_to_country, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE cast(update_date as date) - cast(eta as date) > 0 AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "用户提到'passdue',触发passdue_keyword_rule,在WHERE中添加 cast(update_date as date) - cast(eta as date) > 0 过滤逾期订单"
|
||||
},
|
||||
"passdue_with_country_query": {
|
||||
"user": "查询country为AU的passdue订单",
|
||||
"sql": "SELECT ship_to_country, service_order_id, soid, cast(service_order_creation_date as varchar(4096)) as service_order_creation_date, part_number, topmost_pn, commodity_code, category, cast(eta as varchar(4096)) as eta, cast(so_eta as varchar(4096)) as so_eta, key_lenovo_ref_no, order_type, stm_planner, region, dc_plant, mtm, machine_sn, whether_premier, service_type, warranty, parts_sales, customer, life_cycle, model, aging_range, lenovo_ref_no, action, cast(update_date as varchar(4096)) as update_date FROM dwd_ai.apbo_eta_ful WHERE ship_to_country = 'AU' AND cast(update_date as date) - cast(eta as date) > 0 AND data_flag = 'Newest' ORDER BY soid, eta DESC",
|
||||
"field_selection_reason": "用户提到'passdue'且指定country=AU,WHERE中同时包含 ship_to_country = 'AU' 和 cast(update_date as date) - cast(eta as date) > 0"
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-13
@@ -5,13 +5,14 @@
|
||||
"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"],
|
||||
"data_source": "dwd_ai.apbo_eta_milestone",
|
||||
"fields_list": ["service_order_id", "soid", "part_number", "PO", "po_creation_date", "prid", "DN", "dn_date", "gi_date", "BOL", "hawb", "pickup_time", "flight_etd", "flight_atd", "flight_eta", "flight_ata", "eta", "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"
|
||||
"rule3": "部分字段select时的顺序如下:po,po_creation_date,prid,dn,dn_date,gi_date,bol,hawb,pickup_time,flight_etd,flight_atd,flight_eta,flight_ata,eta,pod,gr_date",
|
||||
"rule4": "禁止使用limit",
|
||||
"rule5": "status和category字段必须固定在最前面两列展示,且每次查询都必须包含这两个字段"
|
||||
},
|
||||
|
||||
"optional_fields": {
|
||||
@@ -54,14 +55,15 @@
|
||||
"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", "实际到达时间"]},
|
||||
"flight_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": ["预计出发", "计划出发时间", "flight_etd", "预计离港时间"]},
|
||||
"flight_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": ["实际出发", "实际离港时间", "flight_atd", "实际出发时间"]},
|
||||
"flight_eta": {"type": "date", "desc": "航班预计到达时间(Flight Estimated Time of Arrival)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["航班预计到达", "航班计划到达时间", "flight_eta", "航班预计到港时间"]},
|
||||
"flight_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": ["实际到达", "实际到港时间", "flight_ata", "实际到达时间"]},
|
||||
"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", "预计到港时间"]},
|
||||
"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"]}
|
||||
"so_eta": {"type": "date", "desc": "订单预计到达时间(SO ata)", "format": "YYYY-MM-DD HH:MM:SS", "query_format": "CAST(field_name AS VARCHAR(2048)) AS field_name 作为字符串展示", "alias": ["订单最终到达时间", "订单ETA", "服务订单预计到达", "Service Order ata"]}
|
||||
},
|
||||
|
||||
"additional_fields": {
|
||||
@@ -85,13 +87,13 @@
|
||||
"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,日期字段已格式化为指定字符串格式"
|
||||
"sql": "SELECT status, category, 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(flight_etd AS VARCHAR(2048)) as flight_etd, CAST(flight_atd AS VARCHAR(2048)) as flight_atd, CAST(flight_eta AS VARCHAR(2048)) as flight_eta, CAST(flight_ata AS VARCHAR(2048)) as flight_ata, CAST(eta AS VARCHAR(2048)) as eta, 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_eta_milestone ORDER BY status_date DESC, service_order_creation_date DESC",
|
||||
"field_selection_reason": "基础查询显示所有必填的milestone字段,包括新增的service_order_creation_date, so_eta,日期字段已格式化为指定字符串格式,status和category固定在最前面两列"
|
||||
},
|
||||
"按主订单号查询": {
|
||||
"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字段,包含所有必填字段,日期字段已格式化为字符串"
|
||||
"sql": "SELECT status, category, 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(flight_etd AS VARCHAR(2048)) as flight_etd, CAST(flight_atd AS VARCHAR(2048)) as flight_atd, CAST(flight_eta AS VARCHAR(2048)) as flight_eta, CAST(flight_ata AS VARCHAR(2048)) as flight_ata, CAST(eta AS VARCHAR(2048)) as eta, 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_eta_milestone WHERE service_order_id = '4019630464' ORDER BY status_date DESC, service_order_creation_date DESC",
|
||||
"field_selection_reason": "用户提到'SO',根据映射规则应查询service_order_id字段,包含所有必填字段,日期字段已格式化为字符串,status和category固定在最前面两列"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
{
|
||||
"meta": {
|
||||
"domain": "TP物料多重影响聚合分析",
|
||||
"keywords": [
|
||||
"multiple impact",
|
||||
"tp物料",
|
||||
"topmost_pn",
|
||||
"part_number",
|
||||
"region",
|
||||
"warranty",
|
||||
"ADW",
|
||||
"CLW",
|
||||
"DOA",
|
||||
"FOC",
|
||||
"MDOA",
|
||||
"OBL",
|
||||
"OOW",
|
||||
"OPT",
|
||||
"multipal_impact"
|
||||
],
|
||||
"description": "此模型用于查询 TP 物料多重影响聚合结果。数据已经按 topmost_pn、part_number、region 聚合,并补充各 warranty 类型计数以及总多重影响数 multipal_impact。支持明细展示、汇总统计、TopN 排名等查询方式。",
|
||||
"data_source": "dwd_ai.apbo_eta_multiple_impact"
|
||||
},
|
||||
"data_model_specification": {
|
||||
"fields_list": [
|
||||
"topmost_pn",
|
||||
"part_number",
|
||||
"region",
|
||||
"qty",
|
||||
"ADW",
|
||||
"CLW",
|
||||
"DOA",
|
||||
"FOC",
|
||||
"MDOA",
|
||||
"OBL",
|
||||
"OOW",
|
||||
"OPT",
|
||||
"multipal_impact"
|
||||
],
|
||||
"mandatory_display_fields": {
|
||||
"default_fields": "topmost_pn, part_number, region, qty, ADW, CLW, DOA, FOC, MDOA, OBL, OOW, OPT, multipal_impact",
|
||||
"rule1": "默认展示全部业务字段。",
|
||||
"rule2": "用户明确指定字段时,优先按用户提及顺序展示这些字段。",
|
||||
"rule3": "明细模式默认保留 topmost_pn, part_number, region, qty, multipal_impact 以及相关 warranty 字段。",
|
||||
"rule4": "聚合/TopN 模式仅保留分组维度字段与聚合结果字段。"
|
||||
},
|
||||
"optional_fields": {
|
||||
"identifier_fields": ["topmost_pn", "part_number"],
|
||||
"dimension_fields": ["region"],
|
||||
"metric_fields": ["qty", "multipal_impact", "ADW", "CLW", "DOA", "FOC", "MDOA", "OBL", "OOW", "OPT"],
|
||||
"warranty_metric_fields": ["ADW", "CLW", "DOA", "FOC", "MDOA", "OBL", "OOW", "OPT"]
|
||||
}
|
||||
},
|
||||
"business_logic_rules": {
|
||||
"query_recognition_rules": {
|
||||
"detail_mode_keywords": ["有哪些", "查看", "列出", "显示", "查询", "明细", "详情", "具体"],
|
||||
"aggregate_mode_keywords": ["统计", "汇总", "总数", "有多少", "数量", "count", "计数", "分组", "分布", "sum", "合计"],
|
||||
"topn_mode_keywords": ["top", "前", "排名", "最高", "最大", "最多"],
|
||||
"multiple_impact_keywords": ["multiple impact", "多重影响", "影响数", "multipal impact", "multipal_impact"],
|
||||
"warranty_keywords": ["ADW", "CLW", "DOA", "FOC", "MDOA", "OBL", "OOW", "OPT", "warranty"]
|
||||
},
|
||||
"default_behavior": {
|
||||
"detail_sorting": "multipal_impact DESC, qty DESC, topmost_pn, part_number, region",
|
||||
"aggregate_sorting": "qty DESC",
|
||||
"limit": "用户未要求时默认不加 LIMIT"
|
||||
},
|
||||
"aggregate_rules": {
|
||||
"metric_definitions": {
|
||||
"qty": "SUM(qty)",
|
||||
"multipal_impact": "SUM(multipal_impact)",
|
||||
"ADW": "SUM(ADW)",
|
||||
"CLW": "SUM(CLW)",
|
||||
"DOA": "SUM(DOA)",
|
||||
"FOC": "SUM(FOC)",
|
||||
"MDOA": "SUM(MDOA)",
|
||||
"OBL": "SUM(OBL)",
|
||||
"OOW": "SUM(OOW)",
|
||||
"OPT": "SUM(OPT)"
|
||||
},
|
||||
"group_by_rule": "所有非聚合字段必须出现在 GROUP BY 中。",
|
||||
"default_metric": "SUM(qty) AS qty"
|
||||
},
|
||||
"top_n_rules": {
|
||||
"recognition_triggers": ["top", "前", "排名", "最高", "最大", "最多"],
|
||||
"require_limit": "识别为 TopN 查询时必须使用 LIMIT N。",
|
||||
"default_limit": "用户未明确 N 时默认 LIMIT 10。",
|
||||
"default_order_by": "默认按 qty DESC 或 multipal_impact DESC 排序。"
|
||||
},
|
||||
"alias_usage": "允许用户使用字段别名或业务词汇,生成 SQL 时应映射到真实字段。",
|
||||
"where_field_must_select": "WHERE 中出现的业务字段默认也应出现在 SELECT 中;TopN 聚合查询除外,仅保留维度字段和聚合指标。",
|
||||
"warranty_metric_rule": "ADW、CLW、DOA、FOC、MDOA、OBL、OOW、OPT 均为已聚合的 warranty 计数字段,查询时直接使用,不需要再根据 warranty 字段二次统计。",
|
||||
"multiple_impact_rule": "multipal_impact 为表中现成字段;当用户表达 multiple impact 总量时,优先使用该字段。",
|
||||
"no_legacy_field_rule": "禁止再使用 pal_2h、service_order_id、soid 等旧表结构字段。"
|
||||
},
|
||||
"field_mapping_reference": {
|
||||
"critical_note": "该表已经是聚合结果表,不存在 pal_2h、service_order_id、soid 等旧明细字段。请仅基于 topmost_pn、part_number、region、qty、各 warranty 聚合字段以及 multipal_impact 生成 SQL。",
|
||||
"key_identifiers": {
|
||||
"topmost_pn": {
|
||||
"type": "varchar",
|
||||
"desc": "TP 物料编号",
|
||||
"example": "02HK965",
|
||||
"alias": ["tp", "物料", "物料号", "零件号", "TP物料", "topmost", "topmost pn", "topmost_pn"]
|
||||
},
|
||||
"part_number": {
|
||||
"type": "varchar",
|
||||
"desc": "料号",
|
||||
"example": "5D11J74767",
|
||||
"alias": ["pn", "part number", "part_number", "料号", "零件料号", "部件号"]
|
||||
},
|
||||
"region": {
|
||||
"type": "varchar",
|
||||
"desc": "区域",
|
||||
"example": "ANZ",
|
||||
"alias": ["region", "区域", "大区", "地区"]
|
||||
}
|
||||
},
|
||||
"metric_fields": {
|
||||
"qty": {
|
||||
"type": "bigint",
|
||||
"desc": "当前 topmost_pn + part_number + region 粒度下的订单数量",
|
||||
"alias": ["qty", "数量", "订单数", "记录数", "count"]
|
||||
},
|
||||
"multipal_impact": {
|
||||
"type": "bigint",
|
||||
"desc": "多重影响总数,字段名以表结构为准保留 multipal_impact 拼写",
|
||||
"alias": ["multiple impact", "multiple_impact", "multipal impact", "multipal_impact", "多重影响", "影响数", "总影响数"]
|
||||
},
|
||||
"ADW": {
|
||||
"type": "bigint",
|
||||
"desc": "warranty=ADW 的计数",
|
||||
"alias": ["ADW", "adw"]
|
||||
},
|
||||
"CLW": {
|
||||
"type": "bigint",
|
||||
"desc": "warranty=CLW 的计数",
|
||||
"alias": ["CLW", "clw"]
|
||||
},
|
||||
"DOA": {
|
||||
"type": "bigint",
|
||||
"desc": "warranty=DOA 的计数",
|
||||
"alias": ["DOA", "doa"]
|
||||
},
|
||||
"FOC": {
|
||||
"type": "bigint",
|
||||
"desc": "warranty=FOC 的计数",
|
||||
"alias": ["FOC", "foc"]
|
||||
},
|
||||
"MDOA": {
|
||||
"type": "bigint",
|
||||
"desc": "warranty=MDOA 的计数",
|
||||
"alias": ["MDOA", "mdoa"]
|
||||
},
|
||||
"OBL": {
|
||||
"type": "bigint",
|
||||
"desc": "warranty=OBL 的计数",
|
||||
"alias": ["OBL", "obl"]
|
||||
},
|
||||
"OOW": {
|
||||
"type": "bigint",
|
||||
"desc": "warranty=OOW 的计数",
|
||||
"alias": ["OOW", "oow"]
|
||||
},
|
||||
"OPT": {
|
||||
"type": "bigint",
|
||||
"desc": "warranty=OPT 的计数",
|
||||
"alias": ["OPT", "opt"]
|
||||
}
|
||||
},
|
||||
"condition_mapping": {
|
||||
"有multiple impact": "multipal_impact > 0",
|
||||
"有多重影响": "multipal_impact > 0",
|
||||
"有qty": "qty > 0",
|
||||
"有ADW": "ADW > 0",
|
||||
"有CLW": "CLW > 0",
|
||||
"有DOA": "DOA > 0",
|
||||
"有FOC": "FOC > 0",
|
||||
"有MDOA": "MDOA > 0",
|
||||
"有OBL": "OBL > 0",
|
||||
"有OOW": "OOW > 0",
|
||||
"有OPT": "OPT > 0"
|
||||
}
|
||||
},
|
||||
"examples": {
|
||||
"detail_mode_examples": {
|
||||
"example1": {
|
||||
"user": "列出 topmost_pn 为 02HK965 的 multiple impact 明细",
|
||||
"mode": "detail_mode",
|
||||
"sql": "SELECT topmost_pn, part_number, region, qty, ADW, CLW, DOA, FOC, MDOA, OBL, OOW, OPT, multipal_impact FROM dwd_ai.apbo_eta_multiple_impact WHERE topmost_pn = '02HK965' ORDER BY multipal_impact DESC, qty DESC, topmost_pn, part_number, region"
|
||||
},
|
||||
"example2": {
|
||||
"user": "查看 region 为 ANZ 且 ADW 有值的记录",
|
||||
"mode": "detail_mode",
|
||||
"sql": "SELECT region, ADW, topmost_pn, part_number, qty, CLW, DOA, FOC, MDOA, OBL, OOW, OPT, multipal_impact FROM dwd_ai.apbo_eta_multiple_impact WHERE region = 'ANZ' AND ADW > 0 ORDER BY multipal_impact DESC, qty DESC, topmost_pn, part_number, region"
|
||||
},
|
||||
"example3": {
|
||||
"user": "查询 pn 为 5D11J74767 的 TP 物料影响",
|
||||
"mode": "detail_mode",
|
||||
"sql": "SELECT part_number, topmost_pn, region, qty, ADW, CLW, DOA, FOC, MDOA, OBL, OOW, OPT, multipal_impact FROM dwd_ai.apbo_eta_multiple_impact WHERE part_number = '5D11J74767' ORDER BY multipal_impact DESC, qty DESC, topmost_pn, part_number, region"
|
||||
}
|
||||
},
|
||||
"aggregate_mode_examples": {
|
||||
"example1": {
|
||||
"user": "按 region 统计 multiple impact 数量",
|
||||
"mode": "aggregate_mode",
|
||||
"sql": "SELECT region, SUM(multipal_impact) AS multipal_impact, SUM(qty) AS qty FROM dwd_ai.apbo_eta_multiple_impact GROUP BY region ORDER BY multipal_impact DESC, qty DESC"
|
||||
},
|
||||
"example2": {
|
||||
"user": "按 topmost_pn 汇总 ADW 和 DOA 数量",
|
||||
"mode": "aggregate_mode",
|
||||
"sql": "SELECT topmost_pn, SUM(ADW) AS ADW, SUM(DOA) AS DOA, SUM(multipal_impact) AS multipal_impact FROM dwd_ai.apbo_eta_multiple_impact GROUP BY topmost_pn ORDER BY multipal_impact DESC, ADW DESC, DOA DESC"
|
||||
},
|
||||
"example3": {
|
||||
"user": "统计 ANZ 区域各 part number 的 qty",
|
||||
"mode": "aggregate_mode",
|
||||
"sql": "SELECT part_number, SUM(qty) AS qty FROM dwd_ai.apbo_eta_multiple_impact WHERE region = 'ANZ' GROUP BY part_number ORDER BY qty DESC"
|
||||
}
|
||||
},
|
||||
"topn_examples": {
|
||||
"example1": {
|
||||
"user": "按 topmost_pn 查询 top 10 multiple impact",
|
||||
"mode": "topn_mode",
|
||||
"sql": "SELECT topmost_pn, SUM(multipal_impact) AS multipal_impact FROM dwd_ai.apbo_eta_multiple_impact GROUP BY topmost_pn ORDER BY multipal_impact DESC LIMIT 10"
|
||||
},
|
||||
"example2": {
|
||||
"user": "by region top 5 qty",
|
||||
"mode": "topn_mode",
|
||||
"sql": "SELECT region, SUM(qty) AS qty FROM dwd_ai.apbo_eta_multiple_impact GROUP BY region ORDER BY qty DESC LIMIT 5"
|
||||
}
|
||||
},
|
||||
"edge_cases": {
|
||||
"example1": {
|
||||
"user": "有多少个 region 有 OOW 影响",
|
||||
"mode": "aggregate_mode",
|
||||
"sql": "SELECT region, SUM(OOW) AS OOW FROM dwd_ai.apbo_eta_multiple_impact WHERE OOW > 0 GROUP BY region ORDER BY OOW DESC"
|
||||
},
|
||||
"example2": {
|
||||
"user": "查看所有 warranty 字段的记录详情",
|
||||
"mode": "detail_mode",
|
||||
"sql": "SELECT topmost_pn, part_number, region, ADW, CLW, DOA, FOC, MDOA, OBL, OOW, OPT, qty, multipal_impact FROM dwd_ai.apbo_eta_multiple_impact ORDER BY multipal_impact DESC, qty DESC, topmost_pn, part_number, region"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
{
|
||||
"meta": {
|
||||
"domain": "亚太区物料库存与用量分析",
|
||||
"keywords": ["库存", "用量", "物料分析", "亚太区", "国家用量", "历史使用量", "近期用量", "premier", "qty", "数量"],
|
||||
"description": "此模型用于分析亚太地区各物料在不同区域、配送中心的国家用量统计。国家字段(AU, VN, JP等)是数值型用量字段,表示该物料在该国家的历史用量,不是国家代码。",
|
||||
"data_source": "dwd_ai.apbo_eta_region_report"
|
||||
},
|
||||
"data_model_specification": {
|
||||
"fields_list": [
|
||||
"topmost_pn", "region", "commodity_code", "dc_plant", "premier", "qty",
|
||||
"AU", "NZ", "LK", "VN", "JP", "HK", "SG", "TH", "PH", "IN", "BN", "NP", "BD", "KR", "ID", "FJ", "MY", "TW",
|
||||
"etl_time"
|
||||
],
|
||||
|
||||
"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", "premier", "qty",
|
||||
"AU", "NZ", "LK", "VN", "JP", "HK", "SG", "TH", "PH", "IN", "BN", "NP", "BD", "KR", "ID", "FJ", "MY", "TW",
|
||||
"etl_time"
|
||||
]
|
||||
}
|
||||
},
|
||||
"business_logic_rules": {
|
||||
"query_recognition_rules": {
|
||||
"material_keywords": ["物料", "topmost_pn", "物料号", "零件号", "Part Number", "PN", "topmost"],
|
||||
"region_keywords": ["region", "区域", "大区", "地区", "Region Code", "CAP", "ANZ", "JP"],
|
||||
"commodity_keywords": ["commodity_code", "商品代码", "编码", "物料分类", "Commodity Code", "CC"],
|
||||
"premier_keywords": ["premier", "优质", "优先", "Premier服务"],
|
||||
"qty_keywords": ["qty", "数量", "总量", "计数", "count"]
|
||||
},
|
||||
|
||||
"default_filters": {
|
||||
"rule": "默认不添加任何WHERE条件,除非用户明确要求",
|
||||
"examples": [
|
||||
"不要添加WHERE region = 'CAP'(除非用户明确要求)",
|
||||
"不要添加WHERE qty > 0(除非用户明确要求)"
|
||||
]
|
||||
},
|
||||
|
||||
"country_field_handling": {
|
||||
"important_note": "国家字段(AU, VN, JP等)是数值型BIGINT,表示该物料在该国家的使用量计数",
|
||||
"critical_warning": "绝对不要将这些字段作为字符串处理,不要使用单引号,不要使用LIKE操作符",
|
||||
"correct_usage": {
|
||||
"pattern": "国家用量大于{值} → {国家字段} > {value}",
|
||||
"examples": [
|
||||
"VN用量超过100 → VN > 100",
|
||||
"有澳大利亚用量 → AU > 0",
|
||||
"没有日本用量 → JP = 0"
|
||||
]
|
||||
},
|
||||
"incorrect_usage": {
|
||||
"pattern": "错误用法示例",
|
||||
"examples": [
|
||||
"WHERE VN = 'VN' (错误:VN是数值,不是字符串)",
|
||||
"WHERE JP LIKE '%JP%' (错误:JP是数值,不支持LIKE)",
|
||||
"WHERE AU IN ('AU', 'NZ') (错误:AU是数值,不是枚举)"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"sorting": {
|
||||
"default": "ORDER BY qty DESC",
|
||||
"alternatives": {
|
||||
"by_premier": "ORDER BY premier DESC",
|
||||
"by_country_usage": "ORDER BY {country_field} DESC (如 ORDER BY VN DESC)"
|
||||
}
|
||||
},
|
||||
|
||||
"limit_rule": {
|
||||
"rule": "禁止使用LIMIT",
|
||||
"exception": "除非用户明确要求Top N"
|
||||
}
|
||||
},
|
||||
"field_mapping_reference": {
|
||||
"critical_note": "此表包含亚太地区各物料的国家用量统计数据。国家字段(AU, VN, JP等)是数值型BIGINT,表示使用量计数,不是国家代码。",
|
||||
|
||||
"material_identifier_fields": {
|
||||
"topmost_pn": {
|
||||
"type": "string",
|
||||
"desc": "顶级物料号,物料的唯一标识",
|
||||
"example": "5CB1L57599",
|
||||
"alias": ["物料号", "零件号", "Part Number", "PN", "topmost", "物料编码"]
|
||||
},
|
||||
"commodity_code": {
|
||||
"type": "string",
|
||||
"desc": "商品代码,物料分类标识",
|
||||
"example": "LF",
|
||||
"alias": ["商品编码", "物料分类", "Commodity Code", "CC", "编码", "商品类别"]
|
||||
}
|
||||
},
|
||||
|
||||
"geographic_dimension_fields": {
|
||||
"region": {
|
||||
"type": "string",
|
||||
"desc": "区域划分:CAP(亚太区)、ANZ(澳新)、JP(日本)",
|
||||
"example": "CAP",
|
||||
"values": ["CAP", "ANZ", "JP"],
|
||||
"alias": ["区域", "大区", "Region", "地区", "地理区域"]
|
||||
},
|
||||
"dc_plant": {
|
||||
"type": "string",
|
||||
"desc": "配送中心/工厂代码",
|
||||
"example": "HKGDC",
|
||||
"alias": ["工厂", "配送中心", "plant", "DC", "发货中心", "Distribution Center"]
|
||||
}
|
||||
},
|
||||
|
||||
"metrics_fields": {
|
||||
"premier": {
|
||||
"type": "bigint",
|
||||
"desc": "Premier服务的订单数量",
|
||||
"alias": ["优质服务", "优先服务", "Premier数量", "Premier订单"]
|
||||
},
|
||||
"qty": {
|
||||
"type": "bigint",
|
||||
"desc": "总数量/总计数",
|
||||
"alias": ["数量", "总量", "计数", "count", "总数"]
|
||||
}
|
||||
},
|
||||
|
||||
"country_usage_fields": {
|
||||
"important_note": "以下所有字段都是数值型(BIGINT),表示该物料在该国家的历史使用量计数,不是国家代码。这些字段支持数值比较操作(>, <, >=, <=, =, !=)。",
|
||||
"critical_warning": "绝对不要将这些字段作为字符串处理,不要使用单引号,不要使用LIKE操作符。",
|
||||
|
||||
"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用量"]
|
||||
}
|
||||
},
|
||||
|
||||
"system_field": {
|
||||
"etl_time": {
|
||||
"type": "timestamp",
|
||||
"desc": "ETL更新时间",
|
||||
"alias": ["更新时间", "ETL时间", "数据更新时间"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"query_examples": {
|
||||
"simple_query": {
|
||||
"user": "region为CAP的物料",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_eta_region_report WHERE region = 'CAP' ORDER BY qty DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。WHERE条件包含region过滤。"
|
||||
},
|
||||
"country_usage_query": {
|
||||
"user": "VN用量超过100的物料",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_eta_region_report WHERE VN > 100 ORDER BY qty DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。WHERE条件包含VN数值过滤。"
|
||||
},
|
||||
"premier_query": {
|
||||
"user": "有Premier服务的物料",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_eta_region_report WHERE premier > 0 ORDER BY premier DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。WHERE条件包含premier数值过滤。"
|
||||
},
|
||||
"multi_country_query": {
|
||||
"user": "有VN和AU用量的物料",
|
||||
"sql": "SELECT topmost_pn, VN, AU FROM dwd_ai.apbo_eta_region_report WHERE VN > 0 AND AU > 0 ORDER BY qty DESC",
|
||||
"field_selection_reason": "用户指定了topmost_pn、VN、AU字段,只查询这些字段。WHERE条件包含VN和AU数值过滤。"
|
||||
},
|
||||
"zero_usage_query": {
|
||||
"user": "没有VN用量的物料",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_eta_region_report WHERE VN = 0 ORDER BY qty DESC",
|
||||
"field_selection_reason": "用户明确要求'没有VN用量的',所以添加VN = 0条件。默认查询所有字段。"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"meta": {
|
||||
"domain": "亚太区物料用量与库存(按国家)分析",
|
||||
"keywords": ["库存", "用量", "物料分析", "亚太区", "国家", "IB", "库存数量", "usage", "ship_to_country"],
|
||||
"description": "此模型用于分析亚太地区各物料在不同区域、配送中心及目的地国家的库存与用量信息。表已在SQL层完成聚合与关联,包含国家维度(ship_to_country)及分组用量/库存字段。",
|
||||
"data_source": "dwd_ai.apbo_eta_usage_ib_report"
|
||||
},
|
||||
"data_model_specification": {
|
||||
"fields_list": [
|
||||
"topmost_pn", "region", "commodity_code", "dc_plant", "ship_to_country",
|
||||
"location_name", "usage_qty_8_week_by_group", "usage_qty_52_week_by_group",
|
||||
"total_history_usage_by_group", "group_current_ib"
|
||||
],
|
||||
"mandatory_display_fields": {
|
||||
"required_fields": "topmost_pn, region, commodity_code, dc_plant, ship_to_country, location_name",
|
||||
"rule1": "默认查询所有字段(SELECT *)",
|
||||
"rule2": "当用户明确指定某些字段时,只查询这些字段,但必须始终包含required_fields,并保持用户提到的顺序",
|
||||
"rule3": "WHERE条件中使用的所有字段,必须在SELECT子句中展示",
|
||||
"rule4": "select的所有字段必须用``包裹,避免关键字冲突"
|
||||
}
|
||||
},
|
||||
"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_keywords": ["country", "国家", "ship_to_country", "收货国", "目的地国家"]
|
||||
},
|
||||
"field_selection_logic": {
|
||||
"priority_order": [
|
||||
{
|
||||
"level": 1,
|
||||
"name": "用户明确指定的字段",
|
||||
"rule": "精确添加用户提到的字段,按用户问题中出现的顺序排列;无论用户是否提及,都必须包含required_fields"
|
||||
},
|
||||
{
|
||||
"level": 2,
|
||||
"name": "默认字段选择",
|
||||
"rule": "如果用户没有明确指定字段,默认查询所有字段(SELECT *)"
|
||||
}
|
||||
],
|
||||
"where_condition_fields_must_in_select": {
|
||||
"rule": "WHERE条件中使用的所有字段必须在SELECT子句中展示",
|
||||
"purpose": "确保查询结果的完整性,用户能看到过滤依据"
|
||||
}
|
||||
},
|
||||
"where_condition_generation": {
|
||||
"strict_rule": "只生成用户明确要求的过滤条件,不添加任何默认或假设的条件",
|
||||
"condition_types": {
|
||||
"exact_match": {
|
||||
"pattern": "{字段}为{值}",
|
||||
"sql": "{field} = '{value}'"
|
||||
},
|
||||
"range_filter": {
|
||||
"pattern": ["大于{值}", "超过{值}", "少于{值}", "小于{值}", "不低于{值}", "不超过{值}"],
|
||||
"sql_mapping": {
|
||||
"大于{值}": "{field} > {value}",
|
||||
"超过{值}": "{field} >= {value}",
|
||||
"少于{值}": "{field} < {value}",
|
||||
"小于{值}": "{field} < {value}",
|
||||
"不低于{值}": "{field} >= {value}",
|
||||
"不超过{值}": "{field} <= {value}"
|
||||
}
|
||||
},
|
||||
"multiple_conditions": {
|
||||
"pattern": ["且", "并且", "和", "同时", ","],
|
||||
"sql": "AND"
|
||||
}
|
||||
},
|
||||
"no_default_conditions": {
|
||||
"rule": "绝对不添加任何用户没有明确要求的WHERE条件"
|
||||
}
|
||||
},
|
||||
"default_behavior": {
|
||||
"sorting": "默认按group_current_ib(库存数量)降序排列:ORDER BY group_current_ib DESC",
|
||||
"limit": "禁止使用limit",
|
||||
"select_all": "默认查询所有字段:SELECT *",
|
||||
"field_order": "required_fields始终置前,其次按用户提到的顺序排列字段"
|
||||
}
|
||||
},
|
||||
"field_mapping_reference": {
|
||||
"critical_note": "此表为按国家维度的用量与库存报表,ship_to_country为国家代码维度字段,不是数值字段。用量与库存字段为数值型,支持比较运算。",
|
||||
"dimension_fields": {
|
||||
"topmost_pn": {
|
||||
"type": "string",
|
||||
"desc": "顶级物料号,物料唯一标识",
|
||||
"alias": ["物料号", "零件号", "Part Number", "PN", "topmost"]
|
||||
},
|
||||
"region": {
|
||||
"type": "string",
|
||||
"desc": "区域划分",
|
||||
"alias": ["区域", "大区", "Region", "地区"]
|
||||
},
|
||||
"commodity_code": {
|
||||
"type": "string",
|
||||
"desc": "商品代码",
|
||||
"alias": ["商品编码", "物料分类", "Commodity Code", "CC"]
|
||||
},
|
||||
"dc_plant": {
|
||||
"type": "string",
|
||||
"desc": "配送中心/工厂代码",
|
||||
"alias": ["工厂", "配送中心", "plant", "DC"]
|
||||
},
|
||||
"ship_to_country": {
|
||||
"type": "string",
|
||||
"desc": "目的地国家代码",
|
||||
"alias": ["country", "国家", "收货国", "目的地国家"]
|
||||
},
|
||||
"location_name": {
|
||||
"type": "string",
|
||||
"desc": "地点名称",
|
||||
"alias": ["地点名称", "location", "地点"]
|
||||
}
|
||||
},
|
||||
"metric_fields": {
|
||||
"usage_qty_8_week_by_group": {
|
||||
"type": "bigint",
|
||||
"desc": "近8周用量"
|
||||
},
|
||||
"usage_qty_52_week_by_group": {
|
||||
"type": "bigint",
|
||||
"desc": "近52周用量"
|
||||
},
|
||||
"total_history_usage_by_group": {
|
||||
"type": "bigint",
|
||||
"desc": "历史总用量"
|
||||
},
|
||||
"group_current_ib": {
|
||||
"type": "bigint",
|
||||
"desc": "当前库存数量"
|
||||
}
|
||||
},
|
||||
"time_fields": {}
|
||||
},
|
||||
"examples": {
|
||||
"simple_query_all_fields": {
|
||||
"user": "region为CAP的数据",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_eta_usage_ib_report WHERE region = 'CAP' ORDER BY group_current_ib DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段。"
|
||||
},
|
||||
"query_by_country": {
|
||||
"user": "country为VN的用量和库存",
|
||||
"sql": "SELECT `ship_to_country`, `usage_qty_8_week_by_group`, `usage_qty_52_week_by_group`, `total_history_usage_by_group`, `group_current_ib` FROM dwd_ai.apbo_eta_usage_ib_report WHERE ship_to_country = 'VN' ORDER BY group_current_ib DESC",
|
||||
"field_selection_reason": "用户指定国家维度与用量/库存字段,按用户顺序输出"
|
||||
},
|
||||
"query_specific_fields": {
|
||||
"user": "查看物料号、库存和近8周用量",
|
||||
"sql": "SELECT `topmost_pn`, `group_current_ib`, `usage_qty_8_week_by_group` FROM dwd_ai.apbo_eta_usage_ib_report ORDER BY group_current_ib DESC",
|
||||
"field_selection_reason": "用户明确指定字段,仅输出这些字段"
|
||||
},
|
||||
"query_usage_and_ib_with_required_fields": {
|
||||
"user": "查看usage和ib",
|
||||
"sql": "SELECT `topmost_pn`, `region`, `commodity_code`, `dc_plant`, `ship_to_country`, `location_name`, `usage_qty_8_week_by_group`, `usage_qty_52_week_by_group`, `total_history_usage_by_group`, `group_current_ib` FROM dwd_ai.apbo_eta_usage_ib_report ORDER BY group_current_ib DESC",
|
||||
"field_selection_reason": "用户仅提到usage和ib,但必须始终包含required_fields"
|
||||
},
|
||||
"query_with_multiple_conditions": {
|
||||
"user": "region为CAP且commodity_code为LF,库存大于500",
|
||||
"sql": "SELECT * FROM dwd_ai.apbo_eta_usage_ib_report WHERE region = 'CAP' AND commodity_code = 'LF' AND group_current_ib > 500 ORDER BY group_current_ib DESC",
|
||||
"field_selection_reason": "用户没有指定字段,默认查询所有字段,包含多条件过滤"
|
||||
},
|
||||
"query_with_etl_time": {
|
||||
"user": "查看CAP库存",
|
||||
"sql": "SELECT `region`, `group_current_ib` FROM dwd_ai.apbo_eta_usage_ib_report WHERE region = 'CAP' ORDER BY group_current_ib DESC",
|
||||
"field_selection_reason": "不展示系统时间字段,仅展示业务字段"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,431 +0,0 @@
|
||||
{
|
||||
"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条件。"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
{
|
||||
"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,4 +0,0 @@
|
||||
本目录存放用于 RAGFlow 匹配的表名检索提示词(JSON)。
|
||||
|
||||
约定:使用单一 JSON 文件维护多个表名及其模板列表。
|
||||
示例文件:tables.json。
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"apbo_eta_ful": [
|
||||
"backlog order",
|
||||
"SO ETA INFO",
|
||||
"BO list",
|
||||
"CC",
|
||||
@@ -17,9 +18,14 @@
|
||||
"recovery ETA",
|
||||
"history order",
|
||||
"Warranty type",
|
||||
"category"
|
||||
"category",
|
||||
"eta",
|
||||
"eta信息",
|
||||
"passdue",
|
||||
"逾期"
|
||||
],
|
||||
"apbo_milestone_info": [
|
||||
"apbo_eta_milestone": [
|
||||
"soid milestone",
|
||||
"GR or POD",
|
||||
"POD",
|
||||
"GR",
|
||||
@@ -30,17 +36,23 @@
|
||||
"里程碑",
|
||||
"节点明细"
|
||||
],
|
||||
"apbo_hic_ssoc_consumption": [
|
||||
"consumption消耗记录",
|
||||
"consumption order"
|
||||
],
|
||||
"apbo_tp_multiple_impact": [
|
||||
"multiple impact orders",
|
||||
"apbo_eta_multiple_impact": [
|
||||
"multiple impact",
|
||||
"不达标的multiple impact",
|
||||
"multiple impact status"
|
||||
],
|
||||
"apbo_region_usage_ib_report": [
|
||||
"ib",
|
||||
"usage"
|
||||
"apbo_eta_region_report": [
|
||||
"region report",
|
||||
"regional report"
|
||||
],
|
||||
"apbo_eta_usage_ib_report":[
|
||||
|
||||
],
|
||||
"apbo_hic_ssoc_consumption": [
|
||||
"consumption消耗记录",
|
||||
"consumption order",
|
||||
"consumption record",
|
||||
"SSOC consumption",
|
||||
"consumption"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user