liujie
2026-07-23 699569e4071becd30c8b15525da7f99a9544d780
监控
1个文件已修改
44 ■■■■■ 已修改文件
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EzvizOpenApiUtils.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/EzvizOpenApiUtils.java
@@ -111,10 +111,26 @@
        requireText(action, "action");
        requireText(command, "command");
        Integer[] directions = resolvePtzDirections(command);
        if (directions.length > 1) {
            JSONObject result = null;
            for (Integer direction : directions) {
                result = ptzControlByDirection(deviceSerial, channelNo, action, direction, speed);
                if (!SUCCESS_CODE.equals(result.getString("code"))) {
                    return result;
                }
            }
            return result;
        }
        return ptzControlByDirection(deviceSerial, channelNo, action, directions[0], speed);
    }
    private JSONObject ptzControlByDirection(String deviceSerial, Integer channelNo, String action, Integer direction, Integer speed) {
        Map<String, Object> form = new LinkedHashMap<>();
        form.put("deviceSerial", deviceSerial);
        form.put("channelNo", channelNo == null ? 1 : channelNo);
        form.put("direction", resolvePtzDirection(command));
        form.put("direction", direction);
        if ("start".equalsIgnoreCase(action)) {
            form.put("speed", normalizePtzSpeed(speed));
            return postFormWithToken("/api/lapp/device/ptz/start", form);
@@ -125,32 +141,32 @@
        throw new IllegalArgumentException("action仅支持start/stop");
    }
    private Integer resolvePtzDirection(String command) {
    private Integer[] resolvePtzDirections(String command) {
        switch (command) {
            case "up":
                return 0;
                return new Integer[]{0};
            case "down":
                return 1;
                return new Integer[]{1};
            case "left":
                return 2;
                return new Integer[]{2};
            case "right":
                return 3;
                return new Integer[]{3};
            case "upleft":
                return 4;
                return new Integer[]{0, 2};
            case "downleft":
                return 5;
                return new Integer[]{1, 2};
            case "upright":
                return 6;
                return new Integer[]{0, 3};
            case "downright":
                return 7;
                return new Integer[]{1, 3};
            case "zoomin":
                return 8;
                return new Integer[]{8};
            case "zoomout":
                return 9;
                return new Integer[]{9};
            case "focusin":
                return 10;
                return new Integer[]{10};
            case "focusout":
                return 11;
                return new Integer[]{11};
            default:
                throw new IllegalArgumentException("不支持的云台控制命令:" + command);
        }