Kaynağa Gözat

会话审计

cgp 1 hafta önce
ebeveyn
işleme
f7896fa752

+ 8 - 0
fs-admin/src/main/java/com/fs/company/controller/CompanyUserController.java

@@ -118,6 +118,14 @@ public class CompanyUserController extends BaseController
         List<CompanyUser> list = companyUserService.selectCompanyUserList(map);
         return R.ok().put("data",list);
     }
+
+    @GetMapping("/getAllCompanyUserListNoParams")
+    public R getAllCompanyUserListNoParams()
+    {
+        List<CompanyUser> list = companyUserService.getAllCompanyUserListNoParams();
+        return R.ok().put("data",list);
+    }
+
     @GetMapping("/getAllUserListLimit")
     public R getAllUserListLimit(@RequestParam(required = false) Long companyId,
                                  @RequestParam(required = false) String keywords){

+ 5 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyUserService.java

@@ -314,4 +314,9 @@ public interface ICompanyUserService {
     int countCompanyUserByUserId(Long userId);
 
     List<VcCompanyUser> selectVcCompanyUserList(List<Long> userIds);
+
+    /**
+     * 获取所有公司员工列表
+     * */
+    List<CompanyUser> getAllCompanyUserListNoParams();
 }

+ 12 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java

@@ -55,6 +55,7 @@ import com.fs.system.service.ISysUserService;
 import com.fs.voice.utils.StringUtil;
 import com.fs.wxUser.domain.CompanyWxUser;
 import com.github.pagehelper.PageHelper;
+import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -1233,4 +1234,15 @@ public class CompanyUserServiceImpl implements ICompanyUserService
         return companyFsUserMapper.selectVcCompanyUserList(userIds);
     }
 
+    @Override
+    public List<CompanyUser> getAllCompanyUserListNoParams() {
+        CompanyUser companyUser=new CompanyUser();
+        companyUser.setStatus("0");
+        List<CompanyUser> companyUserList = companyUserMapper.selectCompanyUserList(companyUser);
+        if (CollectionUtils.isEmpty(companyUserList)){
+            return Collections.emptyList();
+        }
+        return companyUserList;
+    }
+
 }

+ 1 - 1
fs-service/src/main/java/com/fs/qw/dto/SearchMsgRequest.java

