Parcourir la source

大屏接口完善

王苗苗 il y a 3 mois
Parent
commit
832ed42978

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

@@ -58,4 +58,6 @@ public interface TBucketRecordMapper
      * @return 结果
      */
     public int deleteTBucketRecordByIds(Long[] ids);
+
+    TBucketRecord selectNewest();
 }

+ 11 - 1
slibra-system/src/main/java/com/slibra/business/mapper/TCallRecordMapper.java

@@ -104,9 +104,19 @@ public interface TCallRecordMapper
 
     long getRecentCallTimes(String date);
 
-    int getCallInEqualsDay(String date);
+    /**
+     * type 0人工  1机器人 不传,默认所有
+     * status 0未接听 1已接通  不传,默认所有
+     * @param date
+     * @param type
+     * @param status
+     * @return
+     */
+    int getCallInEqualsDay(@Param("date") String date, @Param("type") Integer type, @Param("status") Integer status);
 
     int getCallInEqualsMonth(String month);
 
     List<Top7Res> getTop7ResListByMonthAndSize(@Param("nowMonth") String nowMonth, @Param("size") Integer size);
+
+    long getCallTimesEqualsDay(@Param("date") String date, @Param("type") Integer type);
 }

+ 5 - 5
slibra-system/src/main/java/com/slibra/business/res/HomeCountResp.java

