Browse Source

微信会话内容存储开发

anderx 7 months ago
parent
commit
f8401822af

+ 2 - 1
.gitignore

@@ -1,2 +1,3 @@
 /target/
-/out/
+/out/
+/src/main/resources/lib/libcrypto-3-x64.dll

+ 85 - 0
src/main/java/com/kede/common/dao/ChatMsgMapper.java

@@ -0,0 +1,85 @@
+package com.kede.common.dao;
+
+import com.kede.common.model.ChatMsg;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * 微信会话存储(ChatMsg)表数据库访问层
+ *
+ * @author makejava
+ * @since 2025-06-17 11:06:18
+ */
+public interface ChatMsgMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    ChatMsg selectById(Integer id);
+
+
+    /**
+     * 查询指定行数据
+     *
+     * @param chatMsg  查询条件
+     * @param pageable 分页对象
+     * @return 对象列表
+     */
+    List<ChatMsg> findChatMsgList(ChatMsg chatMsg);
+
+    /**
+     * 统计总行数
+     *
+     * @param chatMsg 查询条件
+     * @return 总行数
+     */
+    int findChatMsgCount(ChatMsg chatMsg);
+
+    /**
+     * 新增数据
+     *
+     * @param chatMsg 实例对象
+     * @return 影响行数
+     */
+    int insert(ChatMsg chatMsg);
+
+    /**
+     * 批量新增数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<ChatMsg> 实例对象列表
+     * @return 影响行数
+     */
+    int insertBatch(@Param("entities") List<ChatMsg> entities);
+
+    /**
+     * 批量新增或按主键更新数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<ChatMsg> 实例对象列表
+     * @return 影响行数
+     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
+     */
+    int insertOrUpdateBatch(@Param("entities") List<ChatMsg> entities);
+
+    /**
+     * 修改数据
+     *
+     * @param chatMsg 实例对象
+     * @return 影响行数
+     */
+    int update(ChatMsg chatMsg);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+}
+

+ 216 - 0
src/main/java/com/kede/common/mapper/ChatMsgMapper.xml

