|
@@ -27,14 +27,7 @@ import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.ImGroupMemberRoleType;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.ImGroupType;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.RoleEnum;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.ImGroupMemberService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.ImGroupService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.StudentStarService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysUserService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TeacherService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.im.ImGroupWrapper;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.util.ThreadPool;
|
|
@@ -61,6 +54,8 @@ import java.io.InputStreamReader;
|
|
|
import java.net.URL;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.MessageFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -106,6 +101,9 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
@Autowired
|
|
|
private StudentStarService studentStarService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CustomerServiceBatchSendingService customerServiceBatchSendingService;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
private ImPluginContext imPluginContext;
|
|
@@ -652,30 +650,68 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
*/
|
|
|
@Override
|
|
|
public void importInfo(List<ImHistoryMessage> info) throws Exception {
|
|
|
- URL url = new URL("https://console.tim.qq.com/v4/im_open_login_svc/account_import");
|
|
|
+
|
|
|
info.stream().forEach(i -> {
|
|
|
//判断消息类型
|
|
|
Integer type = i.getTargetType();
|
|
|
if (type == 1) {
|
|
|
//单聊会话
|
|
|
-
|
|
|
MessageWrapper.PrivateImportMessage privateImportMessage = new MessageWrapper.PrivateImportMessage();
|
|
|
//2:表示历史消息导入,消息不计入未读计数,且消息不会推送到终端
|
|
|
privateImportMessage.setSyncFromOldSystem(2);
|
|
|
//设置发送人
|
|
|
- privateImportMessage.setFromAccount(i.getFromUserId());
|
|
|
+ //根据发送者分场景讨论
|
|
|
+ String id = i.getFromUserId();
|
|
|
+ String imUserId;
|
|
|
+ if (id.contains(":student")){
|
|
|
+ String[] split = id.split(":");
|
|
|
+ String userId = split[0];
|
|
|
+ String clientType = split[1];
|
|
|
+ imUserId = getImUserId(userId,clientType);
|
|
|
+ } else {
|
|
|
+ imUserId = getImUserId(id,"teacher");
|
|
|
+ }
|
|
|
+
|
|
|
+ privateImportMessage.setFromAccount(imUserId);
|
|
|
//设置接收人
|
|
|
privateImportMessage.setToAccount(i.getTargetId());
|
|
|
//设置随机数
|
|
|
privateImportMessage.setMsgRandom(new Random().nextInt());
|
|
|
- //设置body
|
|
|
|
|
|
+ //设置发送时间
|
|
|
+ String time = i.getDateTime();
|
|
|
+ SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ try {
|
|
|
+ Date date = df.parse(time);
|
|
|
+ long dateTime = date.getTime();
|
|
|
+ dateTime = dateTime / (1000);
|
|
|
+ privateImportMessage.setMsgTimeStamp(dateTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置body
|
|
|
+ TencentRequest.MessageBody body = new TencentRequest.MessageBody();
|
|
|
List<TencentRequest.MessageBody> list = new ArrayList<>();
|
|
|
- list.stream().forEach(item -> {
|
|
|
+
|
|
|
+ if (i.getClassname().equals("RC:TxtMsg")){
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(i.getContent());
|
|
|
+ list.add(body1);
|
|
|
+ } else if (i.getClassname().equals("RC:ImgMsg")){
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(i.getContent());
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getJSONObject("user").getString("portraitUri"));
|
|
|
+ list.add(body1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* body.setMsgType(i.getClassname());
|
|
|
+ body.setMsgContent(i.getContent());*/
|
|
|
+
|
|
|
+ /*list.add(body);*/
|
|
|
+ /* list.stream().forEach(item->{
|
|
|
item.setMsgContent(i.getContent());
|
|
|
item.setMsgType(i.getClassname());
|
|
|
- });
|
|
|
- if (list.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:TxtMsg")) {
|
|
|
+ });*/
|
|
|
+ if (list.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:TxtMsg")){
|
|
|
//文本对象
|
|
|
list.stream().forEach(item -> item.setMsgType("TIMTextElem"));
|
|
|
} else if (list.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:ImgMsg")) {
|
|
@@ -688,27 +724,61 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
} else if (type == 3) {
|
|
|
//群组会话
|
|
|
MessageWrapper.GroupImportMessage groupImportMessage = new MessageWrapper.GroupImportMessage();
|
|
|
List<MessageWrapper.GroupImportMessageData> list = new ArrayList<>();
|
|
|
MessageWrapper.GroupImportMessageData data1 = new MessageWrapper.GroupImportMessageData();
|
|
|
List<TencentRequest.MessageBody> bodyList = new ArrayList<>();
|
|
|
+ TencentRequest.MessageBody body = new TencentRequest.MessageBody();
|
|
|
//设置群组Id
|
|
|
groupImportMessage.setGroupId(i.getGroupId());
|
|
|
//设置发送人
|
|
|
- data1.setFromAccount(i.getFromUserId());
|
|
|
+ String imUserId;
|
|
|
+ String id = i.getFromUserId();
|
|
|
+ //根据发送者分场景讨论
|
|
|
+ if (id.contains(":student")){
|
|
|
+ String[] split = id.split(":");
|
|
|
+ String userId = split[0];
|
|
|
+ String clientType = split[1];
|
|
|
+ imUserId = getImUserId(userId,clientType);
|
|
|
+ } else {
|
|
|
+ imUserId = getImUserId(id,"teacher");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ data1.setFromAccount(imUserId);
|
|
|
//设置随机数
|
|
|
data1.setRandom(new Random().nextInt());
|
|
|
//设置发送时间
|
|
|
- data1.setSendTime(Long.parseLong(i.getDateTime()));
|
|
|
- bodyList.stream().forEach(item -> {
|
|
|
- item.setMsgContent(i.getContent());
|
|
|
- item.setMsgType(i.getClassname());
|
|
|
- });
|
|
|
- if (bodyList.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:TxtMsg")) {
|
|
|
+
|
|
|
+ String time = i.getDateTime();
|
|
|
+ SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ try {
|
|
|
+ Date date = df.parse(time);
|
|
|
+ long dateTime = date.getTime();
|
|
|
+ dateTime = dateTime / (1000);
|
|
|
+ data1.setSendTime(dateTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ /*bodyList.stream().forEach(item->{
|
|
|
+ item.setMsgContent(i.getContent());
|
|
|
+ item.setMsgType(i.getClassname());
|
|
|
+ });*/
|
|
|
+ if (i.getClassname().equals("RC:TxtMsg")){
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(i.getContent());
|
|
|
+ bodyList.add(body1);
|
|
|
+ } else if (i.getClassname().equals("RC:ImgMsg")){
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(i.getContent());
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getJSONObject("user").getString("portraitUri"));
|
|
|
+ bodyList.add(body1);
|
|
|
+ }
|
|
|
+ /*body.setMsgContent(i.getContent());
|
|
|
+ body.setMsgType(i.getClassname());*/
|
|
|
+
|
|
|
+ //文本对象
|
|
|
+ if (bodyList.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:TxtMsg")){
|
|
|
bodyList.stream().forEach(item -> item.setMsgType("TIMTextElem"));
|
|
|
} else if (bodyList.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:ImgMsg")) {
|
|
|
//暂未支持图文对象
|
|
@@ -725,12 +795,8 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|