@@ -57,7 +57,7 @@ public class HomeCountResp {
     private int robotInTotal;
 
     //通话时长
-    private int robotInTimes;
+    private long robotInTimes;
 
     //平均通话时长
     private long robotTimesAvg;
@@ -69,7 +69,7 @@ public class HomeCountResp {
     private int robotQueue;
 
     //分流比例
-    private BigDecimal robotStreamRate;
+    private Integer robotStreamRate;
     //下面是今日机器人坐席情况--截止
 
 
@@ -78,18 +78,18 @@ public class HomeCountResp {
     private int humanInTotal;
 
     //通话时长
-    private int humanInTimes;
+    private long humanInTimes;
 
     //平均通话时长
     private long humanTimesAvg;
 
-    //当前在线坐席人数
+    //当前在线坐席人数(2025年01月21日14:27:07 统计的是置闲的客服数量)
     private int onlineTotal;
 
     //当前排队总数
     private int humanQueue;
 
     //分流比例
-    private BigDecimal humanStreamRate;
+    private Integer humanStreamRate;
     //下面是今日人工坐席情况--截止
 }

+ 36 - 6
slibra-system/src/main/java/com/slibra/business/service/impl/TCallRecordServiceImpl.java

@@ -5,8 +5,10 @@ import java.math.BigDecimal;
 import java.util.*;
 
 import com.alibaba.fastjson2.JSON;
+import com.slibra.business.domain.TBucketRecord;
 import com.slibra.business.domain.TCutOffWater;
 import com.slibra.business.domain.TUserInfo;
+import com.slibra.business.mapper.TBucketRecordMapper;
 import com.slibra.business.mapper.TCutOffWaterMapper;
 import com.slibra.business.mapper.TUserInfoMapper;
 import com.slibra.business.res.*;
@@ -75,6 +77,10 @@ public class TCallRecordServiceImpl implements ITCallRecordService
 
     @Autowired
     private SysUserMapper sysUserMapper;
+
+    @Autowired
+    private TBucketRecordMapper bucketRecordMapper;
+
     /**
      * 查询通话记录
      * 
@@ -553,24 +559,24 @@ public class TCallRecordServiceImpl implements ITCallRecordService
         List<DayAndCountRes> recent7DayAndCounts = new ArrayList<>();
         List<DayAndCountRes> recent7DayAndCountsLastYear = new ArrayList<>();
         Date nowDate = DateUtils.getNowDate();
-        String date = DateUtils.getDate();
+        String nowDateStr = DateUtils.getDate();
         String sevenDaysAgo = DateUtils.plusDate(-DEFAULT_DAYS_QUERY_COUNT, nowDate, YYYY_MM_DD);
-        List<String> allDatesInRangeStr = DateUtils.getAllDatesInRangeStr(sevenDaysAgo, date);
+        List<String> allDatesInRangeStr = DateUtils.getAllDatesInRangeStr(sevenDaysAgo, nowDateStr);
         for (String todayYearDate : allDatesInRangeStr) {
             DayAndCountRes dayAndCountRes = new DayAndCountRes();
             dayAndCountRes.setDate(todayYearDate);
-            dayAndCountRes.setCount(this.tCallRecordMapper.getCallInEqualsDay(todayYearDate));
+            dayAndCountRes.setCount(this.tCallRecordMapper.getCallInEqualsDay(todayYearDate, null, null));
             recent7DayAndCounts.add(dayAndCountRes);
         }
         build.setRecent7DayAndCounts(recent7DayAndCounts);
         //近七日呼入电话量趋势--去年数据
-        String dateLastYear = DateUtils.getNYearSameDay(date, 1);
+        String dateLastYear = DateUtils.getNYearSameDay(nowDateStr, 1);
         String sevenDaysAgoLastYear = DateUtils.getNYearSameDay(sevenDaysAgo, 1);
         List<String> allDatesInRangeStrLastYear = DateUtils.getAllDatesInRangeStr(sevenDaysAgoLastYear, dateLastYear);
         for (String lastYearDate : allDatesInRangeStrLastYear) {
             DayAndCountRes dayAndCountRes = new DayAndCountRes();
             dayAndCountRes.setDate(lastYearDate);
-            dayAndCountRes.setCount(this.tCallRecordMapper.getCallInEqualsDay(lastYearDate));
+            dayAndCountRes.setCount(this.tCallRecordMapper.getCallInEqualsDay(lastYearDate, null, null));
             recent7DayAndCountsLastYear.add(dayAndCountRes);
         }
         build.setRecent7DayAndCountsLastYear(recent7DayAndCountsLastYear);
@@ -614,8 +620,32 @@ public class TCallRecordServiceImpl implements ITCallRecordService
         }
         build.setBusinessTop7(top7ResList);
         //今日机器人坐席情况
-
+        //type 0人工  1机器人  2转人工     通过service_category区分:0:0人工坐席    1:1机器人坐席 + 2机器人转人工  2:2机器人转人工
+        //status 0未接听 1已接通  不传,默认所有
+        build.setRobotInTotal(this.tCallRecordMapper.getCallInEqualsDay(nowDateStr, 1, null));
+        long robotInTimes = this.tCallRecordMapper.getCallTimesEqualsDay(nowDateStr, 1);//0人工  1机器人  2转人工     通过service_category区分:0:0人工坐席    1:1机器人坐席 + 2机器人转人工  2:2机器人转人工
+        build.setRobotInTimes(robotInTimes);
+        //获取今日已接听的机器人坐席总呼入量
+        int callInTodaySuccess = this.tCallRecordMapper.getCallInEqualsDay(nowDateStr, 1, 1);
+        if(callInTodaySuccess > 0)
+            build.setRobotTimesAvg(robotInTimes/callInTodaySuccess);
+        build.setTransfer2Human(this.tCallRecordMapper.getCallInEqualsDay(nowDateStr, 2, null));
+        build.setRobotQueue(-1);//todo 逻辑如何处理
+        TBucketRecord bucketRecord = this.bucketRecordMapper.selectNewest();
+        if(!Objects.isNull(bucketRecord)){
+            build.setRobotStreamRate(bucketRecord.getAiPercent());
+            build.setHumanStreamRate(bucketRecord.getTraditionPercent());
+        }
         //今日人工坐席情况
+        build.setHumanInTotal(this.tCallRecordMapper.getCallInEqualsDay(nowDateStr, 0, null));
+        long humanInTimes = this.tCallRecordMapper.getCallTimesEqualsDay(nowDateStr, 0);
+        build.setHumanInTimes(humanInTimes);
+        //获取今日已接听的人工坐席总呼入量
+        int callInTodaySuccessHuman = this.tCallRecordMapper.getCallInEqualsDay(nowDateStr, 0, 1);
+        if(callInTodaySuccessHuman > 0)
+            build.setHumanTimesAvg(humanInTimes/callInTodaySuccessHuman);
+        build.setOnlineTotal(this.tCallRecordMapper.getPersonCountByState(2));
+        build.setHumanQueue(-1);//todo 逻辑如何处理
         return build;
     }
 

+ 6 - 0
slibra-system/src/main/resources/mapper/business/TBucketRecordMapper.xml

@@ -92,4 +92,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <!-- 2025年01月21日14:12:46 下面是新增的SQL,不允许删除或者覆盖-->
+    <select id="selectNewest" resultMap="TBucketRecordResult">
+        <include refid="selectTBucketRecordVo"/>
+        where del_flag = 0 order by id desc limit 1
+    </select>
 </mapper>

+ 43 - 2
slibra-system/src/main/resources/mapper/business/TCallRecordMapper.xml

@@ -488,18 +488,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="getCallInEqualsDay" resultType="int">
         SELECT
-            IFNULL( SUM( times ), 0 )
+            COUNT(*)
         FROM
             t_call_record
         WHERE
             del_flag = 0
           AND category = 0
           AND DATE_FORMAT(time_begin, '%Y-%m-%d' ) = #{date}
+        <if test="type != null ">
+            <choose>
+                <when test="0 == type">
+                    AND service_category = 0
+                </when>
+                <when test="1 == type">
+                    AND (service_category = 1 OR service_category = 2)
+                </when>
+                <when test="2 == type">
+                    AND service_category = 2
+                </when>
+            </choose>
+        </if>
+        <if test="status != null ">
+            AND status = #{status}
+        </if>
     </select>
 
     <select id="getCallInEqualsMonth" resultType="int">
         SELECT
-            IFNULL( SUM( times ), 0 )
+            COUNT(*)
         FROM
             t_call_record
         WHERE
@@ -522,4 +538,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY total DESC
             LIMIT #{size}
     </select>
+
+
+    <select id="getCallTimesEqualsDay" resultType="long">
+        SELECT
+            IFNULL( SUM( times ), 0 )
+        FROM
+        t_call_record
+        WHERE
+        del_flag = 0
+        AND category = 0
+        AND DATE_FORMAT(time_begin, '%Y-%m-%d' ) = #{date}
+        <if test="type != null ">
+            <choose>
+                <when test="0 == type">
+                    AND service_category = 0
+                </when>
+                <when test="1 == type">
+                    AND (service_category = 1 OR service_category = 2)
+                </when>
+                <when test="2 == type">
+                    AND service_category = 2
+                </when>
+            </choose>
+        </if>
+    </select>
 </mapper>