@@ -0,0 +1,216 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.kede.common.dao.ChatMsgMapper">
+
+    <resultMap type="com.kede.common.model.ChatMsg" id="ChatMsgMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="msgid" column="msgid" jdbcType="VARCHAR"/>
+        <result property="action" column="action" jdbcType="VARCHAR"/>
+        <result property="from" column="from" jdbcType="VARCHAR"/>
+        <result property="fromName" column="from_name" jdbcType="VARCHAR"/>
+        <result property="tolist" column="tolist" jdbcType="VARCHAR"/>
+        <result property="tolistName" column="tolist_name" jdbcType="VARCHAR"/>
+        <result property="roomid" column="roomid" jdbcType="VARCHAR"/>
+        <result property="msgtime" column="msgtime" jdbcType="TIMESTAMP"/>
+        <result property="msgtype" column="msgtype" jdbcType="VARCHAR"/>
+        <result property="content" column="content" jdbcType="VARCHAR"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="ChatMsgAllSql">
+        id, msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content, create_time
+    </sql>
+
+    <!--查询单个-->
+    <select id="selectById" resultMap="ChatMsgMap">
+        select
+        <include refid="ChatMsgAllSql"/>
+        from chat_msg
+        where id = #{id}
+    </select>
+
+    <!--新增所有列-->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
+                             create_time)
+        values (#{msgid}, #{action}, #{from}, #{fromName}, #{tolist}, #{tolistName}, #{roomid}, #{msgtime}, #{msgtype},
+                #{content}, #{createTime})
+    </insert>
+
+    <insert id="insertBatch">
+        insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
+        create_time)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.msgid}, #{entity.action}, #{entity.from}, #{entity.fromName}, #{entity.tolist},
+            #{entity.tolistName}, #{entity.roomid}, #{entity.msgtime}, #{entity.msgtype}, #{entity.content},
+            #{entity.createTime})
+        </foreach>
+    </insert>
+
+    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
+        create_time)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.msgid}, #{entity.action}, #{entity.from}, #{entity.fromName}, #{entity.tolist},
+            #{entity.tolistName}, #{entity.roomid}, #{entity.msgtime}, #{entity.msgtype}, #{entity.content},
+            #{entity.createTime})
+        </foreach>
+        on duplicate key update
+        msgid = values(msgid),
+        action = values(action),
+        from = values(from),
+        from_name = values(from_name),
+        tolist = values(tolist),
+        tolist_name = values(tolist_name),
+        roomid = values(roomid),
+        msgtime = values(msgtime),
+        msgtype = values(msgtype),
+        content = values(content),
+        create_time = values(create_time)
+    </insert>
+
+    <!--通过主键修改数据-->
+    <update id="update">
+        update chat_msg
+        <set>
+            <if test="msgid != null and msgid != ''">
+                msgid = #{msgid},
+            </if>
+            <if test="action != null and action != ''">
+                action = #{action},
+            </if>
+            <if test="from != null and from != ''">
+                from = #{from},
+            </if>
+            <if test="fromName != null and fromName != ''">
+                from_name = #{fromName},
+            </if>
+            <if test="tolist != null and tolist != ''">
+                tolist = #{tolist},
+            </if>
+            <if test="tolistName != null and tolistName != ''">
+                tolist_name = #{tolistName},
+            </if>
+            <if test="roomid != null and roomid != ''">
+                roomid = #{roomid},
+            </if>
+            <if test="msgtime != null">
+                msgtime = #{msgtime},
+            </if>
+            <if test="msgtype != null and msgtype != ''">
+                msgtype = #{msgtype},
+            </if>
+            <if test="content != null and content != ''">
+                content = #{content},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--查询指定行数据-->
+    <select id="findChatMsgList" resultMap="ChatMsgMap">
+        select
+        <include refid="ChatMsgAllSql"/>
+
+        from chat_msg
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="msgid != null and msgid != ''">
+                and msgid = #{msgid}
+            </if>
+            <if test="action != null and action != ''">
+                and action = #{action}
+            </if>
+            <if test="from != null and from != ''">
+                and from = #{from}
+            </if>
+            <if test="fromName != null and fromName != ''">
+                and from_name = #{fromName}
+            </if>
+            <if test="tolist != null and tolist != ''">
+                and tolist = #{tolist}
+            </if>
+            <if test="tolistName != null and tolistName != ''">
+                and tolist_name = #{tolistName}
+            </if>
+            <if test="roomid != null and roomid != ''">
+                and roomid = #{roomid}
+            </if>
+            <if test="msgtime != null">
+                and msgtime = #{msgtime}
+            </if>
+            <if test="msgtype != null and msgtype != ''">
+                and msgtype = #{msgtype}
+            </if>
+            <if test="content != null and content != ''">
+                and content = #{content}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+        </where>
+        <if test="page_sql != null">
+            ${page_sql}
+        </if>
+    </select>
+
+    <!--统计总行数-->
+    <select id="findChatMsgCount" resultType="java.lang.Integer">
+        select count(1)
+        from chat_msg
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="msgid != null and msgid != ''">
+                and msgid = #{msgid}
+            </if>
+            <if test="action != null and action != ''">
+                and action = #{action}
+            </if>
+            <if test="from != null and from != ''">
+                and from = #{from}
+            </if>
+            <if test="fromName != null and fromName != ''">
+                and from_name = #{fromName}
+            </if>
+            <if test="tolist != null and tolist != ''">
+                and tolist = #{tolist}
+            </if>
+            <if test="tolistName != null and tolistName != ''">
+                and tolist_name = #{tolistName}
+            </if>
+            <if test="roomid != null and roomid != ''">
+                and roomid = #{roomid}
+            </if>
+            <if test="msgtime != null">
+                and msgtime = #{msgtime}
+            </if>
+            <if test="msgtype != null and msgtype != ''">
+                and msgtype = #{msgtype}
+            </if>
+            <if test="content != null and content != ''">
+                and content = #{content}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+        </where>
+    </select>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete
+        from chat_msg
+        where id = #{id}
+    </delete>
+
+</mapper>
+

+ 160 - 0
src/main/java/com/kede/common/model/ChatMsg.java

