王苗苗 пре 2 дана
родитељ
комит
f97aaebf02

+ 14 - 12
slibra-admin/src/main/java/com/slibra/web/controller/business/FrontController.java

@@ -7,8 +7,10 @@ import com.slibra.business.domain.TPumpingStationNeighbourhoodNumber;
 import com.slibra.business.mapper.*;
 import com.slibra.business.req.AiChatReq;
 import com.slibra.business.req.AiChatRes;
+import com.slibra.business.res.CallRecordCount;
 import com.slibra.business.res.PumpAndNumber;
 import com.slibra.business.service.IFrontService;
+import com.slibra.business.service.ITCallRecordService;
 import com.slibra.business.service.ITNeighborhoodService;
 import com.slibra.common.core.controller.BaseController;
 import com.slibra.common.core.domain.AjaxResult;
@@ -40,19 +42,8 @@ public class FrontController extends BaseController {
     private TCallRecordMapper tCallRecordMapper;
 
     @Autowired
-    private TCutOffWaterMapper tCutOffWaterMapper;
+    private ITCallRecordService itCallRecordService;
 
-    @Autowired
-    private TNeighborhoodBuildingMapper tNeighborhoodBuildingMapper;
-
-    @Autowired
-    private TNeighborhoodMapper tNeighborhoodMapper;
-
-    @Autowired
-    private TPumpingStationMapper tPumpingStationMapper;
-
-    @Autowired
-    private TPumpingStationNeighbourhoodNumberMapper tPumpingStationNeighbourhoodNumberMapper;
 
 
 
@@ -85,6 +76,17 @@ public class FrontController extends BaseController {
     }
 
 
+    /**
+     * 通话统计接口
+     * @return
+     */
+    @GetMapping("/callRecordCountInfo")
+    public R<CallRecordCount> callRecordCountInfo(){
+        log.info("进入了 通话统计接口 接口");
+        return R.ok(this.itCallRecordService.callRecordCountInfo());
+    }
+
+
 
 //    /**
 //     * 获取大屏的实时数据 + 统计数据

+ 25 - 25
slibra-system/src/main/java/com/slibra/business/mapper/CityMapper.java

@@ -33,29 +33,29 @@ public interface CityMapper
      * @param city 全国省市区数据
      * @return 结果
      */
-    public int insertCity(City city);
-
-    /**
-     * 修改全国省市区数据
-     * 
-     * @param city 全国省市区数据
-     * @return 结果
-     */
-    public int updateCity(City city);
-
-    /**
-     * 删除全国省市区数据
-     * 
-     * @param id 全国省市区数据主键
-     * @return 结果
-     */
-    public int deleteCityById(String id);
-
-    /**
-     * 批量删除全国省市区数据
-     * 
-     * @param ids 需要删除的数据主键集合
-     * @return 结果
-     */
-    public int deleteCityByIds(String[] ids);
+//    public int insertCity(City city);
+//
+//    /**
+//     * 修改全国省市区数据
+//     *
+//     * @param city 全国省市区数据
+//     * @return 结果
+//     */
+//    public int updateCity(City city);
+//
+//    /**
+//     * 删除全国省市区数据
+//     *
+//     * @param id 全国省市区数据主键
+//     * @return 结果
+//     */
+//    public int deleteCityById(String id);
+//
+//    /**
+//     * 批量删除全国省市区数据
+//     *
+//     * @param ids 需要删除的数据主键集合
+//     * @return 结果
+//     */
+//    public int deleteCityByIds(String[] ids);
 }

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

@@ -72,4 +72,18 @@ public interface TCallRecordMapper
     int getCallCountsByPhone(String phone);
 
     List<TCallRecord> selectHistoriesByPhone(@Param("phone") String phone, @Param("id") Long id);
+
+    int getTotalByType(Integer type);
+
+    int getTotalByIsAi(int businessType);
+
+    int getSpecialCount();
+
+    int getTransferCount();
+
+    int getPersonCountByState(Integer state);
+
+    int getPersonCountRecordIsRobot(int type);
+
+    long getPersonTotalRecordIsRobot(int type);
 }

+ 99 - 0
slibra-system/src/main/java/com/slibra/business/res/CallRecordCount.java

