Parcourir la source

新增内蒙会话内容存档

anderx il y a 6 mois
Parent
commit
f6f641fe32

+ 2 - 0
src/main/java/com/kede/common/dao/ChatMsgUserMapper.java

@@ -90,5 +90,7 @@ public interface ChatMsgUserMapper {
     List<ChatMsgUser>  selectMyIdByRoom(InputgetUserMsg in);
 
     void deleteByUserId(String from);
+
+    List<ChatMsgUser> selectByProvinceType(int i);
 }
 

+ 3 - 0
src/main/java/com/kede/common/mapper/ChatMsgUserMapper.xml

@@ -200,6 +200,9 @@
         </if>
         )x left join chat_msg_user b on x.roomid=b.user_id
     </select>
+    <select id="selectByProvinceType" resultMap="ChatMsgUserMap">
+        select * from chat_msg_user where province_type=#{provinceType}
+    </select>
 
 </mapper>
 

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

@@ -167,6 +167,27 @@ public class ConversationContentTask {
     }
 
 
+    @RequestMapping(value ="/open/pushMsgName", method = RequestMethod.GET)
+    public void pushMsgName() {
+        List<ChatMsgUser> chatMsgUsers = chatMsgUserMapper.selectByProvinceType(0);
+        for (ChatMsgUser chatMsgUser : chatMsgUsers) {
+            String name = chatMsgUser.getName();
+            if (name.contains("未知")){
+                System.out.println(name);
+                Map<String, Object> map = conversationContentService.pushGetUserName(chatMsgUser.getUserId(), 0);
+                String str = (String) map.get("name");
+                if (!str.contains("未知")){
+                    chatMsgUser.setName(str);
+                    System.out.println(str);
+                    chatMsgUserMapper.update(chatMsgUser);
+                }
+            }
+
+        }
+
+    }
+
+
 
 
 }

+ 3 - 0
src/main/java/com/kede/wechat/service/ConversationContentService.java

@@ -30,4 +30,7 @@ public interface ConversationContentService {
     Object getMyIdByRoom(InputgetUserMsg in);
 
     Object getMsgList(InputgetUserMsg in);
+
+
+    Map<String, Object> pushGetUserName(String userId, int i);
 }

+ 38 - 0
src/main/java/com/kede/wechat/service/impl/ConversationContentServiceImpl.java

@@ -771,6 +771,44 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
         return chatMsgs;
     }
 
+    @Override
+    public Map<String, Object> pushGetUserName(String userId, int type) {
+            ChatMsgUser chatMsgUser =new ChatMsgUser();
+            Map<String, Object> map = new HashMap<>();
+            String msgIdSub = userId.substring(0, 2);
+            String url=null;
+            Integer type2;
+            if (msgIdSub.equals("wb")){
+                type2=0;
+//                url=String.format("https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_robot_info??access_token=%s&robot_id=%s",getAppAccessToken(),userId);
+            }else if (msgIdSub.equals("wo")||msgIdSub.equals("wm")){
+                //     https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get
+                url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAppAccessToken(type),userId);
+                type2=1;
+            }else {
+                url=String.format("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=%s&userid=%s",getAccessToken(type),userId);
+                type2=2;
+            }
+            Map<String, Object> maps = getUserName(url, type2);
+            Object o = maps.get("name");
+            String userName = null;
+            if(o!=null){
+                userName = o.toString();
+            }
+            map.put ("code", maps.get("code"));
+
+            if (StringUtils.isNotBlank(userName)){
+                map.put("name",userName);
+            }
+            if (StringUtils.isBlank(userName)){
+                String str = "未知(" + chatMsgUser.getId() + ")";
+                chatMsgUser.setName(str);
+                map.put("name",str);
+            }
+            return map;
+
+    }
+
 
     private Map<String,Object> getUserName(String url,Integer type){
         String name = null;