@@ -0,0 +1,160 @@
+package com.kede.common.model;
+
+import java.util.Date;
+import java.io.Serializable;
+
+
+/**
+ * 微信会话存储(ChatMsg)实体类
+ *
+ * @author makejava
+ * @since 2025-06-17 11:12:22
+ */
+public class ChatMsg implements Serializable {
+    private static final long serialVersionUID = 334641604843861859L;
+
+    private Integer id;
+    /**
+     * 会话信息编号
+     */
+    private String msgid;
+    /**
+     * 消息动作,目前有send(发送消息)/recall(撤回消息)/switch(切换企业日志)三种类型
+     */
+    private String action;
+    /**
+     * 消息发送方id。同一企业内容为userid,非相同企业为external_userid。消息如果是机器人发出,也为external_userid。
+     */
+    private String from;
+    /**
+     * 发送名称
+     */
+    private String fromName;
+    /**
+     * 消息接收方列表,可能是多个,同一个企业内容为userid,非相同企业为external_userid。数组,内容为string类型
+     */
+    private String tolist;
+    /**
+     * 接受者名称
+     */
+    private String tolistName;
+    /**
+     * 群聊消息的群id。如果是单聊则为空。String类型
+     */
+    private String roomid;
+    /**
+     * 消息发送时间戳
+     */
+    private Date msgtime;
+    /**
+     * 文本消息为:text。
+     */
+    private String msgtype;
+    /**
+     * 消息内容
+     */
+    private String content;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getMsgid() {
+        return msgid;
+    }
+
+    public void setMsgid(String msgid) {
+        this.msgid = msgid;
+    }
+
+    public String getAction() {
+        return action;
+    }
+
+    public void setAction(String action) {
+        this.action = action;
+    }
+
+    public String getFrom() {
+        return from;
+    }
+
+    public void setFrom(String from) {
+        this.from = from;
+    }
+
+    public String getFromName() {
+        return fromName;
+    }
+
+    public void setFromName(String fromName) {
+        this.fromName = fromName;
+    }
+
+    public String getTolist() {
+        return tolist;
+    }
+
+    public void setTolist(String tolist) {
+        this.tolist = tolist;
+    }
+
+    public String getTolistName() {
+        return tolistName;
+    }
+
+    public void setTolistName(String tolistName) {
+        this.tolistName = tolistName;
+    }
+
+    public String getRoomid() {
+        return roomid;
+    }
+
+    public void setRoomid(String roomid) {
+        this.roomid = roomid;
+    }
+
+    public Date getMsgtime() {
+        return msgtime;
+    }
+
+    public void setMsgtime(Date msgtime) {
+        this.msgtime = msgtime;
+    }
+
+    public String getMsgtype() {
+        return msgtype;
+    }
+
+    public void setMsgtype(String msgtype) {
+        this.msgtype = msgtype;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+}
+

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

@@ -0,0 +1,68 @@
+package com.kede.common.task;
+
+import com.kede.wechat.bo.InputChatMsg;
+import com.kede.wechat.service.ConversationContentService;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.sql.SQLOutput;
+import java.util.List;
+import java.util.Map;
+import java.util.StringJoiner;
+
+@Component
+@RestController
+public class ConversationContentTask {
+    @Resource
+    private ConversationContentService conversationContentService;
+
+    /**
+     * 获取企业微信聊天记录
+     */
+//    @Scheduled(cron = "0 0/5 * * * ?")
+    @RequestMapping(value ="/open/pushMsg", method = RequestMethod.GET)
+    public void pushMsg() {
+        Integer pageSeq = 0;
+        Integer pageEnd = 100;
+        Integer pageLimit = 100;
+        Integer count = 0;
+        //循环获取数据,每次100条,count不足100条时最后一次循序
+//        while (count < pageLimit) {
+            pageEnd=3;
+            Map<String, Object> map = conversationContentService.getChatData(pageSeq, pageEnd);
+            List<InputChatMsg> list = (List<InputChatMsg>) map.get("list");
+            pushChatMsg(list);
+//            if (map == null) {
+//                break;
+//            }
+//            if ((int)map.get("total")<100) {
+//                break;
+//            }
+//            pageSeq= pageSeq + pageLimit+1;
+//            pageEnd = pageEnd + pageLimit;
+//        }
+
+    }
+
+    private void pushChatMsg(List<InputChatMsg> list) {
+        for (InputChatMsg chatMsg : list) {
+            System.out.println(chatMsg);
+            String from = chatMsg.getFrom();
+            String chatName = conversationContentService.getChatName(from);
+            System.out.println("from"+chatName);
+            String tolist = chatMsg.getTolist();
+            //用逗号分割
+            String[] tolistArr = tolist.split(",");
+            for (String tolistName : tolistArr) {
+                String tolistName1 = conversationContentService.getChatName(tolistName);
+                System.out.println("toList="+tolistName1);
+            }
+        }
+    }
+
+
+}

+ 39 - 27
src/main/java/com/kede/wechat/bo/ChatMsg.java

@@ -2,38 +2,57 @@ package com.kede.wechat.bo;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.kede.common.utils.DateUtils;
 import javafx.scene.text.Text;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.StringJoiner;
 
-public class ChatMsg {
+public class InputChatMsg {
 //    {\"msgid\":\"1634016854685227651_1749628622146_external\",\"action\":\"send\"," +
 //            "\"from\":\"wopeIoCwAArS1POCA5Fiw6VidWWqkwVA\",\"tolist\":[\"KaKa\"],\"roomid\":\"\",\"msgtime\":1749628618742,\"msgtype\":\"text\",\"" +
 //            "text\":{\"content\":\"您好,请详细描述您的问题,以便更快得到解答!\"}}";
     private String msgid;
     private String action;
     private String from;
-    private List<String> tolist;
+    private String tolist;
     private String roomid;
-    private Long msgtime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date msgtime;
     private String msgtype;
     private String content;
 
-    public ChatMsg() {
+    public InputChatMsg() {
     }
 
-    public ChatMsg(JSONObject jsonObject) {
+    public InputChatMsg(JSONObject jsonObject) {
         this.msgid = jsonObject.getString("msgid");
         this.action = jsonObject.getString("action");
         this.from = jsonObject.getString("from");
         JSONArray tolist1 = jsonObject.getJSONArray("tolist");
-        this.tolist =tolist1.toJavaList(String.class);
+        if (tolist1!=null){
+            StringJoiner tolist = new StringJoiner(",");
+            tolist1.toJavaList(String.class).forEach(
+                    tolist::add
+            );
+            this.tolist =tolist.toString();
+        }
         this.roomid = jsonObject.getString("roomid");
-        this.msgtime = jsonObject.getLong("msgtime");
+        Long msgtime1 = jsonObject.getLong("msgtime");
+        if (msgtime1!=null){
+        Date times=new Date();
+        times.setTime(jsonObject.getLong("msgtime"));
+        this.msgtime = times;
+        }
         this.msgtype = jsonObject.getString("msgtype");
         JSONObject text = jsonObject.getJSONObject("text");
-        this.content = text.getString("content");
+        if (text!=null){
+            this.content = text.getString("content");
+        }
+
     }
 
 
@@ -61,11 +80,11 @@ public class ChatMsg {
         this.from = from;
     }
 
-    public List<String> getTolist() {
+    public String getTolist() {
         return tolist;
     }
 
-    public void setTolist(List<String> tolist) {
+    public void setTolist(String tolist) {
         this.tolist = tolist;
     }
 
@@ -77,13 +96,7 @@ public class ChatMsg {
         this.roomid = roomid;
     }
 
-    public Long getMsgtime() {
-        return msgtime;
-    }
 
-    public void setMsgtime(Long msgtime) {
-        this.msgtime = msgtime;
-    }
 
     public String getMsgtype() {
         return msgtype;
@@ -103,16 +116,15 @@ public class ChatMsg {
 
     @Override
     public String toString() {
-        final StringBuffer sb = new StringBuffer("ChatMsg{");
-        sb.append("msgid='").append(msgid).append('\'');
-        sb.append(", action='").append(action).append('\'');
-        sb.append(", from='").append(from).append('\'');
-        sb.append(", tolist=").append(tolist);
-        sb.append(", roomid='").append(roomid).append('\'');
-        sb.append(", msgtime=").append(msgtime);
-        sb.append(", msgtype='").append(msgtype).append('\'');
-        sb.append(", content='").append(content).append('\'');
-        sb.append('}');
-        return sb.toString();
+        return new StringJoiner(", ", InputChatMsg.class.getSimpleName() + "[", "]")
+                .add("msgid='" + msgid + "'")
+                .add("action='" + action + "'")
+                .add("from='" + from + "'")
+                .add("tolist=" + tolist)
+                .add("roomid='" + roomid + "'")
+                .add("msgtime=" + msgtime)
+                .add("msgtype='" + msgtype + "'")
+                .add("content='" + content + "'")
+                .toString();
     }
 }

+ 5 - 2
src/main/java/com/kede/wechat/controller/ConversationContentController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping(value = "/api/admin/release")
@@ -22,9 +23,11 @@ public class ConversationContentController extends BaseController {
      * @return
      */
     @RequestMapping(value = "/getChatData", method = RequestMethod.GET)
-    public List getChatData()
+    public Map<String, Object> getChatData()
     {
-    	return conversationContentService.getChatData();
+        Map<String, Object> map = conversationContentService.getChatData(null, null);
+
+        return map;
     }
 
     /**

+ 5 - 1
src/main/java/com/kede/wechat/service/ConversationContentService.java

@@ -1,11 +1,15 @@
 package com.kede.wechat.service;
 
+
 import java.util.List;
+import java.util.Map;
 
 public interface ConversationContentService {
-    List getChatData();
+    Map<String,Object> getChatData(Integer pageSeq, Integer pageLimit);
 
     String getAccessToken();
 
     String getPermitUserList();
+
+    String getChatName(String msg);
 }

+ 40 - 29
src/main/java/com/kede/wechat/service/impl/ConversationContentServiceImpl.java

@@ -3,7 +3,7 @@ package com.kede.wechat.service.impl;
 import com.kede.common.utils.DateUtils;
 import com.kede.common.utils.HttpUtils;
 import com.kede.common.utils.RSAEncrypt;
-import com.kede.wechat.bo.ChatMsg;
+import com.kede.wechat.bo.InputChatMsg;
 import com.kede.wechat.service.ConversationContentService;
 import com.tencent.wework.Finance;
 import org.json.JSONArray;
@@ -68,14 +68,20 @@ public class ConversationContentServiceImpl implements ConversationContentServic
             "KQIDAQAB\n" +
             "-----END PUBLIC KEY-----";
     @Override
-    public List<String>  getChatData() {
+    public Map<String,Object>  getChatData(Integer pageSeq, Integer pageLimit) {
         String message = null;
-        List<String> list = new ArrayList<>();
+        Map<String,Object> map = new HashMap<>();
+        List<InputChatMsg> list = new ArrayList<>();
+        Integer total = 0;
         long sdk = Finance.NewSdk();
         System.out.println(Finance.Init(sdk, corpid, secret));
         long ret = 0;
         int seq = 0;
         int limit = 200;
+        if (pageSeq != null || pageLimit!=null){
+            seq=pageSeq;
+            limit = pageLimit;
+        }
         long slice = Finance.NewSlice();
         ret = Finance.GetChatData(sdk, seq, limit, null, null, 3, slice);
         if (ret != 0) {
@@ -85,8 +91,8 @@ public class ConversationContentServiceImpl implements ConversationContentServic
         String getchatdata = Finance.GetContentFromSlice(slice);
         JSONObject jo = new JSONObject(getchatdata);
         JSONArray chatdata = jo.getJSONArray("chatdata");
-
-        System.out.println("消息数:" + chatdata.length());
+        total=chatdata.length();
+        System.out.println("消息数:" + total);
         for (int i = 0; i < chatdata.length(); i++) {
             String item = chatdata.get(i).toString();
 //            item:{
@@ -114,16 +120,19 @@ public class ConversationContentServiceImpl implements ConversationContentServic
 //                    return;
                 }
                 String str = String.valueOf(Finance.GetContentFromSlice(msg));
-                System.out.println("decrypt ret:" + ret + " msg:" + str);
+                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(str);
+                InputChatMsg chatMsg = new InputChatMsg(jsonObject);
+                list.add(chatMsg);
                 Finance.FreeSlice(msg);
-                list.add(str);
             } catch (Exception e) {
                 e.printStackTrace();
             }
 
         }
         Finance.FreeSlice(slice);
-    return list;
+        map.put("list",list);
+        map.put("total",total);
+    return map;
     }
 
     @Override
@@ -164,44 +173,46 @@ public class ConversationContentServiceImpl implements ConversationContentServic
             System.out.println(result.getString("errcode"));
             System.out.println("获取会话内容存档成员列表失败");
         }
-        pushMsg(result.toJSONString());
+        getChatName(result.toJSONString());
         return null;
     }
 
-    public void pushMsg(String msg){
-        msg="{\"msgid\":\"1634016854685227651_1749628622146_external\",\"action\":\"send\"," +
-                "\"from\":\"wopeIoCwAArS1POCA5Fiw6VidWWqkwVA\",\"tolist\":[\"KaKa\"],\"roomid\":\"\",\"msgtime\":1749628618742,\"msgtype\":\"text\",\"" +
-                "text\":{\"content\":\"您好,请详细描述您的问题,以便更快得到解答!\"}}";
-        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(msg);
-        //直接转成对象
-        ChatMsg chatMsg = new ChatMsg(jsonObject);
-        System.out.println(chatMsg);
-        String msgIdSub = chatMsg.getMsgid().substring(0, 2);
+    @Override
+    public String getChatName(String msg) {
+//        msg="{\"msgid\":\"1634016854685227651_1749628622146_external\",\"action\":\"send\"," +
+//                "\"from\":\"wopeIoCwAArS1POCA5Fiw6VidWWqkwVA\",\"tolist\":[\"KaKa\"],\"roomid\":\"\",\"msgtime\":1749628618742,\"msgtype\":\"text\",\"" +
+//                "text\":{\"content\":\"您好,请详细描述您的问题,以便更快得到解答!\"}}";
+//        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(msg);
+//        //直接转成对象
+//        InputChatMsg chatMsg = new InputChatMsg(jsonObject);
+        String msgIdSub = msg.substring(0, 2);
         String url=null;
         if (msgIdSub.equals("wb")){
-            System.out.println("wb=机器人");
-            url=String.format("https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_robot_info??access_token=%s&robot_id=%s",getAccessToken(),chatMsg.getFrom());
-        }else if (msgIdSub.equals("wo")||msgIdSub.equals("wm")){
-            System.out.println("wo=外部联系人");
-            url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAccessToken(),chatMsg.getFrom());
+            url=String.format("https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_robot_info??access_token=%s&robot_id=%s",getAccessToken(),msg);
+        }else if (msgIdSub.equals("wo")){
+        //     https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid=EXTERNAL_USERID&cursor=CURSOR
+            url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAccessToken(),msg);
+        }else if (msgIdSub.equals("wm")){
+            url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAccessToken(),msg);
         }else {
-            System.out.println("=内部联系人");
-            url=String.format("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=%s&userid=%s",getAccessToken(),chatMsg.getFrom());
+            url=String.format("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=%s&userid=%s",getAccessToken(),msg);
         }
-        getUserData(url);
+        String userName = getUserName(url);
+        System.out.println(msg+"="+userName);
+        return userName;
     }
 
 
-    private void getUserData(String url){
-        System.out.println("url="+ url);
+    private String getUserName(String url){
         com.alibaba.fastjson.JSONObject result = HttpUtils.httpGet(url);
         if (result.getInteger("errcode")==0){
             System.out.println(result.toJSONString());
+            return result.getString("name");
         }else {
             System.out.println(result.toJSONString());
             System.out.println("获取会话内容存档成员列表失败");
         }
-
+        return null;
     }
 
 

+ 1 - 3
src/main/java/com/tencent/wework/Finance.java

@@ -138,10 +138,8 @@ public class Finance {
 //            System.out.println(System.getProperty("java.library.path"));
 //            System.loadLibrary("WeWorkFinanceSdk");
             String path="";
-            System.out.println(Finance.class.getResource("").getPath());
-            System.load(path.concat("C:\\gitProject\\kede-officialWeb-HN\\src\\main\\resources\\lib\\libcrypto-1_1-x64.dll"));
+            System.load(path.concat("C:\\gitProject\\kede-officialWeb-HN\\src\\main\\resources\\lib\\libcrypto-3-x64.dll"));
             System.load(path.concat("C:\\gitProject\\kede-officialWeb-HN\\src\\main\\resources\\lib\\libcurl-x64.dll"));
-            System.load(path.concat("C:\\gitProject\\kede-officialWeb-HN\\src\\main\\resources\\lib\\libssl-1_1-x64.dll"));
             System.load(path.concat("C:\\gitProject\\kede-officialWeb-HN\\src\\main\\resources\\lib\\WeWorkFinanceSdk.dll"));
         } else if (osname.contains("Linux")) {
             System.out.println("系统为Linux");

BIN
src/main/resources/lib/libcrypto-1_1-x64.dll


BIN
src/main/resources/lib/libssl-1_1-x64.dll