@@ -0,0 +1,99 @@
+package com.slibra.business.res;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Builder
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+//通话记录统计相关的bean
+public class CallRecordCount {
+
+    //累计电话量
+    private int total;
+
+
+    //------传统客服------
+    //电话量
+    private int humanTotal;
+
+    //总量占比
+    private Double humanPercent;
+
+
+    //------AI客服开始------
+    //------白名单直呼------
+    //电话量
+    private int whiteListTotal;
+
+    //总量占比
+    private Double whiteListPercent;
+
+
+    //------AI机器人------
+    //电话量
+    private int aiTotal;
+
+    //总量占比
+    private Double aiPercent;
+
+    //------传统服务------
+    //电话量
+    private int traditionTotal;
+
+    //总量占比
+    private Double traditionPercent;
+
+    //12345转入次数
+    private int specialCount;
+
+    //转人工次数
+    private int transferCount;
+    //------AI客服结束------
+
+    //------人工客服状态开始------
+    //登录总数
+    private int totalPerson;
+
+    //置闲数
+    private int idlePerson;
+
+    //置忙数
+    private int busyPerson;
+
+    //通话中数
+    private int onlinePerson;
+
+    //拨号中数
+    private int dialPerson;
+
+    //累计通话
+    private int personCount;
+
+    //累计通话时长
+    private long personTotal;
+    //------人工客服状态结束------
+
+
+    //------机器人客服状态开始------
+    //在线
+    private int robotOnLineCount = 8;
+
+    //异常
+    private int robotExceptionCount = 0;
+
+    //转人工
+    private int robotTransfer;
+
+    //累计通话
+    private int robotCount;
+
+    //累计通话时长
+    private long robotTotal;
+
+    //------机器人客服状态结束------
+}
+

+ 3 - 0
slibra-system/src/main/java/com/slibra/business/service/ITCallRecordService.java

@@ -4,6 +4,7 @@ import java.util.HashMap;
 import java.util.List;
 
 import com.slibra.business.domain.TCallRecord;
