Kaynağa Gözat

微信会话内容存储获取优化,下载暂时关闭

anderx 6 ay önce
ebeveyn
işleme
b2c033e101

+ 1 - 0
src/main/java/com/kede/common/task/ConversationContentTask.java

@@ -170,6 +170,7 @@ public class ConversationContentTask {
                 }
                 }
                 in.setMsgtime(chatMsg.getMsgtime());
                 in.setMsgtime(chatMsg.getMsgtime());
                 in.setMsgtype(chatMsg.getMsgtype());
                 in.setMsgtype(chatMsg.getMsgtype());
+                in.setMsgurl(chatMsg.getMsgurl());
                 in.setContent(chatMsg.getContent());
                 in.setContent(chatMsg.getContent());
                 in.setCreateTime(new Date());
                 in.setCreateTime(new Date());
                 chatMsgMapper.insert(in);
                 chatMsgMapper.insert(in);

+ 9 - 0
src/main/java/com/kede/wechat/bo/InputChatMsg.java

@@ -25,6 +25,15 @@ public class InputChatMsg {
     private Date msgtime;
     private Date msgtime;
     private String msgtype;
     private String msgtype;
     private String content;
     private String content;
+    private String msgurl;
+
+    public String getMsgurl() {
+        return msgurl;
+    }
+
+    public void setMsgurl(String msgurl) {
+        this.msgurl = msgurl;
+    }
 
 
     public InputChatMsg() {
     public InputChatMsg() {
     }
     }

+ 13 - 4
src/main/java/com/kede/wechat/service/impl/ConversationContentServiceImpl.java

@@ -25,6 +25,8 @@ import java.io.FileOutputStream;
 import java.io.UnsupportedEncodingException;
 import java.io.UnsupportedEncodingException;
 import java.util.*;
 import java.util.*;
 
 
+import static sun.plugin2.os.windows.OSVERSIONINFOA.size;
+
 @Service("ConversationContentService")
 @Service("ConversationContentService")
 public class ConversationContentServiceImpl implements ConversationContentService {
 public class ConversationContentServiceImpl implements ConversationContentService {
 
 
@@ -149,13 +151,20 @@ public class ConversationContentServiceImpl implements ConversationContentServic
                         if(!msgtype.equals("text")){
                         if(!msgtype.equals("text")){
                             if (msgtype.equals("mixed")){
                             if (msgtype.equals("mixed")){
                                 System.out.println(jsonObject);
                                 System.out.println(jsonObject);
-                                for (int j = 0; j < jsonObject.getJSONArray("mixed").size(); j++) {
-                                    String url=pushFileUrl(sdk,msgtype,jsonObject);
+                                com.alibaba.fastjson.JSONArray mixed = jsonObject.getJSONArray("mixed");
+                                for (int j = 0; j < mixed.size(); j++) {
+                                    com.alibaba.fastjson.JSONObject e = mixed.getJSONObject(j);
+                                    if (e.getString("msgtype").equals("text")){
+                                        String content = pushFileUrl(sdk,e.getString("msgtype"),e);
+                                        chatMsg.setContent(content);
+                                    }else {
+                                        String url = pushFileUrl(sdk,e.getString("msgtype"),e);
+                                        chatMsg.setMsgurl(url);
+                                    }
                                 }
                                 }
-
                             }else {
                             }else {
                                 String url=pushFileUrl(sdk,msgtype,jsonObject);
                                 String url=pushFileUrl(sdk,msgtype,jsonObject);
-                                chatMsg.setContent(url);
+                                chatMsg.setMsgurl(url);
                             }
                             }
 
 
                         }
                         }