|
|
@@ -1364,26 +1364,30 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
|
|
|
@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))
|
|
|
- .eq(MidjourneyUserConversation::getImageInvalid,Boolean.FALSE).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);
|
|
|
- conversation.setImageInvalid(Boolean.TRUE);
|
|
|
- conversationMapper.updateById(conversation);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ public synchronized void syncPicture() {
|
|
|
+ while (true){
|
|
|
+ //上传图片到cos
|
|
|
+ List<MidjourneyUserConversation> imgConversations = conversationMapper.selectList(Wrappers.lambdaQuery(MidjourneyUserConversation.class)
|
|
|
+ .eq(MidjourneyUserConversation::getStatus, "SUCCESS").notLike(MidjourneyUserConversation::getImageUrl, "cdn.mj.galaxydvd.com")
|
|
|
+ .ge(MidjourneyUserConversation::getStartTime, DateUtil.offsetMinute(new Date(), -60 * 24 * 3).getTime())
|
|
|
+ .eq(MidjourneyUserConversation::getImageInvalid,Boolean.FALSE).orderByAsc(MidjourneyUserConversation::getId).last(" limit 10"));
|
|
|
+ if(imgConversations.size() == 0){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ conversation.setImageInvalid(Boolean.TRUE);
|
|
|
+ conversationMapper.updateById(conversation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static int extractNumberOrDefault(String input) {
|