+import com.slibra.business.res.CallRecordCount;
 
 /**
  * 通话记录Service接口
@@ -68,4 +69,6 @@ public interface ITCallRecordService
     String updateFile2TextById(Long id);
 
     String updateFile2TextByIdOneLine(Long id);
+
+    CallRecordCount callRecordCountInfo();
 }

+ 45 - 0
slibra-system/src/main/java/com/slibra/business/service/impl/TCallRecordServiceImpl.java

@@ -10,6 +10,8 @@ import com.slibra.business.domain.TCutOffWater;
 import com.slibra.business.domain.TUserInfo;
 import com.slibra.business.mapper.TCutOffWaterMapper;
 import com.slibra.business.mapper.TUserInfoMapper;
+import com.slibra.business.res.CallRecordCount;
+import com.slibra.common.DecimalUtils;
 import com.slibra.common.exception.ServiceException;
 import com.slibra.common.utils.DateUtils;
 import com.slibra.common.utils.SecurityUtils;
@@ -22,6 +24,7 @@ import com.slibra.business.mapper.TCallRecordMapper;
 import com.slibra.business.domain.TCallRecord;
 import com.slibra.business.service.ITCallRecordService;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.NumberUtils;
 
 import static com.slibra.common.constant.MyConstants.LONG_1;
 
@@ -251,6 +254,48 @@ public class TCallRecordServiceImpl implements ITCallRecordService
         return result;
     }
 
+    @Override
+    public CallRecordCount callRecordCountInfo() {
+        CallRecordCount callRecordCount = CallRecordCount.builder().build();
+        //处理通话统计信息
+        int total = this.tCallRecordMapper.getTotalByType(null);
+        callRecordCount.setTotal(total);
+        int humanTotal = this.tCallRecordMapper.getTotalByType(2);
+        callRecordCount.setHumanTotal(humanTotal);
+        int whiteListTotal = this.tCallRecordMapper.getTotalByType(0);
+        callRecordCount.setWhiteListTotal(whiteListTotal);
+        int aiTotal = this.tCallRecordMapper.getTotalByIsAi(1);
+        callRecordCount.setAiTotal(aiTotal);
+        int traditionTotal = this.tCallRecordMapper.getTotalByIsAi(0);
+        callRecordCount.setTraditionTotal(traditionTotal);
+        if(total > 0){
+            callRecordCount.setHumanPercent((double) (humanTotal / total));
+            callRecordCount.setWhiteListPercent((double) (whiteListTotal / total));
+            callRecordCount.setAiPercent((double) (aiTotal / total));
+            callRecordCount.setTraditionPercent((double) (traditionTotal / total));
+        }
+        callRecordCount.setSpecialCount(this.tCallRecordMapper.getSpecialCount());
+        int transferCount = this.tCallRecordMapper.getTransferCount();
+        callRecordCount.setTransferCount(transferCount);
+        //处理人工客服状态统计信息
+        callRecordCount.setTotalPerson(this.tCallRecordMapper.getPersonCountByState(null));
+        callRecordCount.setIdlePerson(this.tCallRecordMapper.getPersonCountByState(2));
+        callRecordCount.setBusyPerson(this.tCallRecordMapper.getPersonCountByState(1));
+        callRecordCount.setOnlinePerson(this.tCallRecordMapper.getPersonCountByState(3));
+        callRecordCount.setDialPerson(this.tCallRecordMapper.getPersonCountByState(5));
+
+        //通话次数和通话时长
+        callRecordCount.setPersonCount(this.tCallRecordMapper.getPersonCountRecordIsRobot(0));
+        callRecordCount.setPersonTotal(this.tCallRecordMapper.getPersonTotalRecordIsRobot(0));
+
+        callRecordCount.setRobotCount(this.tCallRecordMapper.getPersonCountRecordIsRobot(1));
+        callRecordCount.setRobotTotal(this.tCallRecordMapper.getPersonTotalRecordIsRobot(1));
+        //转人工次数
+        callRecordCount.setRobotTransfer(transferCount);
+
+        return callRecordCount;
+    }
+
 
     /**
      * 校验数据

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

@@ -204,4 +204,79 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectTCallRecordVo"/>
         where phone = #{phone} and del_flag = 0 and id != #{id}
     </select>
+
+
+    <select id="getTotalByType" resultType="int">
+        SELECT
+            COUNT(*)
+        FROM
+            t_call_record
+        WHERE
+            1 = 1 AND del_flag = 0
+        <if test="type != null "> and type = #{type}</if>
+    </select>
+
+
+    <select id="getTotalByIsAi" resultType="int">
+        SELECT
+        COUNT(*)
+        FROM
+        t_call_record
+        WHERE
+        1 = 1 and  type = 1 AND del_flag = 0
+        <if test="businessType == 1 "> and (bussiness_type != '不体验AI服务' or bussiness_type is NULL or bussiness_type = '')</if>
+        <if test="businessType == 0 "> and bussiness_type = '不体验AI服务'</if>
+    </select>
+
+    <select id="getSpecialCount" resultType="int">
+        SELECT
+            COUNT(*)
+        FROM
+            t_call_record
+        WHERE
+            1 = 1 and phone = '12345' AND del_flag = 0
+    </select>
+
+    <select id="getTransferCount" resultType="int">
+        SELECT
+            COUNT(*)
+        FROM
+            t_call_record
+        WHERE
+            1 = 1 and service_category = 2 AND del_flag = 0
+    </select>
+
+    <select id="getPersonCountByState" resultType="int">
+        SELECT
+            COUNT(*)
+        FROM
+            c_agent_monitor
+        WHERE
+            1 = 1
+        <if test="state != null "> and service_state = #{state}</if>
+    </select>
+
+    <select id="getPersonCountRecordIsRobot" resultType="int">
+        SELECT
+            COUNT(*)
+        FROM
+            t_call_record
+        WHERE
+            1 = 1
+          AND del_flag = 0
+        <if test="type == 0 "> and service_category = 0</if>
+        <if test="type == 1 "> and service_category != 0 </if>
+    </select>
+
+    <select id="getPersonTotalRecordIsRobot" resultType="long">
+        SELECT
+        SUM(times)
+        FROM
+        t_call_record
+        WHERE
+        1 = 1
+        AND del_flag = 0
+        <if test="type == 0 "> and service_category = 0</if>
+        <if test="type == 1 "> and service_category != 0 </if>
+    </select>
 </mapper>