|
|
@@ -68,12 +68,8 @@ import static com.yhlxj.web.wss.MidjourneyServerEndpoint.WSS_SESSION_MAP;
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
|
public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
- private static final String RELAX_HOST = "http://172.19.0.17:8080";
|
|
|
- private static final String FAST_HOST = "https://api.bltcy.ai";
|
|
|
- private static final String FAST_TOKEN = "Bearer sk-YTg6N3QH6PLTFLbM9291B1Ae12754bC4B26225F1B95f442c";
|
|
|
-
|
|
|
- private static final String RELAX_TOKEN = "5a9a3e9b-5a5e-4b6b-9a5a-9a5a5a5a5a5a";
|
|
|
-
|
|
|
+ private static final String RELAX_HOST = "http://172.17.0.1:8086";
|
|
|
+ private static final String RELAX_TOKEN = "chen188710";
|
|
|
private static final Map<Long, ImgSize> TASK_IMG_SIZE_MAP = new ConcurrentHashMap<>();
|
|
|
|
|
|
private final MidjourneyUserConversationMapper conversationMapper;
|
|
|
@@ -512,37 +508,38 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
public SubmitResult submit(MidjourneyUser user, Integer mode, String action, Long instanceId, Map<String, Object> param,Boolean again, Long num) throws Exception {
|
|
|
//查询在使用次数最少的账号
|
|
|
- String accountWithMinUsage = getAccountWithMinUsage(mode,instanceId);
|
|
|
- if (accountWithMinUsage == null) {
|
|
|
- throw new Exception("没有可用的账号");
|
|
|
- }
|
|
|
+// String accountWithMinUsage = getAccountWithMinUsage(mode,instanceId);
|
|
|
+// if (accountWithMinUsage == null) {
|
|
|
+// throw new Exception("没有可用的账号");
|
|
|
+// }
|
|
|
param.put("accountFilter",MapUtil.builder(new HashMap<String,Object>())
|
|
|
- .put("instanceId",accountWithMinUsage).build());
|
|
|
+ //.put("instanceId",accountWithMinUsage).build());
|
|
|
+ .put("modes",List.of(mode == 1 ? "FAST" : "RELAX")).build());
|
|
|
if (mode == 2) {
|
|
|
synchronized (user.getId()){
|
|
|
userSubmitLimit(user,action,param.get("customId"),again);
|
|
|
}
|
|
|
}
|
|
|
SubmitResult submitResult = submit2MjProxy(mode, action, param);
|
|
|
- submitResult.setInstanceId(Long.valueOf(accountWithMinUsage));
|
|
|
+ //submitResult.setInstanceId(Long.valueOf(accountWithMinUsage));
|
|
|
int code = submitResult.getCode();
|
|
|
if (code == 23){
|
|
|
recoverUserLimit(user.getId(), mode, num);
|
|
|
return submitResult;
|
|
|
}
|
|
|
if (code != 1 && code != 21 && code != 22) {
|
|
|
- submitResult = checkResult(user, mode, action, instanceId, param, code, accountWithMinUsage, submitResult, num);
|
|
|
+ submitResult = checkResult(user, mode, action, instanceId, param, code, submitResult, num);
|
|
|
}
|
|
|
return submitResult;
|
|
|
}
|
|
|
|
|
|
- private SubmitResult checkResult(MidjourneyUser user, Integer mode, String action, Long instanceId, Map<String, Object> param, int code, String accountWithMinUsage, SubmitResult submitResult, Long num) throws Exception {
|
|
|
+ private SubmitResult checkResult(MidjourneyUser user, Integer mode, String action, Long instanceId, Map<String, Object> param, int code, SubmitResult submitResult, Long num) throws Exception {
|
|
|
if (code == 3) {
|
|
|
- redisService.hdel(mode == 1 ? RedisService.key.MIDJOURNEY_FAST_ACCOUNT.getName() : RedisService.key.MIDJOURNEY_ACCOUNT.getName(), accountWithMinUsage);
|
|
|
- TASK_EXECUTOR.execute(() -> {
|
|
|
- MidjourneyAccount account = midjourneyAccountService.getOne(Wrappers.lambdaQuery(MidjourneyAccount.class).eq(MidjourneyAccount::getInstanceId, accountWithMinUsage).last("limit 1"));
|
|
|
- midjourneyAccountService.updateStatus(account.getId());
|
|
|
- });
|
|
|
+// redisService.hdel(mode == 1 ? RedisService.key.MIDJOURNEY_FAST_ACCOUNT.getName() : RedisService.key.MIDJOURNEY_ACCOUNT.getName(), accountWithMinUsage);
|
|
|
+// TASK_EXECUTOR.execute(() -> {
|
|
|
+// MidjourneyAccount account = midjourneyAccountService.getOne(Wrappers.lambdaQuery(MidjourneyAccount.class).eq(MidjourneyAccount::getInstanceId, accountWithMinUsage).last("limit 1"));
|
|
|
+// midjourneyAccountService.updateStatus(account.getId());
|
|
|
+// });
|
|
|
if(RETRY_ACTION.contains(action)){
|
|
|
return submit(user,mode, action, instanceId, param,true, num);
|
|
|
}
|
|
|
@@ -564,7 +561,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
private SubmitResult submit2MjProxy(Integer mode, String action, Map<String, Object> param) throws Exception {
|
|
|
String host = midjourneyHost;
|
|
|
if (EnvCommonService.active_prd.equals(envCommonService.getEnv())){
|
|
|
- host = "http://172.19.0.15:8082/applets/midjourney/notifyHook";
|
|
|
+ host = "http://172.17.0.1:8082/applets/midjourney/notifyHook";
|
|
|
}else {
|
|
|
host = host + "/8083/api/applets/midjourney/notifyHook";
|
|
|
}
|
|
|
@@ -926,8 +923,8 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
//});
|
|
|
}
|
|
|
|
|
|
- public void cancel(Integer mode,Long taskId) {
|
|
|
- String body = HttpUtil.post(mode == 1 ? FAST_HOST : RELAX_HOST + "/mj/task/"+taskId+"/cancel",MapUtil.empty());
|
|
|
+ public void cancel(Long taskId) {
|
|
|
+ String body = HttpUtil.post(RELAX_HOST + "/mj/task/"+taskId+"/cancel",MapUtil.empty());
|
|
|
log.info("cancel body:{}", body);
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
if (jsonObject.getInt("code") != 1) {
|