Просмотр исходного кода

微信会话内容存储企业名称BUG修复

anderx месяцев назад: 6
Родитель
Сommit
15660e3852

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

@@ -52,14 +52,17 @@ public class InputChatMsg {
         }
         this.roomid = jsonObject.getString("roomid");
         this.msgtype = jsonObject.getString("msgtype");
-        Long msgtime1 = jsonObject.getLong("msgtime");
+        Long msgtime1 = null;
+        if (action.equals("send")||action.equals("recall")){
+            msgtime1 = jsonObject.getLong("msgtime");
+        }else if (action.equals("switch")){
+            msgtime1 = jsonObject.getLong("time");
+        }
         if (msgtime1!=null){
-        Date times=new Date();
-        times.setTime(jsonObject.getLong("msgtime"));
-        this.msgtime = times;
+            Date times=new Date();
+            times.setTime(msgtime1);
+            this.msgtime = times;
         }
-
-
     }
 
 
@@ -128,19 +131,18 @@ public class InputChatMsg {
     }
 
 
-
-
     @Override
     public String toString() {
         return new StringJoiner(", ", InputChatMsg.class.getSimpleName() + "[", "]")
                 .add("msgid='" + msgid + "'")
                 .add("action='" + action + "'")
                 .add("from='" + from + "'")
-                .add("tolist=" + tolist)
+                .add("tolist='" + tolist + "'")
                 .add("roomid='" + roomid + "'")
                 .add("msgtime=" + msgtime)
                 .add("msgtype='" + msgtype + "'")
                 .add("content='" + content + "'")
+                .add("msgurl='" + msgurl + "'")
                 .toString();
     }
 }

+ 7 - 2
src/main/java/com/kede/wechat/service/impl/ConversationContentServiceImpl.java

@@ -164,9 +164,11 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
 //                    return;
                     }
                     String str = String.valueOf(Finance.GetContentFromSlice(msg));
+                    System.out.println("getwep="+str);
                     com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(str);
                     String msgtype = jsonObject.getString("msgtype");
                     InputChatMsg chatMsg = new InputChatMsg(jsonObject);
+                    System.out.println(chatMsg.getMsgtime());
                     if (chatMsg.getMsgtime().getTime()>date.getTime()){
                         //处理数据
                         ChatMsgOptimize chatMsgOptimize = chatMsgOptimizeMapper.selectById(chatMsg.getMsgid());
@@ -194,7 +196,7 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
     }
 
     private void pushSmgType(String msgtype, com.alibaba.fastjson.JSONObject jsonObject, long sdk, InputChatMsg chatMsg) {
-        if (msgtype.equals("text"))
+        if (msgtype!=null&&msgtype.equals("text"))
         {
             //文档
             com.alibaba.fastjson.JSONObject text = jsonObject.getJSONObject("text");
@@ -252,7 +254,10 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
             String url=pushFileUrl(sdk, msgtype, jsonObject);
             chatMsg.setMsgurl(url);
         } else {
-            chatMsg.setContent(pushCharset(jsonObject.toJSONString()));
+            if (!jsonObject.getString("action").equals("switch")&&!jsonObject.getString("action").equals("recall")) {
+                chatMsg.setContent(jsonObject.toJSONString());
+            }
+
         }
     }