|
|
@@ -752,25 +752,26 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
public void sync(MidjourneyUserConversation conversation) throws IOException {
|
|
|
if ((StringUtils.isNotBlank(conversation.getProgress()) && progress.contains(conversation.getProgress())) || status.contains(conversation.getStatus())) {
|
|
|
- log.info("同步任务:{},进度:{}",conversation.getTaskId(),conversation.getProgress());
|
|
|
- Long userId = conversation.getUserId();
|
|
|
- MidjourneyUserConversation dbConversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getTaskId, conversation.getTaskId())
|
|
|
- .eq(MidjourneyUserConversation::getUserId, userId).orderByDesc(MidjourneyUserConversation::getId).last(" limit 1"));
|
|
|
- if (dbConversation != null) {
|
|
|
- if ("SUCCESS".equals(dbConversation.getStatus()) || "FAILURE".equals(dbConversation.getStatus())) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (conversation.getProgressNum() <= dbConversation.getProgressNum() && !conversation.getStatus().equals("FAILURE")){
|
|
|
- return;
|
|
|
- }
|
|
|
- conversation.setOriginalImageUrl(conversation.getImageUrl());
|
|
|
- conversation.setAction(dbConversation.getAction());
|
|
|
- conversation.setMode(dbConversation.getMode());
|
|
|
- conversation.setId(dbConversation.getId());
|
|
|
- conversationMapper.updateById(conversation);
|
|
|
- //失败返还次数
|
|
|
- if ("FAILURE".equals(conversation.getStatus()) && !dbConversation.getStatus().equals("MODEL")){
|
|
|
- Integer mode = dbConversation.getMode();
|
|
|
+ synchronized (this) {
|
|
|
+ log.info("同步任务:{},进度:{}",conversation.getTaskId(),conversation.getProgress());
|
|
|
+ Long userId = conversation.getUserId();
|
|
|
+ MidjourneyUserConversation dbConversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getTaskId, conversation.getTaskId())
|
|
|
+ .eq(MidjourneyUserConversation::getUserId, userId).orderByDesc(MidjourneyUserConversation::getId).last(" limit 1"));
|
|
|
+ if (dbConversation != null) {
|
|
|
+ if ("SUCCESS".equals(dbConversation.getStatus()) || "FAILURE".equals(dbConversation.getStatus())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (conversation.getProgressNum() <= dbConversation.getProgressNum() && !conversation.getStatus().equals("FAILURE")){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ conversation.setOriginalImageUrl(conversation.getImageUrl());
|
|
|
+ conversation.setAction(dbConversation.getAction());
|
|
|
+ conversation.setMode(dbConversation.getMode());
|
|
|
+ conversation.setId(dbConversation.getId());
|
|
|
+ conversationMapper.updateById(conversation);
|
|
|
+ //失败返还次数
|
|
|
+ if ("FAILURE".equals(conversation.getStatus()) && !dbConversation.getStatus().equals("MODEL")){
|
|
|
+ Integer mode = dbConversation.getMode();
|
|
|
// if (StringUtils.equals("未知频道",conversation.getFailReason())) {
|
|
|
// redisService.hdel(mode == 1 ? RedisService.key.MIDJOURNEY_FAST_ACCOUNT.getName() : RedisService.key.MIDJOURNEY_ACCOUNT.getName(),dbConversation.getInstanceId().toString());
|
|
|
// String finalAccountWithMinUsage = dbConversation.getInstanceId().toString();
|
|
|
@@ -781,20 +782,21 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
// }
|
|
|
// });
|
|
|
// }
|
|
|
- Object num = redisService.get(RedisService.key.MIDJOURNEY_RELAX_LIMIT.getName() + userId);
|
|
|
- LambdaUpdateWrapper<MidjourneyUser> wrapper = Wrappers.lambdaUpdate(MidjourneyUser.class)
|
|
|
- .eq(MidjourneyUser::getId, userId);
|
|
|
- if (mode == 1){
|
|
|
- num = redisService.incr(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + userId, 1L);
|
|
|
- wrapper.set(MidjourneyUser::getMjFastNum, num);
|
|
|
- midjourneyUserMapper.update(null, wrapper);
|
|
|
- }
|
|
|
- if (mode == 2){
|
|
|
- if (num != null) {
|
|
|
- num = redisService.incr(RedisService.key.MIDJOURNEY_RELAX_LIMIT.getName() + userId, 1L);
|
|
|
- wrapper.set(MidjourneyUser::getMjRelaxNum, num);
|
|
|
+ Object num = redisService.get(RedisService.key.MIDJOURNEY_RELAX_LIMIT.getName() + userId);
|
|
|
+ LambdaUpdateWrapper<MidjourneyUser> wrapper = Wrappers.lambdaUpdate(MidjourneyUser.class)
|
|
|
+ .eq(MidjourneyUser::getId, userId);
|
|
|
+ if (mode == 1){
|
|
|
+ num = redisService.incr(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + userId, 1L);
|
|
|
+ wrapper.set(MidjourneyUser::getMjFastNum, num);
|
|
|
midjourneyUserMapper.update(null, wrapper);
|
|
|
}
|
|
|
+ if (mode == 2){
|
|
|
+ if (num != null) {
|
|
|
+ num = redisService.incr(RedisService.key.MIDJOURNEY_RELAX_LIMIT.getName() + userId, 1L);
|
|
|
+ wrapper.set(MidjourneyUser::getMjRelaxNum, num);
|
|
|
+ midjourneyUserMapper.update(null, wrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|