package com.zy.ai.mcp.tool; import com.alibaba.fastjson.JSONObject; import com.zy.ai.mcp.service.WcsDataFacade; import lombok.RequiredArgsConstructor; import org.springframework.ai.tool.annotation.Tool; import org.springframework.ai.tool.annotation.ToolParam; import org.springframework.stereotype.Component; import java.util.List; @Component @RequiredArgsConstructor public class WcsMcpTools { private final WcsDataFacade wcsDataFacade; @Tool(name = "device_get_crn_status", description = "通过堆垛机编号查询堆垛机设备实时数据") public Object getCrnDeviceStatus( @ToolParam(description = "堆垛机编号列表,不传则查询全部堆垛机", required = false) List crnNos) { return wcsDataFacade.getCrnDeviceStatus(json().fluentPut("crnNos", crnNos)); } @Tool(name = "device_get_station_status", description = "查询输送线站点设备实时数据") public Object getStationDeviceStatus() { return wcsDataFacade.getStationDeviceStatus(json()); } @Tool(name = "device_get_rgv_status", description = "通过RGV编号查询RGV设备实时数据") public Object getRgvDeviceStatus( @ToolParam(description = "RGV编号列表,不传则查询全部RGV", required = false) List rgvNos) { return wcsDataFacade.getRgvDeviceStatus(json().fluentPut("rgvNos", rgvNos)); } @Tool(name = "task_query", description = "按任务号、状态、设备、条码、库位等条件查询任务数据") public Object queryTasks( @ToolParam(description = "内部工作号列表 wrkNos", required = false) List wrkNos, @ToolParam(description = "WMS任务号列表 wmsWrkNos", required = false) List wmsWrkNos, @ToolParam(description = "任务状态列表 wrkStsList", required = false) List wrkStsList, @ToolParam(description = "入出库类型列表 ioTypeList", required = false) List ioTypeList, @ToolParam(description = "堆垛机编号", required = false) Integer crnNo, @ToolParam(description = "双工位堆垛机编号", required = false) Integer dualCrnNo, @ToolParam(description = "RGV编号", required = false) Integer rgvNo, @ToolParam(description = "条码关键字", required = false) String barcode, @ToolParam(description = "批次号关键字", required = false) String batch, @ToolParam(description = "源库位关键字", required = false) String sourceLocNo, @ToolParam(description = "目标库位关键字", required = false) String locNo, @ToolParam(description = "源站号", required = false) Integer sourceStaNo, @ToolParam(description = "目标站号", required = false) Integer staNo, @ToolParam(description = "返回条数上限,默认 200,最大 500", required = false) Integer limit) { return wcsDataFacade.getTasks(json() .fluentPut("wrkNos", wrkNos) .fluentPut("wmsWrkNos", wmsWrkNos) .fluentPut("wrkStsList", wrkStsList) .fluentPut("ioTypeList", ioTypeList) .fluentPut("crnNo", crnNo) .fluentPut("dualCrnNo", dualCrnNo) .fluentPut("rgvNo", rgvNo) .fluentPut("barcode", barcode) .fluentPut("batch", batch) .fluentPut("sourceLocNo", sourceLocNo) .fluentPut("locNo", locNo) .fluentPut("sourceStaNo", sourceStaNo) .fluentPut("staNo", staNo) .fluentPut("limit", limit)); } @Tool(name = "log_query", description = "通过筛选条件查询系统运行日志数据") public Object getLogs( @ToolParam(description = "返回日志行数上限,默认 500", required = false) Integer limit) { return wcsDataFacade.getLogs(json().fluentPut("limit", limit)); } @Tool(name = "config_get_device_config", description = "通过设备编号查询设备配置数据") public Object getDeviceConfig( @ToolParam(description = "堆垛机编号列表", required = false) List crnNos, @ToolParam(description = "RGV编号列表", required = false) List rgvNos, @ToolParam(description = "输送线编号列表", required = false) List devpNos) { return wcsDataFacade.getDeviceConfig(json() .fluentPut("crnNos", crnNos) .fluentPut("rgvNos", rgvNos) .fluentPut("devpNos", devpNos)); } @Tool(name = "config_get_system_config", description = "查询系统配置数据") public Object getSystemConfig() { return wcsDataFacade.getSystemConfig(json()); } private JSONObject json() { return new JSONObject(); } }