1
6 小时以前 e711c834aec2293c53b07efe53e81e3573c289b6
rsf-server/src/main/java/com/vincent/rsf/server/ai/tool/RsfWmsStockTools.java
@@ -27,6 +27,10 @@
    private final LocItemService locItemService;
    private final DeviceSiteService deviceSiteService;
    /**
     * 查询当前可用于出库的库存明细。
     * 该工具只允许按物料编码或物料名称做定向查询,不允许无条件扫描库存表。
     */
    @Tool(name = "rsf_query_available_inventory", description = "只读查询工具。根据物料编码或物料名称查询当前在库且可用于出库的库存明细。")
    public List<Map<String, Object>> queryAvailableInventory(
            @ToolParam(description = "物料编码,优先使用") String matnr,
@@ -72,33 +76,37 @@
        return result;
    }
    /**
     * 查询指定作业类型可用的设备站点。
     * 返回的是模型更容易消费的扁平结构,而不是直接暴露完整实体对象。
     */
    @Tool(name = "rsf_query_station_list", description = "只读查询工具。根据作业类型列表查询可用站点,返回站点编号、名称、目标位置和状态等信息。")
    public List<Map<String, Object>> queryStationList(
            @ToolParam(required = true, description = "作业类型列表") List<String> types,
            @ToolParam(description = "返回条数,默认 20,最大 50") Integer limit) {
        List<String> normalizedTypes = BuiltinToolGovernanceSupport.sanitizeStringList(types, "站点类型列表", 10, 32);
        int finalLimit = BuiltinToolGovernanceSupport.normalizeLimit(limit, 20, 50);
        List<DeviceSite> sites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>()
                .in(DeviceSite::getType, normalizedTypes)
                .orderByAsc(DeviceSite::getType)
                .orderByAsc(DeviceSite::getSite)
                .last("LIMIT " + finalLimit));
//        int finalLimit = BuiltinToolGovernanceSupport.normalizeLimit(limit, 20, 50);
//        List<DeviceSite> sites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>()
//                .in(DeviceSite::getType, normalizedTypes)
//                .orderByAsc(DeviceSite::getType)
//                .orderByAsc(DeviceSite::getSite)
//                .last("LIMIT " + finalLimit));
        List<Map<String, Object>> result = new ArrayList<>();
        for (DeviceSite site : sites) {
            Map<String, Object> item = new LinkedHashMap<>();
            item.put("id", site.getId());
            item.put("type", site.getType());
            item.put("site", site.getSite());
            item.put("name", site.getName());
            item.put("target", site.getTarget());
            item.put("label", site.getLabel());
            item.put("device", site.getDevice());
            item.put("deviceCode", site.getDeviceCode());
            item.put("deviceSite", site.getDeviceSite());
            item.put("channel", site.getChannel());
            item.put("status", site.getStatus());
            result.add(item);
        }
//        for (DeviceSite site : sites) {
//            Map<String, Object> item = new LinkedHashMap<>();
//            item.put("id", site.getId());
//            item.put("type", site.getType());
//            item.put("site", site.getSite());
//            item.put("name", site.getName());
//            item.put("target", site.getTarget());
//            item.put("label", site.getLabel());
//            item.put("device", site.getDevice());
//            item.put("deviceCode", site.getDeviceCode());
//            item.put("deviceSite", site.getDeviceSite());
//            item.put("channel", site.getChannel());
//            item.put("status", site.getStatus());
//            result.add(item);
//        }
        return result;
    }
}