@@ -21,7 +21,7 @@ public class SearchMsgRequest {
     private Long startTime;          // 起始时间戳(秒)
     private Long endTime;            // 结束时间戳(秒),范围不超过31天
 
-    // 分页
+    // 游标分页
     private Integer limit = 50;      // 每页数量,最大100
     private String cursor;           // 翻页游标
 

+ 5 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwConversationMessageMapper.java

@@ -65,4 +65,9 @@ public interface QwConversationMessageMapper {
      * @return 消息列表
      */
     List<QwConversationMessage> selectByMsgIds(@Param("corpId") String corpId, @Param("msgIds") List<String> msgIds);
+
+    /**
+     *  批量根据msgid查询消息,并排序
+     * */
+    List<QwConversationMessage> selectByMsgIdsOrderByMsgId(@Param("corpId") String corpId, @Param("msgIds") List<String> msgIds);
 }

+ 28 - 18
fs-service/src/main/java/com/fs/qw/service/impl/ICorporateWeChatSpaceServiceImpl.java

@@ -27,8 +27,10 @@ import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -212,20 +214,18 @@ public class ICorporateWeChatSpaceServiceImpl implements ICorporateWeChatSpaceSe
         JSONObject requestData = new JSONObject();
         requestData.put("query_word", request.getQueryWord());
 
-        // 构造 chat_info
+        // 构造 chat_info(与之前相同,省略)
         if (request.getChatType() != null) {
             JSONObject chatInfo = new JSONObject();
             chatInfo.put("chat_type", request.getChatType());
-
-            if (request.getChatType() == 1) { // 单聊
+            if (request.getChatType() == 1) {
                 JSONArray idList = new JSONArray();
                 idList.add(new JSONObject().fluentPut("open_userid", request.getStaffUserId()));
                 idList.add(new JSONObject().fluentPut("external_userid", request.getCustomerId()));
                 chatInfo.put("id_list", idList);
-            } else if (request.getChatType() == 2) { // 群聊
+            } else if (request.getChatType() == 2) {
                 chatInfo.put("chat_id", request.getChatId());
             }
-
             if (request.getMsgTypeList() != null && !request.getMsgTypeList().isEmpty()) {
                 chatInfo.put("msg_type_list", request.getMsgTypeList());
             }
@@ -265,30 +265,40 @@ public class ICorporateWeChatSpaceServiceImpl implements ICorporateWeChatSpaceSe
 
         // 4. 提取 msgid 列表
         JSONArray msgListArray = respData.getJSONArray("msg_list");
-        if (msgListArray == null || msgListArray.isEmpty()) {
-            return new SearchResultVO(new JSONArray(), 0, "");
-        }
-
         List<String> msgIds = new ArrayList<>();
-        for (Object obj : msgListArray) {
-            JSONObject item = (JSONObject) obj;
-            msgIds.add(item.getString("msgid"));
+        if (msgListArray != null) {
+            for (Object obj : msgListArray) {
+                msgIds.add(((JSONObject) obj).getString("msgid"));
+            }
         }
 
-        // 5. 从本地数据库批量查询消息详情
-        List<QwConversationMessage> messages = messageMapper.selectByMsgIds(request.getCorpId(), msgIds);
-        if (messages.isEmpty()) {
-            return new SearchResultVO(new JSONArray(), respData.getIntValue("has_more"), respData.getString("next_cursor"));
+        // 5. 从本地数据库查询消息详情(按 msgid 顺序)
+        List<QwConversationMessage> messages = new ArrayList<>();
+        if (!msgIds.isEmpty()) {
+            // 注意:selectByMsgIds 应保持与 msgIds 相同的顺序(可额外排序)
+            messages = messageMapper.selectByMsgIdsOrderByMsgId(request.getCorpId(), msgIds);
+            // 如果 mapper 不支持顺序,可手动排序
+            Map<String, QwConversationMessage> msgMap = messages.stream()
+                    .collect(Collectors.toMap(QwConversationMessage::getMsgid, Function.identity()));
+            List<QwConversationMessage> ordered = new ArrayList<>();
+            for (String id : msgIds) {
+                QwConversationMessage m = msgMap.get(id);
+                if (m != null) ordered.add(m);
+            }
+            messages = ordered;
         }
 
-        // 6. 构建返回数据
+        // 6. 构建返回数据(格式与 fetchConversations 保持一致)
         JSONArray resultList = new JSONArray();
         for (QwConversationMessage msg : messages) {
             JSONObject item = buildMessageJson(msg, request.getCorpId());
             resultList.add(item);
         }
 
-        return new SearchResultVO(resultList, respData.getIntValue("has_more"), respData.getString("next_cursor"));
+        // 7. 返回游标分页结果
+        Integer hasMore = respData.getIntValue("has_more");
+        String nextCursor = respData.getString("next_cursor");
+        return new SearchResultVO(resultList, hasMore, nextCursor);
     }
 
     /**

+ 3 - 3
fs-service/src/main/java/com/fs/qw/vo/SearchResultVO.java

@@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
 @NoArgsConstructor
 @AllArgsConstructor
 public class SearchResultVO {
-    private JSONArray data;        // 消息列表
-    private Integer hasMore;       // 0-否 1-是
-    private String nextCursor;     // 下一页游标
+    private JSONArray data;      // 消息列表
+    private Integer hasMore;     // 0-无更多 1-还有更多
+    private String nextCursor;   // 下一页游标
 }

+ 14 - 0
fs-service/src/main/resources/mapper/qw/QwConversationMessageMapper.xml

@@ -131,4 +131,18 @@
             #{msgid}
         </foreach>
     </select>
+
+    <select id="selectByMsgIdsOrderByMsgId" resultType="com.fs.qw.domain.QwConversationMessage">
+        <include refid="Base_Column_List"/>
+        WHERE corp_id = #{corpId}
+        AND msgid IN
+        <foreach collection="msgIds" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        ORDER BY FIELD(msgid,
+        <foreach collection="msgIds" item="id" separator=",">
+            #{id}
+        </foreach>
+        )
+    </select>
 </mapper>

+ 0 - 1
fs-service/src/main/resources/mapper/qw/QwUserMapper.xml

@@ -363,7 +363,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         q.id,
         q.qw_user_id AS qwUserId,
         q.qw_user_name AS qwUserName,
-        <!-- 使用 MAX 聚合函数,防止一对多关联导致数据重复 -->
         MAX(cu.nick_name) AS nickName,
         MAX(cd.dept_name) AS departmentName
         FROM