|
@@ -1,37 +1,5 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import static com.ym.mec.biz.dal.enums.MessageTypeEnum.STUDENT_PUSH_VIP_BUY;
|
|
|
-
|
|
|
-import java.awt.image.BufferedImage;
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
-import java.net.MalformedURLException;
|
|
|
-import java.net.URL;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Map.Entry;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Random;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
-
|
|
|
-import com.ym.mec.common.entity.*;
|
|
|
-import net.coobird.thumbnailator.Thumbnails;
|
|
|
-import org.apache.commons.codec.binary.Base64;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
@@ -52,6 +20,9 @@ import com.ym.mec.biz.dal.enums.SendStatusEnum;
|
|
|
import com.ym.mec.biz.service.SysMessageConfigService;
|
|
|
import com.ym.mec.biz.service.SysMessageService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
+import com.ym.mec.common.entity.ImMessageDto;
|
|
|
+import com.ym.mec.common.entity.ImPrivateMessage;
|
|
|
+import com.ym.mec.common.entity.ImTxtMessage;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.page.QueryInfo;
|
|
@@ -65,8 +36,27 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.string.MessageFormatter;
|
|
|
+import net.coobird.thumbnailator.Thumbnails;
|
|
|
+import org.apache.commons.codec.binary.Base64;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URL;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+
|
|
|
+import static com.ym.mec.biz.dal.enums.MessageTypeEnum.STUDENT_PUSH_VIP_BUY;
|
|
|
|
|
|
@Service
|
|
|
public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> implements SysMessageService {
|
|
@@ -234,22 +224,12 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
|
|
|
|
|
|
@Override
|
|
|
public void batchSendImMessage(MessageTypeEnum type, String senderId,String extra, String[] targetIds, String url, Object... args) {
|
|
|
- SysMessageConfig messageConfig = sysMessageConfigService.queryByType(type);
|
|
|
- if (messageConfig == null) {
|
|
|
- throw new BizException("消息类型错误");
|
|
|
- }else if(messageConfig.getSendFlag() == null || messageConfig.getSendFlag() == 0){
|
|
|
- return;
|
|
|
- }
|
|
|
- String content = MessageFormatter.arrayFormat(messageConfig.getContent(), args);
|
|
|
- if(StringUtils.isNotEmpty(url)){
|
|
|
- content += url;
|
|
|
- }
|
|
|
- ImPrivateMessage privateMessage = new ImPrivateMessage();
|
|
|
- privateMessage.setObjectName("RC:TxtMsg");
|
|
|
- privateMessage.setTargetId(targetIds);
|
|
|
- privateMessage.setSenderId(senderId);
|
|
|
- privateMessage.setContent(new ImTxtMessage(content,extra));
|
|
|
- imFeignService.privateSend(privateMessage);
|
|
|
+ String messageContent = checkMessageConfig(type);
|
|
|
+ String content = getContent(messageContent,url, args);
|
|
|
+ ExecutorService executor = Executors.newCachedThreadPool();
|
|
|
+ CompletableFuture.runAsync(()->{
|
|
|
+ imFeignService.privateSend(getImGroupMessage("RC:TxtMsg",senderId,targetIds,content,extra));
|
|
|
+ },executor);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -361,12 +341,10 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
|
|
|
if(sysUser == null){
|
|
|
throw new BizException("用户信息获取失败");
|
|
|
}
|
|
|
- ImPrivateMessage privateMessage = new ImPrivateMessage();
|
|
|
- privateMessage.setObjectName("RC:TxtMsg");
|
|
|
- privateMessage.setTargetId(studentId.split(","));
|
|
|
- privateMessage.setSenderId(sysUser.getId().toString());
|
|
|
- privateMessage.setContent(new ImTxtMessage(content,null));
|
|
|
- imFeignService.privateSend(privateMessage);
|
|
|
+ ExecutorService executor = Executors.newCachedThreadPool();
|
|
|
+ CompletableFuture.runAsync(()->{
|
|
|
+ imFeignService.privateSend(getImGroupMessage("RC:TxtMsg",sysUser.getId().toString(),studentId.split(","),content,null));
|
|
|
+ },executor);
|
|
|
}
|
|
|
|
|
|
@Override
|