|
@@ -60,7 +60,10 @@ 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.net.URL;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.MessageFormat;
|
|
|
import java.text.ParseException;
|
|
@@ -736,7 +739,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")){
|
|
|
//语音
|
|
@@ -758,17 +765,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);
|
|
@@ -883,17 +891,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);
|
|
@@ -945,7 +954,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();
|
|
|
|
|
|
// 获取图片基本信息
|
|
@@ -987,7 +996,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;
|
|
|
}
|
|
@@ -1003,7 +1012,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;
|
|
|
}
|
|
@@ -1020,16 +1029,35 @@ 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, format, imageFile);*/
|
|
|
+
|
|
|
|
|
|
- UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(bais, format);
|
|
|
- String url = uploadReturnBean.getUrl();
|
|
|
- //BufferedImage read = ImageIO.read(bais);
|
|
|
|
|
|
|
|
|
|
|
|
+ UploadReturnBean uploadReturnBean = uploadFileService.uploadFile(bais, format);
|
|
|
+ String url = uploadReturnBean.getUrl();
|
|
|
+ URL url2 = new URL(url);
|
|
|
+ BufferedImage read = ImageIO.read(url2);
|
|
|
+ int width = read.getWidth();
|
|
|
+ int height = read.getHeight();
|
|
|
+
|
|
|
ImageUtil.ImageInfo imageReq = ImageUtil.ImageInfo.builder()
|
|
|
.imgUrl(url)
|
|
|
.suffix(format)
|
|
@@ -1045,9 +1073,9 @@ 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.setThumbSize((imageReq.getSize().intValue()));
|
|
|
+ timVideoFileElem.setThumbWidth( width);
|
|
|
+ timVideoFileElem.setThumbHeight( height);
|
|
|
+ //timVideoFileElem.setThumbSize((imageReq.getSize().intValue()));
|
|
|
timVideoFileElem.setThumbDownloadFlag(2);
|
|
|
timVideoFileElem.setThumbFormat(format);
|
|
|
|