Ver código fonte

新增内蒙会话内容存档

anderx 5 meses atrás
pai
commit
b621296734

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

@@ -81,7 +81,7 @@ public interface ChatMsgUserMapper {
      */
     int deleteById(Integer id);
 
-    ChatMsgUser selectByUserId(String userId);
+    ChatMsgUser selectByUserId(@Param("userId")String userId,@Param("provinceType")Integer provinceType);
 
     List<ChatMsgUser> getUserList(@Param("type")Integer type,@Param("provinceType")Integer provinceType);
 

+ 50 - 34
src/main/java/com/kede/common/mapper/ChatMsgUserMapper.xml

@@ -8,10 +8,11 @@
         <result property="name" column="name" jdbcType="VARCHAR"/>
         <result property="type" column="type" jdbcType="INTEGER"/>
         <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="provinceType" column="province_type" jdbcType="INTEGER"/>
     </resultMap>
 
     <sql id="ChatMsgUserAllSql">
-        id, user_id, name, type, create_time
+        id, user_id, name, type, create_time, province_type
     </sql>
 
     <!--查询单个-->
@@ -24,29 +25,30 @@
 
     <!--新增所有列-->
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
-        insert into chat_msg_user(user_id, name, type, create_time)
-        values (#{userId}, #{name}, #{type}, #{createTime})
+        insert into chat_msg_user(user_id, name, type, create_time, province_type)
+        values (#{userId}, #{name}, #{type}, #{createTime}, #{provinceType})
     </insert>
 
     <insert id="insertBatch">
-        insert into chat_msg_user(user_id, name, type, create_time)
+        insert into chat_msg_user(user_id, name, type, create_time, province_type)
         values
         <foreach collection="entities" item="entity" separator=",">
-            (#{entity.userId}, #{entity.name}, #{entity.type}, #{entity.createTime})
+            (#{entity.userId}, #{entity.name}, #{entity.type}, #{entity.createTime}, #{entity.provinceType})
         </foreach>
     </insert>
 
     <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
-        insert into chat_msg_user(user_id, name, type, create_time)
+        insert into chat_msg_user(user_id, name, type, create_time, province_type)
         values
         <foreach collection="entities" item="entity" separator=",">
-            (#{entity.userId}, #{entity.name}, #{entity.type}, #{entity.createTime})
+            (#{entity.userId}, #{entity.name}, #{entity.type}, #{entity.createTime}, #{entity.provinceType})
         </foreach>
         on duplicate key update
         user_id = values(user_id),
         name = values(name),
         type = values(type),
-        create_time = values(create_time)
+        create_time = values(create_time),
+        province_type = values(province_type)
     </insert>
 
     <!--通过主键修改数据-->
@@ -65,6 +67,9 @@
             <if test="createTime != null">
                 create_time = #{createTime},
             </if>
+            <if test="provinceType != null">
+                province_type = #{provinceType},
+            </if>
         </set>
         where id = #{id}
     </update>
@@ -91,6 +96,9 @@
             <if test="createTime != null">
                 and create_time = #{createTime}
             </if>
+            <if test="provinceType != null">
+                and province_type = #{provinceType}
+            </if>
         </where>
         <if test="page_sql != null">
             ${page_sql}
@@ -117,16 +125,19 @@
             <if test="createTime != null">
                 and create_time = #{createTime}
             </if>
+            <if test="provinceType != null">
+                and province_type = #{provinceType}
+            </if>
         </where>
     </select>
 
-
     <!--通过主键删除-->
     <delete id="deleteById">
         delete
         from chat_msg_user
         where id = #{id}
     </delete>
+
     <delete id="deleteByUserId">
         delete
         from chat_msg_user
@@ -138,54 +149,59 @@
         <include refid="ChatMsgUserAllSql"/>
         from chat_msg_user
         where user_id = #{id}
+        <if test="provinceType != null">
+            and province_type = #{provinceType}
+        </if>
     </select>
     <select id="getUserList" resultMap="ChatMsgUserMap">
         select
         <include refid="ChatMsgUserAllSql"/>
         from chat_msg_user
         <where>
-        <if test="type != null">
-            and type = #{type}
-        </if>
-        <if test="provinceType != null">
-            and province_type = #{provinceType}
-        </if>
+            <if test="type != null">
+                and type = #{type}
+            </if>
+            <if test="provinceType != null">
+                and province_type = #{provinceType}
+            </if>
         </where>
     </select>
     <select id="selectMyIdByUser" resultMap="ChatMsgUserMap">
         select x.user_id,b.name
         from (select tolist user_id
-              from chat_msg
-              where from_id = #{userId} and type=0
-              <if test="startTime != null and startTime != ''">
-                  and msgtime between  #{startTime} and #{endTime}
-              </if>
-              union
-              select from_id user_id
-              from chat_msg
-              where find_in_set(#{userId},tolist) and type=0
-                <if test="startTime != null and startTime != ''">
-                    and msgtime between  #{startTime} and #{endTime}
-                </if>
-              )x left join chat_msg_user b on x.user_id=b.user_id
+        from chat_msg
+        where from_id = #{userId} and type=0
+        <if test="startTime != null and startTime != ''">
+            and msgtime between  #{startTime} and #{endTime}
+        </if>
+        union
+        select from_id user_id
+        from chat_msg
+        where find_in_set(#{userId},tolist) and type=0
+        <if test="startTime != null and startTime != ''">
+            and msgtime between  #{startTime} and #{endTime}
+        </if>
+        )x left join chat_msg_user b on x.user_id=b.user_id
     </select>
     <select id="selectMyIdByRoom" resultType="com.kede.common.model.ChatMsgUser">
         select x.roomid userId,b.name
         from (select roomid
-              from chat_msg
-              where from_id = #{userId} and type=1
+        from chat_msg
+        where from_id = #{userId} and type=1
         <if test="startTime != null and startTime != ''">
             and msgtime between  #{startTime} and #{endTime}
         </if>
         union
-              select roomid
-              from chat_msg
-              where find_in_set(#{userId},tolist) and type=1
+        select roomid
+        from chat_msg
+        where find_in_set(#{userId},tolist) and type=1
         <if test="startTime != null and startTime != ''">
             and msgtime between  #{startTime} and #{endTime}
         </if>
-              )x left join chat_msg_user b on x.roomid=b.user_id
+        )x left join chat_msg_user b on x.roomid=b.user_id
     </select>
 
 </mapper>
 
+
+

+ 17 - 5
src/main/java/com/kede/common/model/ChatMsgUser.java

@@ -8,28 +8,32 @@ import java.io.Serializable;
  * 微信会话存储对象名称(ChatMsgUser)实体类
  *
  * @author makejava
- * @since 2025-06-17 14:44:32
+ * @since 2025-07-14 14:23:32
  */
 public class ChatMsgUser implements Serializable {
-    private static final long serialVersionUID = -13552348943109897L;
+    private static final long serialVersionUID = 981741379208488697L;
 
     private Integer id;
     /**
-     * 编号
+     * 接受人编号或群编号
      */
     private String userId;
     /**
-     * 称
+     * 
      */
     private String name;
     /**
-     * 会话信息编号 0=机器人,1=外部联系人,2=内部联系人
+     * 会话信息编号 0=机器人,1=外部联系人,2=内部联系人,3=群名称
      */
     private Integer type;
     /**
      * 创建时间
      */
     private Date createTime;
+    /**
+     * 省份 0=湖南,1=内蒙
+     */
+    private Integer provinceType;
 
 
     public Integer getId() {
@@ -72,5 +76,13 @@ public class ChatMsgUser implements Serializable {
         this.createTime = createTime;
     }
 
+    public Integer getProvinceType() {
+        return provinceType;
+    }
+
+    public void setProvinceType(Integer provinceType) {
+        this.provinceType = provinceType;
+    }
+
 }
 

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

@@ -147,12 +147,13 @@ public class ConversationContentTask {
             }
             in.setRoomName(roomName);
             if (StringUtils.isNotBlank(chatMsg.getRoomid())){
-                ChatMsgUser chatMsgUser = chatMsgUserMapper.selectByUserId(chatMsg.getRoomid());
+                ChatMsgUser chatMsgUser = chatMsgUserMapper.selectByUserId(chatMsg.getRoomid(),chatMsg.getProvinceType());
                 if (chatMsgUser == null&&roomName!=null){
                     ChatMsgUser cmu = new ChatMsgUser();
                     cmu.setUserId(chatMsg.getRoomid());
                     cmu.setName(roomName);
                     cmu.setType(3);
+                    cmu.setProvinceType(chatMsg.getProvinceType());
                     cmu.setCreateTime(new Date());
                     chatMsgUserMapper.insert(cmu);
                 }

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

@@ -560,7 +560,7 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
     public Map<String,Object> pushGetChatName(String userId, Integer type) {
         Map<String,Object> map = new HashMap<>();
         Integer i =  0;
-        ChatMsgUser chatMsgUser = chatMsgUserMapper.selectByUserId(userId);
+        ChatMsgUser chatMsgUser = chatMsgUserMapper.selectByUserId(userId, type);
         if (chatMsgUser != null){
             map.put("name",chatMsgUser.getName());
             map.put("code",i);
@@ -618,7 +618,7 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
         String roomname=null;
                         //        https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/get?access_token=ACCESS_TOKEN
         String roomid = chatMsg.getRoomid();
-        ChatMsgUser chatMsgUser = chatMsgUserMapper.selectByUserId(roomid);
+        ChatMsgUser chatMsgUser = chatMsgUserMapper.selectByUserId(roomid, type);
         if (chatMsgUser != null){
             return chatMsgUser.getName();
         }else {