|
|
@@ -880,7 +880,13 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
private static String uploadPic(String url, String prefix) throws IOException {
|
|
|
// 替换 URL 并下载图像字节
|
|
|
url = url.replace("cdn.mj.liuliangbang.vip", "cdn.discordapp.com");
|
|
|
- byte[] body = HttpUtil.downloadBytes(url);
|
|
|
+
|
|
|
+ byte[] body;
|
|
|
+ try {
|
|
|
+ body = HttpUtil.downloadBytes(url);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new IOException(e);
|
|
|
+ }
|
|
|
|
|
|
// 创建临时文件并将图像字节写入文件
|
|
|
Path tempFile = Files.createTempFile(prefix, ".png");
|
|
|
@@ -1290,6 +1296,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
try {
|
|
|
JSONArray jsonArray = listByIds(1, list.stream().map(MidjourneyUserConversation::getTaskId).collect(Collectors.toList()), channel);
|
|
|
for (Object json : jsonArray) {
|
|
|
+ log.info("定时任务同步回调notifyHook");
|
|
|
notifyHook(Jsons.toJson(json));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -1299,6 +1306,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
|
|
|
JSONArray relaxArray = listByIds(2, relaxMidjourneyUserConversations.stream().map(MidjourneyUserConversation::getTaskId).collect(Collectors.toList()), null);
|
|
|
for (Object json : relaxArray) {
|
|
|
+ log.info("定时任务同步回调notifyHook");
|
|
|
notifyHook(Jsons.toJson(json));
|
|
|
}
|
|
|
}
|
|
|
@@ -1360,7 +1368,8 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
//上传图片到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"));
|
|
|
+ .ge(MidjourneyUserConversation::getCreatedTime, DateUtil.offsetMinute(new Date(), -60 * 24))
|
|
|
+ .eq(MidjourneyUserConversation::getImageInvalid,Boolean.FALSE).orderByAsc(MidjourneyUserConversation::getId).last(" limit 10"));
|
|
|
for (MidjourneyUserConversation conversation : imgConversations) {
|
|
|
try {
|
|
|
String imageUrl = conversation.getImageUrl();
|
|
|
@@ -1370,6 +1379,8 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
log.error("上传图片失败", e);
|
|
|
+ conversation.setImageInvalid(Boolean.TRUE);
|
|
|
+ conversationMapper.updateById(conversation);
|
|
|
}
|
|
|
|
|
|
}
|