|
|
@@ -118,7 +118,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
private final MidjourneyApiChannelMapper midjourneyApiChannelMapper;
|
|
|
|
|
|
- public static final Map<String, MjVersionStatus> MJ_VERSION_STATUS_MAP = new ConcurrentHashMap<>();
|
|
|
+ public static final Map<String, MjVersionStatus> MJ_VERSION_STATUS_MAP = new HashMap<>();
|
|
|
|
|
|
private final MidjourneyWhiteMapper midjourneyWhiteMapper;
|
|
|
|
|
|
@@ -991,6 +991,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
@Override
|
|
|
public void cancelConversation(MidjourneyUser user, Long id) {
|
|
|
+
|
|
|
MidjourneyUserConversation conversation = conversationMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUserConversation.class).eq(MidjourneyUserConversation::getId, id));
|
|
|
if (conversation == null) {
|
|
|
throw BusinessRuntimeException.getInstance("会话不存在");
|
|
|
@@ -1196,11 +1197,19 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
synchronized (key.intern()) {
|
|
|
String currentProgressStr = redisService.getStr(key);
|
|
|
- int currentProgress = StringUtils.isBlank(currentProgressStr) ? 0 : Integer.parseInt(currentProgressStr);
|
|
|
- if (conversation.getProgressNum() > currentProgress) {
|
|
|
- redisService.set(key, String.valueOf(conversation.getProgressNum()), RedisService.key.MIDJOURNEY_PROGRESS.getTimeout());
|
|
|
+ if(StringUtils.isNotBlank(currentProgressStr)){
|
|
|
+ if (StringUtils.isNumeric(currentProgressStr)) {
|
|
|
+ int currentProgress = Integer.parseInt(currentProgressStr);
|
|
|
+ if (conversation.getProgressNum() > currentProgress) {
|
|
|
+ redisService.set(key, String.valueOf(conversation.getProgressNum()), RedisService.key.MIDJOURNEY_PROGRESS.getTimeout());
|
|
|
+ sendProgressToClient(conversation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ redisService.set(key, 0, RedisService.key.MIDJOURNEY_PROGRESS.getTimeout());
|
|
|
sendProgressToClient(conversation);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1292,23 +1301,6 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
for (Object json : relaxArray) {
|
|
|
notifyHook(Jsons.toJson(json));
|
|
|
}
|
|
|
-
|
|
|
- //上传图片到cos
|
|
|
- List<MidjourneyUserConversation> imgConversations = conversationMapper.selectList(Wrappers.lambdaQuery(MidjourneyUserConversation.class)
|
|
|
- .eq(MidjourneyUserConversation::getStatus, "SUCCESS").notLike(MidjourneyUserConversation::getImageUrl, "cdn.mj.galaxydvd.com")
|
|
|
- .ge(MidjourneyUserConversation::getCreatedTime, DateUtil.offsetMinute(new Date(), -60 * 24)).orderByAsc(MidjourneyUserConversation::getId).last(" limit 10"));
|
|
|
- for (MidjourneyUserConversation conversation : imgConversations) {
|
|
|
- try {
|
|
|
- String imageUrl = conversation.getImageUrl();
|
|
|
- if (StringUtil.isNotBlank(imageUrl)) {
|
|
|
- conversation.setImageUrl(uploadPic(imageUrl, "conversation" + conversation.getId()));
|
|
|
- conversationMapper.updateById(conversation);
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("上传图片失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1358,11 +1350,31 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
String subCategory = parts[2] + "-" + parts[3];
|
|
|
String key = mainCategory + "-" + subCategory;
|
|
|
MJ_VERSION_STATUS_MAP
|
|
|
- .putIfAbsent(key, mjVersionStatus);
|
|
|
+ .put(key, mjVersionStatus);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncPicture() {
|
|
|
+ //上传图片到cos
|
|
|
+ List<MidjourneyUserConversation> imgConversations = conversationMapper.selectList(Wrappers.lambdaQuery(MidjourneyUserConversation.class)
|
|
|
+ .eq(MidjourneyUserConversation::getStatus, "SUCCESS").notLike(MidjourneyUserConversation::getImageUrl, "cdn.mj.galaxydvd.com")
|
|
|
+ .ge(MidjourneyUserConversation::getCreatedTime, DateUtil.offsetMinute(new Date(), -60 * 24)).orderByAsc(MidjourneyUserConversation::getId).last(" limit 10"));
|
|
|
+ for (MidjourneyUserConversation conversation : imgConversations) {
|
|
|
+ try {
|
|
|
+ String imageUrl = conversation.getImageUrl();
|
|
|
+ if (StringUtil.isNotBlank(imageUrl)) {
|
|
|
+ conversation.setImageUrl(uploadPic(imageUrl, "conversation" + conversation.getId()));
|
|
|
+ conversationMapper.updateById(conversation);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("上传图片失败", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static int extractNumberOrDefault(String input) {
|
|
|
try {
|
|
|
Pattern pattern = Pattern.compile("\\d+");
|