Sfoglia il codice sorgente

cid外呼统计优化

zyy 1 mese fa
parent
commit
7769c5c52d

+ 36 - 0
fs-company/src/main/java/com/fs/company/controller/company/CompanyVoiceRoboticCallLogAddwxController.java

@@ -8,9 +8,12 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 import com.fs.common.utils.StringUtils;
+import com.fs.company.domain.CompanyVoiceRoboticCallLogCallphone;
 import com.fs.company.domain.CompanyWxClient;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogAddWxExportVO;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogAddwxVO;
+import com.fs.company.vo.CompanyVoiceRoboticCallLogCallPhoneVO;
+import com.fs.company.vo.CompanyVoiceRoboticCallLogCount;
 import org.springframework.beans.BeanUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -127,6 +130,39 @@ public class CompanyVoiceRoboticCallLogAddwxController extends BaseController
         return toAjax(companyVoiceRoboticCallLogAddwxService.deleteCompanyVoiceRoboticCallLogAddwxByLogIds(logIds));
     }
 
+    @PreAuthorize("@ss.hasPermi('company:sendmsglog:list')")
+    @GetMapping("/listByClientIdAndRoboticId")
+    public TableDataInfo listByClientIdAndRoboticId(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx) {
+        startPage();
+        List<CompanyVoiceRoboticCallLogAddwxVO> list = companyVoiceRoboticCallLogAddwxService.listByRoboticId(companyVoiceRoboticCallLogAddwx);
+        return getDataTable(list);
+
+    }
+
+
+    /**
+     * 加微统计数据(按照任务id分组,任务id-任务名称-查询总任务数量-成功数量)
+     */
+    @PreAuthorize("@ss.hasPermi('company:sendmsglog:list')")
+    @GetMapping("/groupList")
+    public TableDataInfo groupList(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx)
+    {
+        startPage();
+        List<CompanyVoiceRoboticCallLogAddwx> list = companyVoiceRoboticCallLogAddwxService.selectCompanyVoiceRoboticAddwxLogGroupList(companyVoiceRoboticCallLogAddwx);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询调用日志_发送短信列表统计数据
+     */
+    @PreAuthorize("@ss.hasPermi('company:sendmsglog:list')")
+    @GetMapping("/count")
+    public AjaxResult selectCompanyVoiceRoboticAddwxLogCount()
+    {
+        CompanyVoiceRoboticCallLogCount companyVoiceRoboticCallLogCount = companyVoiceRoboticCallLogAddwxService.selectCompanyVoiceRoboticAddwxLogCount();
+        return AjaxResult.success(companyVoiceRoboticCallLogCount);
+    }
+
 //    /**
 //     * 导出调用日志_加微信列表
 //     */

+ 3 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyVoiceRoboticCallLogAddwx.java

@@ -72,6 +72,9 @@ public class CompanyVoiceRoboticCallLogAddwx extends BaseEntity{
 
     private Integer qwWxAddWayId;
 
+    @TableField(exist = false)
+    private String successRate;
+
     public static CompanyVoiceRoboticCallLogAddwx initCallLog( String runParam, Long keyId, Long taskId,Long wxAccountId,Long companyId,int qwWxAddWayId) {
         CompanyVoiceRoboticCallLogAddwx log = new CompanyVoiceRoboticCallLogAddwx();
         log.wxClientId = keyId;

+ 3 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyVoiceRoboticCallLogCallphone.java

@@ -133,6 +133,9 @@ public class CompanyVoiceRoboticCallLogCallphone extends BaseEntity{
     @TableField(exist = false)
     private Integer runningCount;
 
+    @TableField(exist = false)
+    private String successRate;
+
     public static CompanyVoiceRoboticCallLogCallphone initCallLog( String runParam, Long keyId, Long taskId,Long companyId) {
         CompanyVoiceRoboticCallLogCallphone log = new CompanyVoiceRoboticCallLogCallphone();
         log.callerId = keyId;

+ 3 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyVoiceRoboticCallLogSendmsg.java

@@ -92,6 +92,9 @@ public class CompanyVoiceRoboticCallLogSendmsg extends BaseEntity{
 
     private String phone;
 
+    @TableField(exist = false)
+    private String successRate;
+
 
 
     public static CompanyVoiceRoboticCallLogSendmsg initCallLog( String runParam, Long keyId, Long taskId,Long companyId,Long companyUserId,Long tempId) {

+ 23 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyVoiceRoboticCallLogAddwxMapper.java

@@ -4,7 +4,10 @@ import java.util.List;
 import java.util.Map;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.company.domain.CompanyVoiceRoboticCallLogAddwx;
+import com.fs.company.domain.CompanyVoiceRoboticCallLogCallphone;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogAddwxVO;
+import com.fs.company.vo.CompanyVoiceRoboticCallLogCallPhoneVO;
+import com.fs.company.vo.CompanyVoiceRoboticCallLogCount;
 import org.apache.ibatis.annotations.Param;
 
 /**
@@ -70,4 +73,24 @@ public interface CompanyVoiceRoboticCallLogAddwxMapper extends BaseMapper<Compan
 
     Map<String, Long> countListAll(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx);
 
+    /**
+     * 查询加微记录分组列表
+     * @param companyVoiceRoboticCallLogAddwx
+     * @return
+     */
+    List<CompanyVoiceRoboticCallLogAddwx> selectCompanyVoiceRoboticCallLogAddwxGroupList (CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx);
+
+    /**
+     * 查询加微记录详情
+     * @param companyVoiceRoboticCallLogAddwx
+     * @return
+     */
+    List<CompanyVoiceRoboticCallLogAddwxVO> listByRoboticId(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx);
+
+    /**
+     * 查询加微记录统计(所有任务)
+     * @return
+     */
+    CompanyVoiceRoboticCallLogCount selectCompanyVoiceRoboticAddwxLogCount();
+
 }

+ 16 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyVoiceRoboticCallLogAddwxService.java

@@ -4,8 +4,11 @@ import java.util.List;
 import java.util.Map;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.company.domain.CompanyVoiceRoboticCallLogAddwx;
+import com.fs.company.domain.CompanyVoiceRoboticCallLogCallphone;
 import com.fs.company.domain.CompanyWxClient;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogAddwxVO;
+import com.fs.company.vo.CompanyVoiceRoboticCallLogCallPhoneVO;
+import com.fs.company.vo.CompanyVoiceRoboticCallLogCount;
 
 /**
  * 调用日志_加微信Service接口
@@ -75,4 +78,17 @@ public interface ICompanyVoiceRoboticCallLogAddwxService extends IService<Compan
 
     Map<String, Long> countListAll(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx);
 
+    List<CompanyVoiceRoboticCallLogAddwx> selectCompanyVoiceRoboticAddwxLogGroupList(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx);
+
+    CompanyVoiceRoboticCallLogCount selectCompanyVoiceRoboticAddwxLogCount();
+
+    /**
+     * 查询加微记录详情
+     * @param companyVoiceRoboticCallLogAddwx
+     * @return
+     */
+    List<CompanyVoiceRoboticCallLogAddwxVO> listByRoboticId(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx);
+
+
+
 }

+ 18 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyVoiceRoboticCallLogAddwxServiceImpl.java

@@ -6,10 +6,13 @@ import java.util.Map;
 import com.fs.common.utils.DateUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fs.company.domain.CompanyVoiceRoboticCallLog;
+import com.fs.company.domain.CompanyVoiceRoboticCallLogCallphone;
 import com.fs.company.domain.CompanyWxClient;
 import com.fs.company.mapper.CompanyVoiceRoboticBusinessMapper;
 import com.fs.company.mapper.CompanyWxClientMapper;
 import com.fs.company.vo.CompanyVoiceRoboticCallLogAddwxVO;
+import com.fs.company.vo.CompanyVoiceRoboticCallLogCallPhoneVO;
+import com.fs.company.vo.CompanyVoiceRoboticCallLogCount;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
@@ -162,4 +165,19 @@ class CompanyVoiceRoboticCallLogAddwxServiceImpl extends ServiceImpl<CompanyVoic
         return baseMapper.countListAll(companyVoiceRoboticCallLogAddwx);
     }
 
+    @Override
+    public List<CompanyVoiceRoboticCallLogAddwx> selectCompanyVoiceRoboticAddwxLogGroupList(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx) {
+        return baseMapper.selectCompanyVoiceRoboticCallLogAddwxGroupList(companyVoiceRoboticCallLogAddwx);
+    }
+
+    @Override
+    public CompanyVoiceRoboticCallLogCount selectCompanyVoiceRoboticAddwxLogCount() {
+        return baseMapper.selectCompanyVoiceRoboticAddwxLogCount();
+    }
+
+    @Override
+    public List<CompanyVoiceRoboticCallLogAddwxVO> listByRoboticId(CompanyVoiceRoboticCallLogAddwx companyVoiceRoboticCallLogAddwx) {
+        return baseMapper.listByRoboticId(companyVoiceRoboticCallLogAddwx);
+    }
+
 }

+ 54 - 0
fs-service/src/main/resources/mapper/company/CompanyVoiceRoboticCallLogAddwxMapper.xml

@@ -141,6 +141,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="isWeCom != null "> and t1.is_we_com = #{isWeCom}</if>
     </select>
 
+    <select id="selectCompanyVoiceRoboticCallLogAddwxGroupList" resultType="com.fs.company.domain.CompanyVoiceRoboticCallLogAddwx" parameterType="com.fs.company.domain.CompanyVoiceRoboticCallLogAddwx">
+        select
+        robotic_id,
+        cvr.name as robotic_name,
+        count(1) as totalRecordCount,
+        sum(case when status = 1 then 1 else 0 end) as runningCount,
+        sum(case when status = 2 then 1 else 0 end) as successCount,
+        sum(case when status = 3 then 1 else 0 end) as failCount,
+        concat(round(sum(case when t3.is_add = 1 then 1 else 0 end) * 100.0 / count(1), 2), '%') as successRate
+        from company_voice_robotic_call_log_addwx t1
+        inner join company_voice_robotic cvr on cvr.id = t1.robotic_id
+        left join company_wx_client t3 on t3.id = t1.wx_client_id
+        <where>
+            <if test="roboticId != null">and robotic_id = #{roboticId}</if>
+        </where>
+        group by robotic_id
+    </select>
+
     <select id="listAll" parameterType="CompanyVoiceRoboticCallLogAddwx" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogAddwxVO">
         select
             t1.*,
@@ -204,4 +222,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="roboticId != null"> and t1.robotic_id = #{roboticId}</if>
         </where>
     </select>
+
+    <select id="listByRoboticId" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogAddwxVO" parameterType="com.fs.company.domain.CompanyVoiceRoboticCallLogAddwx">
+        SELECT
+        t1.*,
+        t2.company_name,
+        t3.nick_name as companyUserName,
+        cvr.name as robotic_name
+        FROM company_voice_robotic_call_log_addwx t1
+        left join company t2 on t1.company_id = t2.company_id
+        left join company_user t3 on t3.user_id = t1.company_user_id
+        left join company_voice_robotic cvr on cvr.id = t1.robotic_id
+        where 1=1
+        <if test="roboticId != null">and t1.robotic_id = #{roboticId}</if>
+        <if test="wxClientId != null">and t1.wx_client_id = #{wxClientId}</if>
+        <if test="wxClientIds != null and wxClientIds.size() > 0">
+            AND t1.wx_client_id IN
+            <foreach collection='wxClientIds' item='item' open='(' separator=',' close=')'>
+                #{item}
+            </foreach>
+        </if>
+        <if test="wxAccountId != null and wxAccountId != ''">
+            and t1.wx_account_id like concat('%', #{wxAccountId}, '%')
+        </if>
+
+    </select>
+
+    <select id="selectCompanyVoiceRoboticAddwxLogCount" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogCount">
+        select
+            count(1) as recordCount,
+            sum(case when status = 2 then 1 else 0 end) as successRecordCount,
+            sum(case when run_time &gt;= CURDATE() and run_time &lt; DATE_ADD(CURDATE(), INTERVAL 1 DAY) then 1 else 0 end) as todayCount,
+            sum(case when status = 2 and run_time &gt;= CURDATE() and run_time &lt; DATE_ADD(CURDATE(), INTERVAL 1 DAY) then 1 else 0 end) as todaySuccessCount
+        from company_voice_robotic_call_log_addwx cw
+                 inner join company_voice_robotic cvr on cvr.id = cw.robotic_id
+    </select>
+
 </mapper>

+ 3 - 2
fs-service/src/main/resources/mapper/company/CompanyVoiceRoboticCallLogCallphoneMapper.xml

@@ -206,7 +206,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         count(1) as totalRecordCount,
         sum(case when status = 1 then 1 else 0 end) as runningCount,
         sum(case when status = 2 then 1 else 0 end) as successCount,
-        sum(case when status = 3 then 1 else 0 end) as failCount
+        sum(case when status = 3 then 1 else 0 end) as failCount,
+        concat(round(sum(case when call_time is not null then 1 else 0 end) * 100.0 / count(1), 2), '%') as successRate
         from company_voice_robotic_call_log_callphone t1
         inner join company_voice_robotic cvr on cvr.id = t1.robotic_id
         <where>
@@ -225,7 +226,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
-    <select id="listByRoboticId" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogCallPhoneVO" parameterType="CompanyVoiceRoboticCallLogCallphone">
+    <select id="listByRoboticId" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogCallPhoneVO" parameterType="com.fs.company.domain.CompanyVoiceRoboticCallLogCallphone">
         SELECT
         t1.*,
         t2.company_name,

+ 3 - 1
fs-service/src/main/resources/mapper/company/CompanyVoiceRoboticCallLogSendmsgMapper.xml

@@ -48,9 +48,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         count(1) as totalRecordCount,
         sum(case when status = 1 then 1 else 0 end) as runningCount,
         sum(case when status = 2 then 1 else 0 end) as successCount,
-        sum(case when status = 3 then 1 else 0 end) as failCount
+        sum(case when status = 3 then 1 else 0 end) as failCount,
+        concat(round(ifnull(sum(case when cc.is_send_msg = 1 then 1 else 0 end) * 100.0 / nullif(count(1), 0),0),2),'%') as successRate
         from company_voice_robotic_call_log_sendmsg msg
         inner join company_voice_robotic cvr on cvr.id = msg.robotic_id
+        left join company_voice_robotic_callees cc on cc.id = msg.caller_id
         <where>
             <if test="roboticId != null">and robotic_id = #{roboticId}</if>
             <if test="callerId != null">and caller_id = #{callerId}</if>