|
|
@@ -534,7 +534,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
// midjourneyAccountService.updateStatus(account.getId());
|
|
|
// });
|
|
|
if(RETRY_ACTION.contains(action)){
|
|
|
- return submit(user,mode, action, instanceId, param,true, num);
|
|
|
+ return retryAction(user, mode, action, instanceId, param, submitResult, num);
|
|
|
}
|
|
|
}
|
|
|
if (code == 4) {
|
|
|
@@ -551,6 +551,27 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 无可用账号重试
|
|
|
+ */
|
|
|
+ private SubmitResult retryAction(MidjourneyUser user, Integer mode, String action, Long instanceId, Map<String, Object> param, SubmitResult submitResult, Long num) throws Exception {
|
|
|
+ String key = RedisService.key.MIDJOURNEY_USER_AGAIN.getName() + user.getId();
|
|
|
+ long aginaCount;
|
|
|
+ String str = redisService.getStr(key);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(str)) {
|
|
|
+ redisService.set(key, 1L, RedisService.key.MIDJOURNEY_USER_AGAIN.getTimeout());
|
|
|
+ aginaCount = 1L;
|
|
|
+ } else {
|
|
|
+ aginaCount = redisService.incr(key, 1L);
|
|
|
+ }
|
|
|
+ if (aginaCount > 5) {
|
|
|
+ log.error("超过5次重试,action:" + action + " error message:" + submitResult.getDescription());
|
|
|
+ throw BusinessRuntimeException.getInstance("网络出现异常");
|
|
|
+ }
|
|
|
+ return submit(user, mode, action, instanceId, param, true, num);
|
|
|
+ }
|
|
|
+
|
|
|
private SubmitResult submit2MjProxy(Integer mode, String action, Map<String, Object> param) throws Exception {
|
|
|
String host = midjourneyHost;
|
|
|
if (EnvCommonService.active_prd.equals(envCommonService.getEnv())){
|