|
@@ -63,6 +63,7 @@ import javax.annotation.Resource;
|
|
|
import javax.imageio.ImageIO;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
+import java.net.URL;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.MessageFormat;
|
|
|
import java.text.ParseException;
|
|
@@ -764,10 +765,9 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
String size = jsonObject.getString("size");
|
|
|
int duration = jsonObject.getInteger("duration");
|
|
|
String content = jsonObject.getString("content");
|
|
|
- String name = jsonObject.getString("name");
|
|
|
TencentRequest.MessageBody body1 = null;
|
|
|
try {
|
|
|
- body1 = getTimVideoFileElem(sightUrl,size,duration,content,name);
|
|
|
+ body1 = getTimVideoFileElem(sightUrl,size,duration,content);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -890,10 +890,9 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
String size = jsonObject.getString("size");
|
|
|
int duration = jsonObject.getInteger("duration");
|
|
|
String content = jsonObject.getString("content");
|
|
|
- String name = jsonObject.getString("name");
|
|
|
TencentRequest.MessageBody body1 = null;
|
|
|
try {
|
|
|
- body1 = getTimVideoFileElem(sightUrl,size,duration,content,name);
|
|
|
+ body1 = getTimVideoFileElem(sightUrl,size,duration,content);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -937,6 +936,8 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
groupImportMessage.setMsgList(list);
|
|
|
try {
|
|
|
imPluginContext.getPluginService().importGroupMessage(groupImportMessage);
|
|
|
+ //为已导入数据更改标识
|
|
|
+ imGroupService.updateStatus(info);
|
|
|
} catch (Exception e) {
|
|
|
log.error("导入群组IM消息失败 msg:{}",list,e);
|
|
|
}
|
|
@@ -1011,7 +1012,7 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
}
|
|
|
|
|
|
//构建视频请求体
|
|
|
- public TencentRequest.MessageBody getTimVideoFileElem(String sightUrl, String size, int duration, String content,String name) throws IOException {
|
|
|
+ public TencentRequest.MessageBody getTimVideoFileElem(String sightUrl, String size, int duration, String content) throws IOException {
|
|
|
if (StringUtils.isEmpty(sightUrl) && StringUtils.isEmpty(sightUrl) && duration == 0) {
|
|
|
return null;
|
|
|
}
|
|
@@ -1027,41 +1028,26 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
format = "JPG";
|
|
|
}
|
|
|
|
|
|
- //获取JDK8里的解码器Base64.Decoder,将base64字符串转为字节数组
|
|
|
- //byte[] bytes = Base64.getDecoder().decode(content);
|
|
|
- //构建字节数组输入流
|
|
|
- //bais = new ByteArrayInputStream(bytes);
|
|
|
-
|
|
|
- //获取图片类型
|
|
|
- String suffix = name.substring(name.lastIndexOf(".") + 1);
|
|
|
- //获取JDK8里的解码器Base64.Decoder,将base64字符串转为字节数组
|
|
|
byte[] bytes = Base64.getDecoder().decode(content);
|
|
|
//构建字节数组输入流
|
|
|
bais = new ByteArrayInputStream(bytes);
|
|
|
- //通过ImageIO把字节数组输入流转为BufferedImage
|
|
|
- BufferedImage bufferedImage = ImageIO.read(bais);
|
|
|
-
|
|
|
- //构建文件
|
|
|
- File imageFile = new File(name);
|
|
|
- //写入生成文件
|
|
|
- ImageIO.write(bufferedImage, suffix, imageFile);
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
- UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(bais, suffix);
|
|
|
+ UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(bais, format);
|
|
|
String url = uploadReturnBean.getUrl();
|
|
|
- /*BufferedImage read = ImageIO.read(bais);
|
|
|
+ URL url2 = new URL(url);
|
|
|
+ BufferedImage read = ImageIO.read(url2);
|
|
|
int width = read.getWidth();
|
|
|
- int height = read.getHeight();*/
|
|
|
-
|
|
|
+ int height = read.getHeight();
|
|
|
|
|
|
ImageUtil.ImageInfo imageReq = ImageUtil.ImageInfo.builder()
|
|
|
.imgUrl(url)
|
|
|
- .suffix(suffix)
|
|
|
+ .suffix(format)
|
|
|
.build();
|
|
|
|
|
|
+ // 获取图片基本信息
|
|
|
+ ImageUtil.imageToBase64(imageReq);
|
|
|
|
|
|
ImHistoryMessageWrapper.TimVideoFileElem timVideoFileElem = new ImHistoryMessageWrapper.TimVideoFileElem();
|
|
|
timVideoFileElem.setVideoUrl(sightUrl);
|
|
@@ -1072,9 +1058,9 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
timVideoFileElem.setVideoDownloadFlag(2);
|
|
|
timVideoFileElem.setThumbUrl(url);
|
|
|
timVideoFileElem.setThumbUUID(imageReq.getMd5());
|
|
|
- timVideoFileElem.setThumbWidth( bufferedImage.getWidth());
|
|
|
- timVideoFileElem.setThumbHeight( bufferedImage.getHeight());
|
|
|
- timVideoFileElem.setThumbSize((imageReq.getSize().intValue()));
|
|
|
+ timVideoFileElem.setThumbWidth( width);
|
|
|
+ timVideoFileElem.setThumbHeight( height);
|
|
|
+ //timVideoFileElem.setThumbSize((imageReq.getSize().intValue()));
|
|
|
timVideoFileElem.setThumbDownloadFlag(2);
|
|
|
timVideoFileElem.setThumbFormat(format);
|
|
|
|