|
@@ -752,114 +752,115 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
@Override
|
|
@Override
|
|
public void importInfo(List<ImHistoryMessage> info) throws Exception {
|
|
public void importInfo(List<ImHistoryMessage> info) throws Exception {
|
|
|
|
|
|
- info.forEach(i -> {
|
|
|
|
- //判断消息类型
|
|
|
|
- Integer type = i.getTargetType();
|
|
|
|
- if (type == 1) {
|
|
|
|
- //单聊会话
|
|
|
|
- MessageWrapper.PrivateImportMessage privateImportMessage = new MessageWrapper.PrivateImportMessage();
|
|
|
|
- //2:表示历史消息导入,消息不计入未读计数,且消息不会推送到终端
|
|
|
|
- privateImportMessage.setSyncFromOldSystem(2);
|
|
|
|
- //设置发送人
|
|
|
|
- //根据发送者分场景讨论
|
|
|
|
- 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());
|
|
|
|
|
|
+ for (ImHistoryMessage i : info) {//判断消息类型
|
|
|
|
+ log.info("消息导入:{}",i);
|
|
|
|
+ try {
|
|
|
|
+ Integer type = i.getTargetType();
|
|
|
|
+ if (type == 1) {
|
|
|
|
+ //单聊会话
|
|
|
|
+ MessageWrapper.PrivateImportMessage privateImportMessage = new MessageWrapper.PrivateImportMessage();
|
|
|
|
+ //2:表示历史消息导入,消息不计入未读计数,且消息不会推送到终端
|
|
|
|
+ privateImportMessage.setSyncFromOldSystem(2);
|
|
|
|
+ //设置发送人
|
|
|
|
+ //根据发送者分场景讨论
|
|
|
|
+ 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");
|
|
|
|
+ }
|
|
|
|
|
|
- //设置发送时间
|
|
|
|
- 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();
|
|
|
|
- }
|
|
|
|
|
|
+ privateImportMessage.setFromAccount(imUserId);
|
|
|
|
+ //设置接收人
|
|
|
|
+ privateImportMessage.setToAccount(i.getTargetId());
|
|
|
|
+ //设置随机数
|
|
|
|
+ privateImportMessage.setMsgRandom(new Random().nextInt());
|
|
|
|
|
|
- //设置body
|
|
|
|
- TencentRequest.MessageBody body = new TencentRequest.MessageBody();
|
|
|
|
- List<TencentRequest.MessageBody> list = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(i.getContent());
|
|
|
|
- if (i.getClassname().equals("RC:TxtMsg")) {
|
|
|
|
- //文本
|
|
|
|
- TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(jsonObject.getString("content"));
|
|
|
|
- list.add(body1);
|
|
|
|
- } else if (i.getClassname().equals("RC:ImgMsg")) {
|
|
|
|
- //图片
|
|
|
|
- TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("imageUri"));
|
|
|
|
- list.add(body1);
|
|
|
|
- } else if (i.getClassname().equals("RC:GIFMsg")) {
|
|
|
|
- //GIf
|
|
|
|
- String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
- int gifDataSize = jsonObject.getInteger("gifDataSize");
|
|
|
|
- int width = jsonObject.getInteger("width");
|
|
|
|
- int height = jsonObject.getInteger("height");
|
|
|
|
- TencentRequest.MessageBody body1 = getTimGifElem(remoteUrl,gifDataSize,width,height);
|
|
|
|
- list.add(body1);
|
|
|
|
- } else if (i.getClassname().equals("RC:HQVCMsg")){
|
|
|
|
- //语音
|
|
|
|
- String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
- int duration = jsonObject.getInteger("duration");
|
|
|
|
- TencentRequest.MessageBody body1 = getTimSoundElem(remoteUrl,duration);
|
|
|
|
- list.add(body1);
|
|
|
|
- } else if(i.getClassname().equals("RC:FileMsg")){
|
|
|
|
- //文件
|
|
|
|
- String fileUrl = jsonObject.getString("fileUrl");
|
|
|
|
- String size = jsonObject.getString("size");
|
|
|
|
- String name = jsonObject.getString("name");
|
|
|
|
-
|
|
|
|
- TencentRequest.MessageBody body1 = getTimFileElem(fileUrl,size,name);
|
|
|
|
- list.add(body1);
|
|
|
|
- } else if(i.getClassname().equals("RC:SightMsg")){
|
|
|
|
- //视频
|
|
|
|
- String sightUrl = jsonObject.getString("sightUrl");
|
|
|
|
- String size = jsonObject.getString("size");
|
|
|
|
- int duration = jsonObject.getInteger("duration");
|
|
|
|
- String content = jsonObject.getString("content");
|
|
|
|
- TencentRequest.MessageBody body1 = null;
|
|
|
|
|
|
+ //设置发送时间
|
|
|
|
+ String time = i.getDateTime();
|
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
try {
|
|
try {
|
|
- body1 = getTimVideoFileElem(sightUrl,size,duration,content);
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
|
+ Date date = df.parse(time);
|
|
|
|
+ long dateTime = date.getTime();
|
|
|
|
+ dateTime = dateTime / (1000);
|
|
|
|
+ privateImportMessage.setMsgTimeStamp(dateTime);
|
|
|
|
+ } catch (ParseException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- list.add(body1);
|
|
|
|
- } else if(i.getClassname().equals("RC:LBSMsg")) {
|
|
|
|
- //位置
|
|
|
|
- double latitude = jsonObject.getDouble("latitude");
|
|
|
|
- double longitude = jsonObject.getDouble("longitude");
|
|
|
|
- String poi = jsonObject.getString("poi");
|
|
|
|
- TencentRequest.MessageBody body1 = getTimLocationElem(latitude, longitude, poi);
|
|
|
|
- list.add(body1);
|
|
|
|
- } else if (i.getClassname().equals("RC:ImgTextMsg")){
|
|
|
|
- //图文
|
|
|
|
- TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(jsonObject.getString("content"));
|
|
|
|
- TencentRequest.MessageBody body2 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("imageUri"));
|
|
|
|
- list.add(body1);
|
|
|
|
- list.add(body2);
|
|
|
|
- } else {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ //设置body
|
|
|
|
+ TencentRequest.MessageBody body = new TencentRequest.MessageBody();
|
|
|
|
+ List<TencentRequest.MessageBody> list = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(i.getContent());
|
|
|
|
+ if (i.getClassname().equals("RC:TxtMsg")) {
|
|
|
|
+ //文本
|
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(jsonObject.getString("content"));
|
|
|
|
+ list.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:ImgMsg")) {
|
|
|
|
+ //图片
|
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("imageUri"));
|
|
|
|
+ list.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:GIFMsg")) {
|
|
|
|
+ //GIf
|
|
|
|
+ String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
+ int gifDataSize = jsonObject.getInteger("gifDataSize");
|
|
|
|
+ int width = jsonObject.getInteger("width");
|
|
|
|
+ int height = jsonObject.getInteger("height");
|
|
|
|
+ TencentRequest.MessageBody body1 = getTimGifElem(remoteUrl, gifDataSize, width, height);
|
|
|
|
+ list.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:HQVCMsg")) {
|
|
|
|
+ //语音
|
|
|
|
+ String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
+ int duration = jsonObject.getInteger("duration");
|
|
|
|
+ TencentRequest.MessageBody body1 = getTimSoundElem(remoteUrl, duration);
|
|
|
|
+ list.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:FileMsg")) {
|
|
|
|
+ //文件
|
|
|
|
+ String fileUrl = jsonObject.getString("fileUrl");
|
|
|
|
+ String size = jsonObject.getString("size");
|
|
|
|
+ String name = jsonObject.getString("name");
|
|
|
|
+
|
|
|
|
+ TencentRequest.MessageBody body1 = getTimFileElem(fileUrl, size, name);
|
|
|
|
+ list.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:SightMsg")) {
|
|
|
|
+ //视频
|
|
|
|
+ String sightUrl = jsonObject.getString("sightUrl");
|
|
|
|
+ String size = jsonObject.getString("size");
|
|
|
|
+ int duration = jsonObject.getInteger("duration");
|
|
|
|
+ String content = jsonObject.getString("content");
|
|
|
|
+ TencentRequest.MessageBody body1 = null;
|
|
|
|
+ try {
|
|
|
|
+ body1 = getTimVideoFileElem(sightUrl, size, duration, content);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ list.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:LBSMsg")) {
|
|
|
|
+ //位置
|
|
|
|
+ double latitude = jsonObject.getDouble("latitude");
|
|
|
|
+ double longitude = jsonObject.getDouble("longitude");
|
|
|
|
+ String poi = jsonObject.getString("poi");
|
|
|
|
+ TencentRequest.MessageBody body1 = getTimLocationElem(latitude, longitude, poi);
|
|
|
|
+ list.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:ImgTextMsg")) {
|
|
|
|
+ //图文
|
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(jsonObject.getString("content"));
|
|
|
|
+ TencentRequest.MessageBody body2 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("imageUri"));
|
|
|
|
+ list.add(body1);
|
|
|
|
+ list.add(body2);
|
|
|
|
+ } else {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
/* body.setMsgType(i.getClassname());
|
|
/* body.setMsgType(i.getClassname());
|
|
body.setMsgContent(i.getContent());*/
|
|
body.setMsgContent(i.getContent());*/
|
|
|
|
|
|
- /*list.add(body);*/
|
|
|
|
|
|
+ /*list.add(body);*/
|
|
/* list.stream().forEach(item->{
|
|
/* list.stream().forEach(item->{
|
|
item.setMsgContent(i.getContent());
|
|
item.setMsgContent(i.getContent());
|
|
item.setMsgType(i.getClassname());
|
|
item.setMsgType(i.getClassname());
|
|
@@ -872,124 +873,124 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
//图文对象
|
|
//图文对象
|
|
list.forEach(item -> item.setMsgType("TIMImageElem"));
|
|
list.forEach(item -> item.setMsgType("TIMImageElem"));
|
|
}*/
|
|
}*/
|
|
- privateImportMessage.setTencentMessageBody(list);
|
|
|
|
- try {
|
|
|
|
- imPluginContext.getPluginService().importPrivateMessage(privateImportMessage);
|
|
|
|
- //为已导入数据更改标识
|
|
|
|
- imGroupService.updateStatus(info);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("导入私聊IM消息失败 msg:{}",list,e);
|
|
|
|
- }
|
|
|
|
- } 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<>();
|
|
|
|
- //设置群组Id
|
|
|
|
- groupImportMessage.setGroupId(i.getGroupId());
|
|
|
|
- //设置发送人
|
|
|
|
- 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");
|
|
|
|
- }
|
|
|
|
|
|
+ privateImportMessage.setTencentMessageBody(list);
|
|
|
|
+ try {
|
|
|
|
+ imPluginContext.getPluginService().importPrivateMessage(privateImportMessage);
|
|
|
|
+ //为已导入数据更改标识
|
|
|
|
+ imGroupService.updateStatus(info);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("导入私聊IM消息失败 msg:{},entity:{}", list,i, e);
|
|
|
|
+ }
|
|
|
|
+ } 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<>();
|
|
|
|
+ //设置群组Id
|
|
|
|
+ groupImportMessage.setGroupId(i.getGroupId());
|
|
|
|
+ //设置发送人
|
|
|
|
+ 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.setFromAccount(imUserId);
|
|
|
|
+ //设置随机数
|
|
|
|
+ data1.setRandom(new Random().nextInt());
|
|
|
|
+ //设置发送时间
|
|
|
|
|
|
- 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();
|
|
|
|
- }
|
|
|
|
|
|
+ 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->{
|
|
/*bodyList.stream().forEach(item->{
|
|
item.setMsgContent(i.getContent());
|
|
item.setMsgContent(i.getContent());
|
|
item.setMsgType(i.getClassname());
|
|
item.setMsgType(i.getClassname());
|
|
});*/
|
|
});*/
|
|
- JSONObject jsonObject = JSONObject.parseObject(i.getContent());
|
|
|
|
- if (i.getClassname().equals("RC:TxtMsg")) {
|
|
|
|
- //文本
|
|
|
|
- TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(jsonObject.getString("content"));
|
|
|
|
- bodyList.add(body1);
|
|
|
|
- } else if (i.getClassname().equals("RC:ImgMsg")) {
|
|
|
|
- //图片 GIf
|
|
|
|
- TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("imageUri"));
|
|
|
|
- bodyList.add(body1);
|
|
|
|
- } else if (i.getClassname().equals("RC:GIFMsg")) {
|
|
|
|
- //GIf
|
|
|
|
- String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
- int gifDataSize = jsonObject.getInteger("gifDataSize");
|
|
|
|
- int width = jsonObject.getInteger("width");
|
|
|
|
- int height = jsonObject.getInteger("height");
|
|
|
|
- TencentRequest.MessageBody body1 = getTimGifElem(remoteUrl,gifDataSize,width,height);
|
|
|
|
- bodyList.add(body1);
|
|
|
|
- } else if (i.getClassname().equals("RC:HQVCMsg")){
|
|
|
|
- //语音
|
|
|
|
- String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
- int duration = jsonObject.getInteger("duration");
|
|
|
|
- TencentRequest.MessageBody body1 = getTimSoundElem(remoteUrl,duration);
|
|
|
|
- bodyList.add(body1);
|
|
|
|
- } else if(i.getClassname().equals("RC:FileMsg")){
|
|
|
|
- //文件
|
|
|
|
- String fileUrl = jsonObject.getString("fileUrl");
|
|
|
|
- String size = jsonObject.getString("size");
|
|
|
|
- String name = jsonObject.getString("name");
|
|
|
|
-
|
|
|
|
- TencentRequest.MessageBody body1 = getTimFileElem(fileUrl,size,name);
|
|
|
|
- bodyList.add(body1);
|
|
|
|
- } else if(i.getClassname().equals("RC:SightMsg")){
|
|
|
|
- //视频
|
|
|
|
- String sightUrl = jsonObject.getString("sightUrl");
|
|
|
|
- String size = jsonObject.getString("size");
|
|
|
|
- int duration = jsonObject.getInteger("duration");
|
|
|
|
- String content = jsonObject.getString("content");
|
|
|
|
- TencentRequest.MessageBody body1 = null;
|
|
|
|
- try {
|
|
|
|
- body1 = getTimVideoFileElem(sightUrl,size,duration,content);
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(i.getContent());
|
|
|
|
+ if (i.getClassname().equals("RC:TxtMsg")) {
|
|
|
|
+ //文本
|
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(jsonObject.getString("content"));
|
|
|
|
+ bodyList.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:ImgMsg")) {
|
|
|
|
+ //图片 GIf
|
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("imageUri"));
|
|
|
|
+ bodyList.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:GIFMsg")) {
|
|
|
|
+ //GIf
|
|
|
|
+ String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
+ int gifDataSize = jsonObject.getInteger("gifDataSize");
|
|
|
|
+ int width = jsonObject.getInteger("width");
|
|
|
|
+ int height = jsonObject.getInteger("height");
|
|
|
|
+ TencentRequest.MessageBody body1 = getTimGifElem(remoteUrl, gifDataSize, width, height);
|
|
|
|
+ bodyList.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:HQVCMsg")) {
|
|
|
|
+ //语音
|
|
|
|
+ String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
+ int duration = jsonObject.getInteger("duration");
|
|
|
|
+ TencentRequest.MessageBody body1 = getTimSoundElem(remoteUrl, duration);
|
|
|
|
+ bodyList.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:FileMsg")) {
|
|
|
|
+ //文件
|
|
|
|
+ String fileUrl = jsonObject.getString("fileUrl");
|
|
|
|
+ String size = jsonObject.getString("size");
|
|
|
|
+ String name = jsonObject.getString("name");
|
|
|
|
+
|
|
|
|
+ TencentRequest.MessageBody body1 = getTimFileElem(fileUrl, size, name);
|
|
|
|
+ bodyList.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:SightMsg")) {
|
|
|
|
+ //视频
|
|
|
|
+ String sightUrl = jsonObject.getString("sightUrl");
|
|
|
|
+ String size = jsonObject.getString("size");
|
|
|
|
+ int duration = jsonObject.getInteger("duration");
|
|
|
|
+ String content = jsonObject.getString("content");
|
|
|
|
+ TencentRequest.MessageBody body1 = null;
|
|
|
|
+ try {
|
|
|
|
+ body1 = getTimVideoFileElem(sightUrl, size, duration, content);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ bodyList.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:LBSMsg")) {
|
|
|
|
+ //位置
|
|
|
|
+ double latitude = jsonObject.getDouble("latitude");
|
|
|
|
+ double longitude = jsonObject.getDouble("longitude");
|
|
|
|
+ String poi = jsonObject.getString("poi");
|
|
|
|
+ TencentRequest.MessageBody body1 = getTimLocationElem(latitude, longitude, poi);
|
|
|
|
+ bodyList.add(body1);
|
|
|
|
+ } else if (i.getClassname().equals("RC:ImgTextMsg")) {
|
|
|
|
+ //图文
|
|
|
|
+ TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(jsonObject.getString("content"));
|
|
|
|
+ TencentRequest.MessageBody body2 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("imageUri"));
|
|
|
|
+ bodyList.add(body1);
|
|
|
|
+ bodyList.add(body2);
|
|
|
|
+ } else if (i.getClassname().equals("RC:CombineMsg")) {
|
|
|
|
+ //合并转发
|
|
|
|
+ String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
+ int conversationType = jsonObject.getInteger("conversationType");
|
|
|
|
+ getTimRelayElem();
|
|
|
|
+ } else {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
- bodyList.add(body1);
|
|
|
|
- } else if(i.getClassname().equals("RC:LBSMsg")) {
|
|
|
|
- //位置
|
|
|
|
- double latitude = jsonObject.getDouble("latitude");
|
|
|
|
- double longitude = jsonObject.getDouble("longitude");
|
|
|
|
- String poi = jsonObject.getString("poi");
|
|
|
|
- TencentRequest.MessageBody body1 = getTimLocationElem(latitude, longitude, poi);
|
|
|
|
- bodyList.add(body1);
|
|
|
|
- } else if (i.getClassname().equals("RC:ImgTextMsg")){
|
|
|
|
- //图文
|
|
|
|
- TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimTextElem(jsonObject.getString("content"));
|
|
|
|
- TencentRequest.MessageBody body2 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("imageUri"));
|
|
|
|
- bodyList.add(body1);
|
|
|
|
- bodyList.add(body2);
|
|
|
|
- } else if (i.getClassname().equals("RC:CombineMsg")){
|
|
|
|
- //合并转发
|
|
|
|
- String remoteUrl = jsonObject.getString("remoteUrl");
|
|
|
|
- int conversationType = jsonObject.getInteger("conversationType");
|
|
|
|
- getTimRelayElem();
|
|
|
|
- } else {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
/*body.setMsgContent(i.getContent());
|
|
/*body.setMsgContent(i.getContent());
|
|
body.setMsgType(i.getClassname());*/
|
|
body.setMsgType(i.getClassname());*/
|
|
|
|
|
|
- //文本对象
|
|
|
|
|
|
+ //文本对象
|
|
/*if (bodyList.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:TxtMsg")) {
|
|
/*if (bodyList.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:TxtMsg")) {
|
|
bodyList.forEach(item -> item.setMsgType("TIMTextElem"));
|
|
bodyList.forEach(item -> item.setMsgType("TIMTextElem"));
|
|
} else if (bodyList.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:ImgMsg")) {
|
|
} else if (bodyList.stream().map(TencentRequest.MessageBody::getMsgType).collect(Collectors.toList()).get(0).equals("RC:ImgMsg")) {
|
|
@@ -997,20 +998,24 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
bodyList.forEach(item -> item.setMsgType("TIMCustomElem"));
|
|
bodyList.forEach(item -> item.setMsgType("TIMCustomElem"));
|
|
}*/
|
|
}*/
|
|
|
|
|
|
- data1.setTencentMessageBody(bodyList);
|
|
|
|
|
|
+ data1.setTencentMessageBody(bodyList);
|
|
|
|
|
|
- list.add(data1);
|
|
|
|
- //导入消息列表
|
|
|
|
- groupImportMessage.setMsgList(list);
|
|
|
|
- try {
|
|
|
|
- imPluginContext.getPluginService().importGroupMessage(groupImportMessage);
|
|
|
|
- //为已导入数据更改标识
|
|
|
|
- imGroupService.updateStatus(info);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("导入群组IM消息失败 msg:{}",list,e);
|
|
|
|
|
|
+ list.add(data1);
|
|
|
|
+ //导入消息列表
|
|
|
|
+ groupImportMessage.setMsgList(list);
|
|
|
|
+ try {
|
|
|
|
+ imPluginContext.getPluginService().importGroupMessage(groupImportMessage);
|
|
|
|
+ //为已导入数据更改标识
|
|
|
|
+ imGroupService.updateStatus(info);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("导入群组IM消息失败 msg:{},entity:{}", list,i, e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ log.info("导入消息成功:{}",i);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("导入消息失败:",e);
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private TencentRequest.MessageBody getTimGifElem(String remoteUr,int size,int width,int height) {
|
|
private TencentRequest.MessageBody getTimGifElem(String remoteUr,int size,int width,int height) {
|
|
@@ -1188,19 +1193,17 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void groupTransfer() {
|
|
public void groupTransfer() {
|
|
-// int page = 1;
|
|
|
|
-// int size = 100;
|
|
|
|
-// List<ImGroup> imGroups = this.lambdaQuery().orderByDesc(ImGroup::getCreateTime)
|
|
|
|
-// .last("limit " + ((page - 1) * size) + "," + size).list();
|
|
|
|
-// while (!imGroups.isEmpty()) {
|
|
|
|
-// groupTransfer(imGroups);
|
|
|
|
-//
|
|
|
|
-// page++;
|
|
|
|
-// imGroups = this.lambdaQuery().orderByDesc(ImGroup::getCreateTime)
|
|
|
|
-// .last("limit " + ((page - 1) * size) + "," + size).list();
|
|
|
|
-// }
|
|
|
|
- ImGroup byId = this.getById("9f677fcd-9d80-4db0-8beb-0ff04e6a98f6FAN");
|
|
|
|
- groupTransfer(Collections.singletonList(byId));
|
|
|
|
|
|
+ int page = 1;
|
|
|
|
+ int size = 100;
|
|
|
|
+ List<ImGroup> imGroups = this.lambdaQuery().orderByDesc(ImGroup::getCreateTime)
|
|
|
|
+ .last("limit " + ((page - 1) * size) + "," + size).list();
|
|
|
|
+ while (!imGroups.isEmpty()) {
|
|
|
|
+ groupTransfer(imGroups);
|
|
|
|
+
|
|
|
|
+ page++;
|
|
|
|
+ imGroups = this.lambdaQuery().orderByDesc(ImGroup::getCreateTime)
|
|
|
|
+ .last("limit " + ((page - 1) * size) + "," + size).list();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1298,11 +1301,22 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
String courseIcon = sysConfigService.findConfigValue(SysConfigConstant.ICON_COURSE_GROUP_DEFAULT);
|
|
String courseIcon = sysConfigService.findConfigValue(SysConfigConstant.ICON_COURSE_GROUP_DEFAULT);
|
|
String defaultHeard = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD);
|
|
String defaultHeard = sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD);
|
|
for (ImGroup imGroup : records) {
|
|
for (ImGroup imGroup : records) {
|
|
|
|
+
|
|
|
|
+ log.info("群迁移开始:{}", imGroup.getId());
|
|
|
|
+ // 先删除群组
|
|
|
|
+ try {
|
|
|
|
+ // 解散群
|
|
|
|
+ imPluginContext.getPluginService().groupDismiss(imGroup.getId(), new ArrayList<>());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(String.format("群迁移删除群聊失败:%s", e.getMessage()),e);
|
|
|
|
+ }
|
|
|
|
+
|
|
List<ImGroupMember> memberList = imGroupMemberService.lambdaQuery()
|
|
List<ImGroupMember> memberList = imGroupMemberService.lambdaQuery()
|
|
.eq(ImGroupMember::getGroupId, imGroup.getId())
|
|
.eq(ImGroupMember::getGroupId, imGroup.getId())
|
|
.list();
|
|
.list();
|
|
ImGroupMember admin = memberList.stream().filter(ImGroupMember::getIsAdmin).findFirst().orElse(null);
|
|
ImGroupMember admin = memberList.stream().filter(ImGroupMember::getIsAdmin).findFirst().orElse(null);
|
|
if (admin == null) {
|
|
if (admin == null) {
|
|
|
|
+ log.info("群主不存在,groupId:{}",imGroup.getId());
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
@@ -1363,11 +1377,12 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(String.format("群迁移加入群聊失败:%s", e.getMessage()));
|
|
log.error(String.format("群迁移加入群聊失败:%s", e.getMessage()));
|
|
}
|
|
}
|
|
|
|
+ log.info("群迁移成功:{}", imGroup.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void register(Long userId, String imGroupId, String avatar, Boolean admin, ClientEnum clientType) {
|
|
private void register(Long userId, String imGroupId, String avatar, Boolean admin, ClientEnum clientType) {
|
|
- SysUser user = sysUserService.findUserById(userId);
|
|
|
|
|
|
+ SysUser user = sysUserService.getByUserId(userId);
|
|
|
|
|
|
// 群组默认头象
|
|
// 群组默认头象
|
|
List<GroupMemberWrapper.ImGroupMember> groupMembers = Lists.newArrayList();
|
|
List<GroupMemberWrapper.ImGroupMember> groupMembers = Lists.newArrayList();
|