添加了固定的输出Schema定义,包含code、message和data字段, 用于规范MCP工具的返回格式,提高API响应的一致性。 - 定义了标准的输出Schema结构 - 包含响应状态码、消息和数据字段 - code和message为必需字段
35 lines
5.1 KiB
JSON
35 lines
5.1 KiB
JSON
[
|
||
{
|
||
"id": "2006300000000000000",
|
||
"businessName": "查询列表",
|
||
"businessDescription": "查询所有工单列表,返回fact_work_order表的全部数据",
|
||
"datasourceId": "19",
|
||
"sqlTemplate": "SELECT * FROM fact_work_order",
|
||
"parameters": {}
|
||
},
|
||
{
|
||
"id": "2006300000000000004",
|
||
"businessName": "工单详情",
|
||
"businessDescription": "根据工单编号查询工单详情,包括工单基本信息、产品信息、委外供应商、工艺路线等",
|
||
"datasourceId": "19",
|
||
"sqlTemplate": "SELECT wo.work_order_id, wo.work_order_number AS 工单编号, wo.status AS 工单状态, wo.planned_qty AS 计划数量, wo.completed_qty AS 完成数量, wo.operation_good_qty AS 工序良品数, wo.operation_bad_qty AS 工序不良品数, wo.qc_good_qty AS 质检良品数, wo.qc_bad_qty AS 质检不良品数, wo.source_doc_number AS 来源单据编号, wo.event_time_utc AS 事件时间, p.product_code AS 产品编码, p.product_name AS 产品名称, p.product_spec AS 产品规格, s.supplier_name AS 委外供应商, r.routing_name AS 工艺路线 FROM fact_work_order wo LEFT JOIN dim_product p ON wo.product_id = p.product_id AND p.is_current = true LEFT JOIN dim_supplier s ON wo.supplier_id = s.supplier_id AND s.is_current = true LEFT JOIN dim_routing r ON wo.routing_id = r.routing_id AND r.is_current = true WHERE wo.work_order_number = '{workOrderNumber}'",
|
||
"parameters": {
|
||
"workOrderNumber": {
|
||
"type": "string",
|
||
"description": "工单编号",
|
||
"required": true,
|
||
"examples": [
|
||
"WO1311343859"
|
||
]
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"id": "2006300000000000005",
|
||
"businessName": "工单执行进度与异常节点看板",
|
||
"businessDescription": "工单执行进度与异常节点看板,展示工单完工进度、工序良率、质检良率、异常标识等关键监控指标",
|
||
"datasourceId": "19",
|
||
"sqlTemplate": "WITH work_order_progress AS (SELECT wo.work_order_number, wo.status AS work_order_status, wo.planned_qty, wo.completed_qty, wo.operation_good_qty, wo.operation_bad_qty, wo.qc_good_qty, wo.qc_bad_qty, wo.source_doc_number AS sales_order_number, wo.event_time_utc, p.product_code, p.product_name, CASE WHEN wo.planned_qty > 0 THEN ROUND(wo.completed_qty * 100.0 / wo.planned_qty, 2) ELSE 0 END AS completion_pct, CASE WHEN (wo.operation_good_qty + wo.operation_bad_qty) > 0 THEN ROUND(wo.operation_good_qty * 100.0 / (wo.operation_good_qty + wo.operation_bad_qty), 2) ELSE NULL END AS operation_yield_pct, CASE WHEN (wo.qc_good_qty + wo.qc_bad_qty) > 0 THEN ROUND(wo.qc_good_qty * 100.0 / (wo.qc_good_qty + wo.qc_bad_qty), 2) ELSE NULL END AS qc_yield_pct FROM fact_work_order wo LEFT JOIN dim_product p ON wo.product_id = p.product_id AND p.is_current = true), task_summary AS (SELECT work_order_number, COUNT(*) AS total_tasks, SUM(CASE WHEN actual_end_time_utc IS NOT NULL THEN 1 ELSE 0 END) AS completed_tasks, SUM(CASE WHEN actual_start_time_utc IS NOT NULL AND actual_end_time_utc IS NULL THEN 1 ELSE 0 END) AS in_progress_tasks, SUM(CASE WHEN actual_start_time_utc IS NULL THEN 1 ELSE 0 END) AS pending_tasks, SUM(bad_qty) AS total_bad_qty FROM fact_operation_task GROUP BY work_order_number), labor_summary AS (SELECT work_order_number, SUM(report_qty) AS total_report_qty, SUM(good_qty) AS total_good_qty, SUM(bad_qty) AS total_bad_qty, SUM(duration_minutes) AS total_work_minutes FROM fact_labor_report GROUP BY work_order_number), qc_summary AS (SELECT work_order_number, COUNT(*) AS qc_record_count, SUM(pass_qty) AS total_pass_qty, SUM(fail_qty) AS total_fail_qty FROM fact_quality_inspection WHERE work_order_number IS NOT NULL GROUP BY work_order_number) SELECT wp.work_order_number AS 工单编号, wp.product_code AS 产品编码, wp.product_name AS 产品名称, wp.sales_order_number AS 关联销售订单, wp.work_order_status AS 工单状态, wp.planned_qty AS 计划数量, wp.completed_qty AS 完成数量, wp.completion_pct AS 完工进度百分比, COALESCE(ts.total_tasks, 0) AS 工序总数, COALESCE(ts.completed_tasks, 0) AS 已完成工序, COALESCE(ts.in_progress_tasks, 0) AS 进行中工序, COALESCE(ts.pending_tasks, 0) AS 待开始工序, COALESCE(ls.total_report_qty, 0) AS 累计报工数, COALESCE(ls.total_work_minutes, 0) AS 累计工时_分钟, wp.operation_yield_pct AS 工序良率, wp.qc_yield_pct AS 质检良率, COALESCE(qc.total_pass_qty, 0) AS 质检通过数, COALESCE(qc.total_fail_qty, 0) AS 质检不通过数, CASE WHEN wp.completion_pct < 50 AND wp.work_order_status = 'STARTED' THEN '进度滞后' WHEN wp.operation_yield_pct < 90 THEN '工序良率异常' WHEN wp.qc_yield_pct < 95 THEN '质检良率异常' WHEN ts.total_bad_qty > 0 THEN '存在不良品' ELSE '正常' END AS 异常标识, wp.event_time_utc AS 最后更新时间 FROM work_order_progress wp LEFT JOIN task_summary ts ON wp.work_order_number = ts.work_order_number LEFT JOIN labor_summary ls ON wp.work_order_number = ls.work_order_number LEFT JOIN qc_summary qc ON wp.work_order_number = qc.work_order_number ORDER BY CASE wp.work_order_status WHEN 'STARTED' THEN 1 WHEN 'RELEASED' THEN 2 WHEN 'PLANNED' THEN 3 ELSE 4 END, wp.event_time_utc DESC",
|
||
"parameters": {}
|
||
}
|
||
] |