diff --git a/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java b/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java index 5bc6009..3d37894 100644 --- a/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java +++ b/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java @@ -351,14 +351,17 @@ public class IvsDeviceController { return ResponseEntity.ok().body(new InputStreamResource(ivsResourceRetryableDelegate.generateErrorImage())); } + // 上面刚刚向摄像机发送了拍照指令, 需要给摄像机留出拍照时间 delayBeforeGetPicture(); IvsPlatformSnapshotView snapShotView; try { - snapShotView = ivsResourceRetryableDelegate.getSnapshotListRetryable( - new IvsChanSnapVo(ivsDevChanSnapVo.getCameraCode(), - ivsDevChanSnapVo.getDomainCode(), - ivsSnapshotView.getTaskID())); + IvsChanSnapVo ivsChanSnapVo = new IvsChanSnapVo(); + ivsChanSnapVo.setUUID(uuid); + ivsChanSnapVo.setCameraCode(ivsDevChanSnapVo.getCameraCode()); + ivsChanSnapVo.setDomainCode(ivsDevChanSnapVo.getDomainCode()); + ivsChanSnapVo.setTaskID(ivsSnapshotView.getTaskID()); + snapShotView = ivsResourceRetryableDelegate.getSnapshotListRetryable(ivsChanSnapVo); } catch (IOException e) { log.info("snapShotView {}", e.getMessage() + " final fail"); return ResponseEntity.ok().body(new InputStreamResource(ivsResourceRetryableDelegate.generateErrorImage())); diff --git a/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsResourceRetryableDelegate.java b/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsResourceRetryableDelegate.java index f2a7bba..b451652 100644 --- a/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsResourceRetryableDelegate.java +++ b/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsResourceRetryableDelegate.java @@ -35,7 +35,9 @@ import java.util.UUID; public class IvsResourceRetryableDelegate { private static final Logger log = LoggerFactory.getLogger(IvsResourceRetryableDelegate.class); - private static final int RETRYABLE_MAX = 10; + private static final int RETRYABLE_MIN = 10; + + private static final int RETRYABLE_MAX = 20; @Resource private IvsCommonService ivsCommonService; @@ -55,7 +57,7 @@ public class IvsResourceRetryableDelegate { log.info("URI_PLATFORM_SNAPSHOT SUCCESS retryCount: {}, UUID: {}", retryCount, ivsDevChanSnapVo.getUUID()); } catch (Exception e) { log.info("URI_PLATFORM_SNAPSHOT FAIL retryCount: {}, UUID: {}", retryCount, ivsDevChanSnapVo.getUUID()); - throw new IOException("URI_PLATFORM_SNAPSHOT FAIL UUID: " + ivsDevChanSnapVo.getUUID()); + throw new IOException("URI_PLATFORM_SNAPSHOT FAIL UUID: " + ivsDevChanSnapVo.getUUID() + ", retryCount: " + retryCount); } return ivsSnapshotView; @@ -70,7 +72,7 @@ public class IvsResourceRetryableDelegate { @Retryable( value = IOException.class, - maxAttempts = RETRYABLE_MAX, + maxAttempts = RETRYABLE_MIN, backoff = @Backoff(delay = 2000)) // 每次重试间隔 2 秒 public IvsPlatformSnapshotView getSnapshotListRetryable(final IvsChanSnapVo ivsChanSnapVo) throws IOException { int retryCount = RetrySynchronizationManager.getContext() != null @@ -98,7 +100,7 @@ public class IvsResourceRetryableDelegate { @Retryable( value = IOException.class, - maxAttempts = RETRYABLE_MAX, + maxAttempts = RETRYABLE_MIN, backoff = @Backoff(delay = 2000)) // 每次重试间隔 2 秒 public ResponseEntity downloadPictureRetryable(String uuid, String pictureUrl) throws IOException { int retryCount = RetrySynchronizationManager.getContext() != null