shenyijian
2023-12-19 ecdd1add809811170ecb6bbef8941bcac7c349f8
src/main/java/com/dji/sample/control/service/impl/ControlServiceImpl.java
@@ -100,6 +100,16 @@
            RedisOpsUtils.setWithExpire(serviceIdentifier + RedisConst.DELIMITER + bid, sn,
                    RedisConst.DEVICE_ALIVE_SECOND * RedisConst.DEVICE_ALIVE_SECOND);
        }
        //当执行返航指令时,删除图斑redis
        if (serviceIdentifier == "return_home"){
            if (RedisOpsUtils.checkExist("tuban:" + sn)){
                RedisOpsUtils.del("tuban:" + sn);
            }
        }
        return ResponseResult.success();
    }
@@ -205,27 +215,32 @@
                                eventsReceiver.getStatus().getMessage() : eventsReceiver.getResult().getErrorMsg())
                        .result(eventsReceiver.getResult().getErrorCode())
                        .build());
        //当飞向目标点成功后
        if (eventsReceiver.getStatus().equals(FlyToStatusEnum.WAYLINE_OK)) {
            JSONObject jsonObject = (JSONObject) RedisOpsUtils.get("tuban:" + dockSn);
            if (jsonObject != null) {
                List<PointPOJO> targetList = (List<PointPOJO>) jsonObject.get("targetList");
                int curIndex = (Integer) jsonObject.get("curIndex");
                String payloadIndex = jsonObject.getString("payloadIndex");
                flyToNextPoint(targetList, curIndex, dockSn, payloadIndex);
                flyToNextPoint(targetList, curIndex+1, dockSn, payloadIndex);
            }
        }
        return receiver;
    }
    private ResponseResult flyToNextPoint(List<PointPOJO> targetList, int curIndex, String sn, String payloadIndex) throws Exception {
        curIndex = curIndex + 1;
    @Override
    public ResponseResult flyToNextPoint(List<PointPOJO> targetList, int curIndex, String sn, String payloadIndex) throws Exception {
        //当无人机状态为人工时再发布下一个命令
        while (true) {
            Optional<DeviceDTO> dockOpt = deviceRedisService.getDeviceOnline(sn);
            DeviceModeCodeEnum deviceMode = deviceService.getDeviceMode(dockOpt.get().getChildDeviceSn());
            if (DeviceModeCodeEnum.MANUAL == deviceMode) {
                //执行拍照
                ResponseResult responseResult = takePhoto(sn, payloadIndex);
                //发布飞行指令
                if (curIndex == targetList.size()) {
                    //当前是最后一个点,返航
                    ResponseResult returnHome = controlDockDebug(sn, "return_home", null);
@@ -245,9 +260,6 @@
                    pointDTO.setLatitude(targetList.get(curIndex).getLat());
                    pointDTOS.add(pointDTO);
                    flyToPointParam.setPoints(pointDTOS);
                    //执行拍照
                    ResponseResult responseResult = takePhoto(sn, payloadIndex);
                    //发布下一个飞行指令
                    ResponseResult flyToRes = flyToPoint(sn, flyToPointParam);