|
@@ -196,79 +196,75 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void pushSmgType(String msgtype, com.alibaba.fastjson.JSONObject jsonObject, long sdk, InputChatMsg chatMsg) {
|
|
private void pushSmgType(String msgtype, com.alibaba.fastjson.JSONObject jsonObject, long sdk, InputChatMsg chatMsg) {
|
|
|
- if (msgtype!=null){
|
|
|
|
|
- if (msgtype.equals("text"))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (msgtype!=null) {
|
|
|
|
|
+ if (msgtype.equals("text")) {
|
|
|
//文档
|
|
//文档
|
|
|
com.alibaba.fastjson.JSONObject text = jsonObject.getJSONObject("text");
|
|
com.alibaba.fastjson.JSONObject text = jsonObject.getJSONObject("text");
|
|
|
- if (text!=null){
|
|
|
|
|
|
|
+ if (text != null) {
|
|
|
String content1 = text.getString("content");
|
|
String content1 = text.getString("content");
|
|
|
// chatMsg.setContent(pushCharset(content1));
|
|
// chatMsg.setContent(pushCharset(content1));
|
|
|
chatMsg.setContent(content1);
|
|
chatMsg.setContent(content1);
|
|
|
}
|
|
}
|
|
|
- }else if (msgtype.equals("link"))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (msgtype.equals("link")) {
|
|
|
//链接
|
|
//链接
|
|
|
com.alibaba.fastjson.JSONObject link = jsonObject.getJSONObject("link");
|
|
com.alibaba.fastjson.JSONObject link = jsonObject.getJSONObject("link");
|
|
|
chatMsg.setMsgurl(link.getString("link_url"));
|
|
chatMsg.setMsgurl(link.getString("link_url"));
|
|
|
chatMsg.setContent(pushCharset(link.getString("title")));
|
|
chatMsg.setContent(pushCharset(link.getString("title")));
|
|
|
- }else if (msgtype.equals("mixed"))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (msgtype.equals("mixed")) {
|
|
|
//混合
|
|
//混合
|
|
|
- System.out.println("=+++++++++++++++++++++++++++++++++++++"+jsonObject);
|
|
|
|
|
|
|
+ System.out.println("=+++++++++++++++++++++++++++++++++++++" + jsonObject);
|
|
|
com.alibaba.fastjson.JSONObject mixed = jsonObject.getJSONObject("mixed");
|
|
com.alibaba.fastjson.JSONObject mixed = jsonObject.getJSONObject("mixed");
|
|
|
com.alibaba.fastjson.JSONArray item = mixed.getJSONArray("item");
|
|
com.alibaba.fastjson.JSONArray item = mixed.getJSONArray("item");
|
|
|
for (int j = 0; j < item.size(); j++) {
|
|
for (int j = 0; j < item.size(); j++) {
|
|
|
com.alibaba.fastjson.JSONObject e = item.getJSONObject(j);
|
|
com.alibaba.fastjson.JSONObject e = item.getJSONObject(j);
|
|
|
String type = e.getString("type");
|
|
String type = e.getString("type");
|
|
|
- if (type.equals("text")){
|
|
|
|
|
|
|
+ if (type.equals("text")) {
|
|
|
com.alibaba.fastjson.JSONObject contentJson = e.getJSONObject("content");
|
|
com.alibaba.fastjson.JSONObject contentJson = e.getJSONObject("content");
|
|
|
String content = contentJson.getString("content");
|
|
String content = contentJson.getString("content");
|
|
|
chatMsg.setContent(content);
|
|
chatMsg.setContent(content);
|
|
|
- }else {
|
|
|
|
|
- String url ="";
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String url = "";
|
|
|
com.alibaba.fastjson.JSONObject content = e.getJSONObject("content");
|
|
com.alibaba.fastjson.JSONObject content = e.getJSONObject("content");
|
|
|
- String sdkfileid=content.getString("sdkfileid");
|
|
|
|
|
- if (type.equals("file")){
|
|
|
|
|
|
|
+ String sdkfileid = content.getString("sdkfileid");
|
|
|
|
|
+ if (type.equals("file")) {
|
|
|
String filename = content.getString("filename");
|
|
String filename = content.getString("filename");
|
|
|
String osname = System.getProperties().getProperty("os.name");
|
|
String osname = System.getProperties().getProperty("os.name");
|
|
|
if (osname.contains("Windows")) {
|
|
if (osname.contains("Windows")) {
|
|
|
// filename = new String(filename.getBytes("GBK"),"UTF-8");
|
|
// filename = new String(filename.getBytes("GBK"),"UTF-8");
|
|
|
- String safeName=filename.replaceAll("[<>:\"/\\\\|?*,、]", "_");
|
|
|
|
|
- url="/wechat/"+ safeName;
|
|
|
|
|
|
|
+ String safeName = filename.replaceAll("[<>:\"/\\\\|?*,、]", "_");
|
|
|
|
|
+ url = "/wechat/" + safeName;
|
|
|
}
|
|
}
|
|
|
- }else if (type.equals("image")) {
|
|
|
|
|
- url="/wechat/" + System.currentTimeMillis() + ".jpg";
|
|
|
|
|
|
|
+ } else if (type.equals("image")) {
|
|
|
|
|
+ url = "/wechat/" + System.currentTimeMillis() + ".jpg";
|
|
|
com.alibaba.fastjson.JSONObject image = jsonObject.getJSONObject("image");
|
|
com.alibaba.fastjson.JSONObject image = jsonObject.getJSONObject("image");
|
|
|
- }else {
|
|
|
|
|
- chatMsg.setContent(chatMsg.getContent()+"[附件="+e+"]");
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ chatMsg.setContent(chatMsg.getContent() + "[附件=" + e + "]");
|
|
|
}
|
|
}
|
|
|
- downloadFile(sdk, sdkfileid, uploadPath+ url);
|
|
|
|
|
|
|
+ downloadFile(sdk, sdkfileid, uploadPath + url);
|
|
|
chatMsg.setMsgurl(url);
|
|
chatMsg.setMsgurl(url);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- } else if (msgtype.equals("sphfeed"))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (msgtype.equals("sphfeed")) {
|
|
|
chatMsg.setContent(jsonObject.getString("sphfeed"));
|
|
chatMsg.setContent(jsonObject.getString("sphfeed"));
|
|
|
- } else if (msgtype.equals("file")||msgtype.equals("image")||msgtype.equals("video")||msgtype.equals("voice"))
|
|
|
|
|
- {
|
|
|
|
|
- String url=pushFileUrl(sdk, msgtype, jsonObject);
|
|
|
|
|
|
|
+ } else if (msgtype.equals("file") || msgtype.equals("image") || msgtype.equals("video") || msgtype.equals("voice")) {
|
|
|
|
|
+ String url = pushFileUrl(sdk, msgtype, jsonObject);
|
|
|
chatMsg.setMsgurl(url);
|
|
chatMsg.setMsgurl(url);
|
|
|
- } else if (msgtype.equals("chatrecord"))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (msgtype.equals("chatrecord")) {
|
|
|
chatMsg.setContent(jsonObject.getString("chatrecord"));
|
|
chatMsg.setContent(jsonObject.getString("chatrecord"));
|
|
|
- } else if (msgtype.equals("agree"))
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (msgtype.equals("agree")) {
|
|
|
chatMsg.setContent("[同意会话存储]");
|
|
chatMsg.setContent("[同意会话存储]");
|
|
|
- } else if (msgtype.equals("disagree"))
|
|
|
|
|
|
|
+ } else if (msgtype.equals("disagree")) {
|
|
|
chatMsg.setContent("[不同意会话存储]");
|
|
chatMsg.setContent("[不同意会话存储]");
|
|
|
|
|
+ } else if (msgtype.equals("emotion")) {
|
|
|
|
|
+ String url = pushFileUrl(sdk, msgtype, jsonObject);
|
|
|
|
|
+ chatMsg.setMsgurl(url);
|
|
|
} else {
|
|
} else {
|
|
|
- if (!jsonObject.getString("action").equals("switch")&&!jsonObject.getString("action").equals("recall")) {
|
|
|
|
|
|
|
+ if (!jsonObject.getString("action").equals("switch") && !jsonObject.getString("action").equals("recall")) {
|
|
|
chatMsg.setContent(jsonObject.toJSONString());
|
|
chatMsg.setContent(jsonObject.toJSONString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String pushCharset(String content1) {
|
|
private String pushCharset(String content1) {
|
|
@@ -298,19 +294,31 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
|
|
|
if (osname.contains("Windows")) {
|
|
if (osname.contains("Windows")) {
|
|
|
// filename = new String(filename.getBytes("GBK"),"UTF-8");
|
|
// filename = new String(filename.getBytes("GBK"),"UTF-8");
|
|
|
String safeName=filename.replaceAll("[<>:\"/\\\\|?*,、]", "_");
|
|
String safeName=filename.replaceAll("[<>:\"/\\\\|?*,、]", "_");
|
|
|
- url = "/wechat/"+ safeName;
|
|
|
|
|
|
|
+ url = "/wechat/"+ "file/"+safeName;
|
|
|
}
|
|
}
|
|
|
}else if (msgtype.equals("image")){
|
|
}else if (msgtype.equals("image")){
|
|
|
- url = "/wechat/"+ System.currentTimeMillis()+".jpg";
|
|
|
|
|
|
|
+ url = "/wechat/"+"image/"+ System.currentTimeMillis()+".jpg";
|
|
|
com.alibaba.fastjson.JSONObject image = jsonObject.getJSONObject("image");
|
|
com.alibaba.fastjson.JSONObject image = jsonObject.getJSONObject("image");
|
|
|
sdkfileid = image.getString("sdkfileid");
|
|
sdkfileid = image.getString("sdkfileid");
|
|
|
}else if (msgtype.equals("voice")){
|
|
}else if (msgtype.equals("voice")){
|
|
|
- url = "/wechat/"+ System.currentTimeMillis()+".mp3";
|
|
|
|
|
|
|
+ url = "/wechat/"+"voice/" +System.currentTimeMillis()+".mp3";
|
|
|
com.alibaba.fastjson.JSONObject image = jsonObject.getJSONObject("voice");
|
|
com.alibaba.fastjson.JSONObject image = jsonObject.getJSONObject("voice");
|
|
|
sdkfileid = image.getString("sdkfileid");
|
|
sdkfileid = image.getString("sdkfileid");
|
|
|
}else if (msgtype.equals("video")){
|
|
}else if (msgtype.equals("video")){
|
|
|
- url = url +"/wechat/"+ System.currentTimeMillis()+".mp4";
|
|
|
|
|
|
|
+ url = url +"/wechat/"+"video/"+ System.currentTimeMillis()+".mp4";
|
|
|
com.alibaba.fastjson.JSONObject image = jsonObject.getJSONObject("video");
|
|
com.alibaba.fastjson.JSONObject image = jsonObject.getJSONObject("video");
|
|
|
|
|
+ }else if (msgtype.equals("emotion")){
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject emotion = jsonObject.getJSONObject("emotion");
|
|
|
|
|
+ Integer type=emotion.getInteger("type");
|
|
|
|
|
+ String suffix= "";
|
|
|
|
|
+ if (type==1){
|
|
|
|
|
+ suffix=".gif";
|
|
|
|
|
+ }else if (type==2){
|
|
|
|
|
+ suffix=".png";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ url = url +"/wechat/"+"emotion/"+ System.currentTimeMillis()+suffix;
|
|
|
|
|
+ sdkfileid = emotion.getString("sdkfileid");
|
|
|
}
|
|
}
|
|
|
// 下载文件
|
|
// 下载文件
|
|
|
downloadFile(sdk, sdkfileid, uploadPath+url);
|
|
downloadFile(sdk, sdkfileid, uploadPath+url);
|
|
@@ -327,6 +335,8 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
|
|
|
System.out.println("getmediadata ret:" + ret);
|
|
System.out.println("getmediadata ret:" + ret);
|
|
|
Finance.FreeMediaData(media_data);
|
|
Finance.FreeMediaData(media_data);
|
|
|
return;
|
|
return;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ System.out.println("getmediadata ret:" + ret);
|
|
|
}
|
|
}
|
|
|
System.out.printf("getmediadata outindex len:%d, data_len:%d, is_finis:%d\n",Finance.GetIndexLen(media_data),Finance.GetDataLen(media_data), Finance.IsMediaDataFinish(media_data));
|
|
System.out.printf("getmediadata outindex len:%d, data_len:%d, is_finis:%d\n",Finance.GetIndexLen(media_data),Finance.GetDataLen(media_data), Finance.IsMediaDataFinish(media_data));
|
|
|
try {
|
|
try {
|