Jelajahi Sumber

人工客服统计 查询用户逻辑调整:先获取所有的去重的ID,而不再是通过ID和name去重,然后再获取最新的用户名,防止用户改名

王苗苗 2 bulan lalu
induk
melakukan
0316fa253f

+ 2 - 0
slibra-system/src/main/java/com/slibra/business/mapper/TCallRecordMapper.java

@@ -94,4 +94,6 @@ public interface TCallRecordMapper
     int getCountByTypeAndDate(@Param("category") int category, @Param("date") String date, @Param("userId") String userId);
 
     int getPersonCountByType(int type);
+
+    List<CallUserCountInfo> selectAllPersonUserIds();
 }

+ 15 - 1
slibra-system/src/main/java/com/slibra/business/service/impl/TCallRecordServiceImpl.java

@@ -13,10 +13,12 @@ import com.slibra.business.mapper.TUserInfoMapper;
 import com.slibra.business.res.CallRecordCount;
 import com.slibra.business.res.CallUserCountInfo;
 import com.slibra.common.DecimalUtils;
+import com.slibra.common.core.domain.entity.SysUser;
 import com.slibra.common.exception.ServiceException;
 import com.slibra.common.utils.DateUtils;
 import com.slibra.common.utils.SecurityUtils;
 import com.slibra.common.utils.StringUtils;
+import com.slibra.system.mapper.SysUserMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -72,6 +74,9 @@ public class TCallRecordServiceImpl implements ITCallRecordService
     @Autowired
     @Qualifier("qiNiuYunServiceNew")
     QiNiuYunServiceImpl qiNiuYunService;
+
+    @Autowired
+    private SysUserMapper sysUserMapper;
     /**
      * 查询通话记录
      * 
@@ -335,7 +340,9 @@ public class TCallRecordServiceImpl implements ITCallRecordService
     @Override
     public List<CallUserCountInfo> userCallCount() {
         //先获取所有的人工信息 再查状态 再统计数据
-        List<CallUserCountInfo> result = this.tCallRecordMapper.selectAllUsersByType(0);
+        //2025年01月07日09:50:29 逻辑调整:因为人工会改名字,机器人客服不会,所以人工只获取ID,再额外查询一次最新的名字,机器人则不需要
+//        List<CallUserCountInfo> result = this.tCallRecordMapper.selectAllUsersByType(0);
+        List<CallUserCountInfo> result = this.tCallRecordMapper.selectAllPersonUserIds();
         String date = DateUtils.getDate();
         if(!CollectionUtils.isEmpty(result)){
             for (CallUserCountInfo callUserCountInfo : result) {
@@ -343,6 +350,13 @@ public class TCallRecordServiceImpl implements ITCallRecordService
                     log.error("统计人工客服数据的时候,存在姓名和ID全部为空的异常数据,跳过此次统计");
                     continue;
                 }
+                try {
+                    SysUser sysUser = this.sysUserMapper.selectUserById(Long.valueOf(callUserCountInfo.getUserId()));
+                    if(!Objects.isNull(sysUser))
+                        callUserCountInfo.setUserName(sysUser.getNickName());
+                } catch (NumberFormatException e) {
+                    log.error("统计人工客服信息时,获取人工信息失败,异常信息为{}", e.getMessage());
+                }
                 String userId = callUserCountInfo.getUserId();
                 if(StringUtils.isNotBlank(userId)){
                     callUserCountInfo.setStatus(this.parseStatus(this.tCallRecordMapper.getStatusByUserId(userId)));

+ 13 - 0
slibra-system/src/main/resources/mapper/business/TCallRecordMapper.xml

@@ -313,6 +313,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="type == 1 "> and service_category != 0 </if>
     </select>
 
+    <select id="selectAllPersonUserIds" resultType="com.slibra.business.res.CallUserCountInfo">
+        SELECT DISTINCT
+        user_id userId
+        FROM
+        t_call_record
+        WHERE
+        1 = 1
+        AND del_flag = 0
+        AND user_id IS NOT NULL
+        AND user_id != ''
+        and service_category = 0
+    </select>
+
     <select id="getStatusByUserId" resultType="java.lang.Integer">
         SELECT
             service_state