|
@@ -87,6 +87,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.io.*;
|
|
@@ -805,7 +807,11 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
list.add(body1);
|
|
|
} else if (i.getClassname().equals("RC:GIFMsg")) {
|
|
|
//GIf
|
|
|
- TencentRequest.MessageBody body1 = CustomerServiceBatchSendingServiceImpl.getTimImageElem(jsonObject.getString("remoteUrl"));
|
|
|
+ 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")){
|
|
|
//语音
|
|
@@ -827,17 +833,18 @@ 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);
|
|
|
+ body1 = getTimVideoFileElem(sightUrl,size,duration,content,name);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
list.add(body1);
|
|
|
} else if(i.getClassname().equals("RC:LBSMsg")) {
|
|
|
//位置
|
|
|
- int latitude = jsonObject.getInteger("latitude");
|
|
|
- int longitude = jsonObject.getInteger("longitude");
|
|
|
+ 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);
|
|
@@ -952,17 +959,18 @@ 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);
|
|
|
+ body1 = getTimVideoFileElem(sightUrl,size,duration,content,name);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
bodyList.add(body1);
|
|
|
} else if(i.getClassname().equals("RC:LBSMsg")) {
|
|
|
//位置
|
|
|
- int latitude = jsonObject.getInteger("latitude");
|
|
|
- int longitude = jsonObject.getInteger("longitude");
|
|
|
+ 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);
|
|
@@ -1014,7 +1022,7 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
// 腾讯云消息
|
|
|
ImageUtil.ImageInfo imageReq = ImageUtil.ImageInfo.builder()
|
|
|
.imgUrl(remoteUr)
|
|
|
- .suffix(remoteUr.substring(remoteUr.lastIndexOf(".") + 1))
|
|
|
+ .suffix("GIF")
|
|
|
.build();
|
|
|
|
|
|
// 获取图片基本信息
|
|
@@ -1056,7 +1064,7 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
}
|
|
|
|
|
|
//构建位置请求体
|
|
|
- private TencentRequest.MessageBody getTimLocationElem(int latitude, int longitude, String poi) {
|
|
|
+ private TencentRequest.MessageBody getTimLocationElem(double latitude, double longitude, String poi) {
|
|
|
if (latitude == 0 && longitude == 0 && StringUtils.isEmpty(poi)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -1072,7 +1080,7 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
}
|
|
|
|
|
|
//构建视频请求体
|
|
|
- public TencentRequest.MessageBody getTimVideoFileElem(String sightUrl, String size, int duration, String content) throws IOException {
|
|
|
+ public TencentRequest.MessageBody getTimVideoFileElem(String sightUrl, String size, int duration, String content,String name) throws IOException {
|
|
|
if (StringUtils.isEmpty(sightUrl) && StringUtils.isEmpty(sightUrl) && duration == 0) {
|
|
|
return null;
|
|
|
}
|
|
@@ -1089,19 +1097,38 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
}
|
|
|
|
|
|
//获取JDK8里的解码器Base64.Decoder,将base64字符串转为字节数组
|
|
|
- byte[] bytes = Base64.getDecoder().decode(content);
|
|
|
+ //byte[] bytes = Base64.getDecoder().decode(content);
|
|
|
//构建字节数组输入流
|
|
|
- bais = new ByteArrayInputStream(bytes);
|
|
|
+ //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, format);
|
|
|
- String url = uploadReturnBean.getUrl();
|
|
|
- //BufferedImage read = ImageIO.read(bais);
|
|
|
|
|
|
|
|
|
|
|
|
+ UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(bais, suffix);
|
|
|
+ String url = uploadReturnBean.getUrl();
|
|
|
+ /*BufferedImage read = ImageIO.read(bais);
|
|
|
+ int width = read.getWidth();
|
|
|
+ int height = read.getHeight();*/
|
|
|
+
|
|
|
+
|
|
|
ImageUtil.ImageInfo imageReq = ImageUtil.ImageInfo.builder()
|
|
|
.imgUrl(url)
|
|
|
- .suffix(format)
|
|
|
+ .suffix(suffix)
|
|
|
.build();
|
|
|
|
|
|
|
|
@@ -1114,8 +1141,8 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
timVideoFileElem.setVideoDownloadFlag(2);
|
|
|
timVideoFileElem.setThumbUrl(url);
|
|
|
timVideoFileElem.setThumbUUID(imageReq.getMd5());
|
|
|
- timVideoFileElem.setThumbWidth(imageReq.getWidth());
|
|
|
- timVideoFileElem.setThumbHeight(imageReq.getHeight());
|
|
|
+ timVideoFileElem.setThumbWidth( bufferedImage.getWidth());
|
|
|
+ timVideoFileElem.setThumbHeight( bufferedImage.getHeight());
|
|
|
timVideoFileElem.setThumbSize((imageReq.getSize().intValue()));
|
|
|
timVideoFileElem.setThumbDownloadFlag(2);
|
|
|
timVideoFileElem.setThumbFormat(format);
|