Commit 8c7566e01d21eef21671fd81026f413675865432

Authored by 张志伟
1 parent 4eb2f717

:sparkles: 新增通话记录池

doc/v1.1.3/sql.sql
... ... @@ -3,4 +3,35 @@ alter table follow_record_log
3 3  
4 4 update follow_record_log t1
5 5 set task_id = (select w1.task_id from follow_record w1 where w1.id = t1.record_id)
6   -where t1.task_id is null;
7 6 \ No newline at end of file
  7 +where t1.task_id is null;
  8 +
  9 +
  10 +create table secret_report_history
  11 +(
  12 + id bigint auto_increment,
  13 + task_id bigint not null comment '任务id',
  14 + task_type int(3) not null comment '跟进类型 ',
  15 + follow_record_id bigint not null comment '跟进记录id',
  16 + first_call tinyint(1) not null comment '是否是首次通话',
  17 + call_id varchar(225) not null comment '通话记录id',
  18 + staff_id bigint not null comment '工作人员id',
  19 + staff_name varchar(64) null comment '工作人员名称',
  20 + customer_id bigint not null comment '客户id',
  21 + call_type int(3) not null comment '主/被叫',
  22 + call_time datetime not null comment '呼叫时间',
  23 + call_duration bigint null comment '通话时长(秒)',
  24 + shop_id bigint not null comment '门店id',
  25 + group_id bigint not null comment '集团id',
  26 + constraint secret_report_history_pk
  27 + primary key (id)
  28 +)
  29 + comment '智能电话通话记录';
  30 +
  31 +create index secret_report_history_call_time_index
  32 + on secret_report_history (call_time);
  33 +
  34 +create index secret_report_history_customer_id_index
  35 + on secret_report_history (customer_id);
  36 +
  37 +create index secret_report_history_staff_id_index
  38 + on secret_report_history (staff_id);
8 39 \ No newline at end of file
... ...
fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java 0 → 100644
  1 +package cn.fw.valhalla.dao.mapper;
  2 +
  3 +import cn.fw.valhalla.domain.db.SecretReportHistory;
  4 +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO;
  5 +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery;
  6 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  7 +import org.apache.ibatis.annotations.Param;
  8 +import org.springframework.stereotype.Repository;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * @author : kurisu
  14 + * @className : SecretReportHistoryMapper
  15 + * @description : 通话记录mapper
  16 + * @date: 2021-02-21 14:54
  17 + */
  18 +@Repository
  19 +public interface SecretReportHistoryMapper extends BaseMapper<SecretReportHistory> {
  20 + /**
  21 + * 查询通话记录池
  22 + *
  23 + * @param startIndex
  24 + * @param pageSize
  25 + * @param queryVO
  26 + * @return
  27 + */
  28 + List<SecretReportHistoryDTO> secretReportList(@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize, @Param("condition") SecretReportHistoryQuery queryVO);
  29 +
  30 + /**
  31 + * 查询通话记录总数
  32 + *
  33 + * @param queryVO
  34 + * @return
  35 + */
  36 + Long secretReportCount(@Param("condition") SecretReportHistoryQuery queryVO);
  37 +}
... ...
fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.fw.valhalla.dao.mapper.SecretReportHistoryMapper">
  4 + <select
  5 + id="secretReportList"
  6 + resultType="cn.fw.valhalla.domain.dto.SecretReportHistoryDTO"
  7 + parameterType="cn.fw.valhalla.domain.query.SecretReportHistoryQuery"
  8 + >
  9 + SELECT t1.id,
  10 + t1.task_id task_id,
  11 + t1.task_type follow_type,
  12 + t1.follow_record_id follow_record_id,
  13 + t1.first_call first_call,
  14 + t1.call_id call_id,
  15 + t1.staff_id staff_id,
  16 + t1.staff_name staff_name,
  17 + t1.customer_id customer_id,
  18 + t1.customer_id customer_id,
  19 + if(t1.task_type=3 , t4.name, t3.name) customer_name,
  20 + if(t1.task_type=3 , t4.plate_no, t2.plate_no) plate_no,
  21 + t1.call_type dial_type,
  22 + t1.call_time call_time,
  23 + t1.call_duration call_duration,
  24 + t1.shop_id shop_id,
  25 + t1.group_id group_id
  26 + FROM secret_report_history t1
  27 + left join customer t2 on t1.customer_id = t2.id
  28 + left join customer_base_info t3 on t2.base_id = t3.id
  29 + left join accident_pool t4 on t1.customer_id = t4.id
  30 + <where>
  31 + <if test="condition.groupId !=null">
  32 + and t1.group_id = #{condition.groupId}
  33 + </if>
  34 + <if test="condition.userId !=null">
  35 + and t1.staff_id = #{condition.userId}
  36 + </if>
  37 + <if test="condition.userName !=null and condition.userName != ''">
  38 + and t1.staff_name like concat('%', #{condition.userName}, '%')
  39 + </if>
  40 + <if test="condition.plateNo != null and condition.plateNo !=''">
  41 + and t2.plate_no like concat('%', #{condition.plateNo}, '%')
  42 + </if>
  43 +
  44 + <if test="condition.shopIds !=null">
  45 + and t1.shop_id in
  46 + <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
  47 + #{id}
  48 + </foreach>
  49 + </if>
  50 + <if test="condition.taskType !=null">
  51 + and t1.task_type = #{condition.taskType}
  52 + </if>
  53 + <if test="condition.startTime1 !=null">
  54 + and t1.call_time >= #{condition.startTime1}
  55 + </if>
  56 + <if test="condition.startTime2 !=null">
  57 + and t1.call_time &lt;= #{condition.startTime2}
  58 + </if>
  59 + </where>
  60 + <if test="condition.orderString != null and condition.orderString !='' ">
  61 + ${condition.orderString}
  62 + </if>
  63 + limit #{startIndex},#{pageSize};
  64 + </select>
  65 +
  66 +
  67 + <select
  68 + id="secretReportCount"
  69 + resultType="java.lang.Long"
  70 + parameterType="cn.fw.valhalla.domain.query.SecretReportHistoryQuery"
  71 + >
  72 + SELECT count(t1.id)
  73 + FROM secret_report_history t1
  74 + left join customer t2 on t1.customer_id = t2.id
  75 + left join customer_base_info t3 on t2.base_id = t3.id
  76 + left join accident_pool t4 on t1.customer_id = t4.id
  77 + <where>
  78 + <if test="condition.groupId !=null">
  79 + and t1.group_id = #{condition.groupId}
  80 + </if>
  81 + <if test="condition.userId !=null">
  82 + and t1.staff_id = #{condition.userId}
  83 + </if>
  84 + <if test="condition.userName !=null and condition.userName != ''">
  85 + and t1.staff_name like concat('%', #{condition.userName}, '%')
  86 + </if>
  87 + <if test="condition.plateNo != null and condition.plateNo !=''">
  88 + and t2.plate_no like concat('%', #{condition.plateNo}, '%')
  89 + </if>
  90 +
  91 + <if test="condition.shopIds !=null">
  92 + and t1.shop_id in
  93 + <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
  94 + #{id}
  95 + </foreach>
  96 + </if>
  97 + <if test="condition.taskType !=null">
  98 + and t1.task_type = #{condition.taskType}
  99 + </if>
  100 + <if test="condition.startTime1 !=null">
  101 + and t1.call_time >= #{condition.startTime1}
  102 + </if>
  103 + <if test="condition.startTime2 !=null">
  104 + and t1.call_time &lt;= #{condition.startTime2}
  105 + </if>
  106 + </where>
  107 + </select>
  108 +</mapper>
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java 0 → 100644
  1 +package cn.fw.valhalla.domain.db;
  2 +
  3 +import cn.fw.common.data.entity.BaseEntity;
  4 +import cn.fw.valhalla.domain.enums.CallTypeEnum;
  5 +import cn.fw.valhalla.domain.enums.FollowTypeEnum;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.ToString;
  9 +
  10 +import java.util.Date;
  11 +
  12 +/**
  13 + * @author : kurisu
  14 + * @className : SecretReportHistory
  15 + * @description : 通话记录
  16 + * @date: 2021-02-21 11:41
  17 + */
  18 +@Data
  19 +@ToString(callSuper = true)
  20 +@EqualsAndHashCode(callSuper = true)
  21 +public class SecretReportHistory extends BaseEntity<SecretReportHistory, Long> {
  22 + /**
  23 + * 任务id
  24 + */
  25 + private Long taskId;
  26 + /**
  27 + * 跟进类型
  28 + */
  29 + private FollowTypeEnum taskType;
  30 + /**
  31 + * 跟进id
  32 + */
  33 + private Long followRecordId;
  34 + /**
  35 + * 是否首次通话(针对跟进任务来说)
  36 + */
  37 + private Boolean firstCall;
  38 + /**
  39 + * 通话id
  40 + */
  41 + private String callId;
  42 + /**
  43 + * 工作人员id
  44 + */
  45 + private Long staffId;
  46 + /**
  47 + * 工作人员名称
  48 + */
  49 + private String staffName;
  50 + /**
  51 + * 客户id
  52 + */
  53 + private Long customerId;
  54 + /**
  55 + * 呼叫类型
  56 + */
  57 + private CallTypeEnum callType;
  58 + /**
  59 + * 呼叫时间
  60 + */
  61 + private Date callTime;
  62 + /**
  63 + * 通话时长
  64 + */
  65 + private Long callDuration;
  66 + /**
  67 + * 门店id
  68 + */
  69 + private Long shopId;
  70 + /**
  71 + * 集团id
  72 + */
  73 + private Long groupId;
  74 +}
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java
1 1 package cn.fw.valhalla.domain.dto;
2 2  
  3 +import cn.fw.valhalla.domain.enums.CallTypeEnum;
3 4 import lombok.Data;
4 5  
5 6 import java.time.LocalDateTime;
... ... @@ -22,6 +23,10 @@ public class CallReportDTO {
22 23 */
23 24 private Long staffId;
24 25 /**
  26 + * 工作人员名称
  27 + */
  28 + private String staffName;
  29 + /**
25 30 * 用户号码
26 31 */
27 32 private String staffMobile;
... ... @@ -38,6 +43,10 @@ public class CallReportDTO {
38 43 */
39 44 private Long talkTime;
40 45 /**
  46 + * 呼叫类型
  47 + */
  48 + private CallTypeEnum dialType;
  49 + /**
41 50 * 集团id
42 51 */
43 52 private Long groupId;
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java 0 → 100644
  1 +package cn.fw.valhalla.domain.dto;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.util.Date;
  6 +
  7 +/**
  8 + * @author : kurisu
  9 + * @className : SecretReportHistoryDTO
  10 + * @description :
  11 + * @date: 2021-02-21 15:47
  12 + */
  13 +@Data
  14 +public class SecretReportHistoryDTO {
  15 + private Long id;
  16 + /**
  17 + * 任务id
  18 + */
  19 + private Long taskId;
  20 + /**
  21 + * 跟进类型
  22 + */
  23 + private Integer followType;
  24 + /**
  25 + * 跟进id
  26 + */
  27 + private Long followRecordId;
  28 + /**
  29 + * 是否首次通话(针对跟进任务来说)
  30 + */
  31 + private Boolean firstCall;
  32 + /**
  33 + * 通话id
  34 + */
  35 + private String callId;
  36 + /**
  37 + * 工作人员id
  38 + */
  39 + private Long staffId;
  40 + /**
  41 + * 工作人员名称
  42 + */
  43 + private String staffName;
  44 + /**
  45 + * 客户id
  46 + */
  47 + private Long customerId;
  48 + /**
  49 + * 客户名称
  50 + */
  51 + private String customerName;
  52 + /**
  53 + * 车牌号
  54 + */
  55 + private String plateNo;
  56 + /**
  57 + * 呼叫类型
  58 + */
  59 + private Integer dialType;
  60 + /**
  61 + * 呼叫时间
  62 + */
  63 + private Date callTime;
  64 + /**
  65 + * 通话时长
  66 + */
  67 + private Long callDuration;
  68 + /**
  69 + * 门店id
  70 + */
  71 + private Long shopId;
  72 + /**
  73 + * 集团id
  74 + */
  75 + private Long groupId;
  76 +}
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java 0 → 100644
  1 +package cn.fw.valhalla.domain.enums;
  2 +
  3 +import com.baomidou.mybatisplus.core.enums.IEnum;
  4 +import com.fasterxml.jackson.annotation.JsonCreator;
  5 +import com.fasterxml.jackson.annotation.JsonValue;
  6 +import lombok.Getter;
  7 +
  8 +/**
  9 + * @author : kurisu
  10 + * @className : CallTypeEnum
  11 + * @description : 呼叫类型
  12 + * @date: 2020-08-11 17:37
  13 + */
  14 +public enum CallTypeEnum implements IEnum<Integer> {
  15 + /**
  16 + * 主叫
  17 + */
  18 + CALL(1, "主叫"),
  19 + /**
  20 + * 被叫
  21 + */
  22 + P_CALL(2, "被叫"),
  23 + ;
  24 +
  25 + /**
  26 + * 值
  27 + */
  28 + private final Integer value;
  29 + /**
  30 + * 名称
  31 + */
  32 + @Getter
  33 + private final String name;
  34 +
  35 + CallTypeEnum(final Integer value, final String name) {
  36 + this.value = value;
  37 + this.name = name;
  38 + }
  39 +
  40 + /**
  41 + * 根据枚举值获取枚举对象
  42 + */
  43 + @JsonCreator
  44 + public static CallTypeEnum ofValue(final Integer value) {
  45 + for (final CallTypeEnum typeEnum : CallTypeEnum.values()) {
  46 + if (typeEnum.value.equals(value)) {
  47 + return typeEnum;
  48 + }
  49 + }
  50 + return null;
  51 + }
  52 +
  53 + /**
  54 + * 获取值
  55 + *
  56 + * @return 值
  57 + */
  58 + @JsonValue
  59 + @Override
  60 + public Integer getValue() {
  61 + return value;
  62 + }
  63 +
  64 + /**
  65 + * 获取描述
  66 + *
  67 + * @return 值
  68 + */
  69 + @JsonCreator
  70 + public static String getNameByVale(final Integer value) {
  71 + for (final CallTypeEnum typeEnum : CallTypeEnum.values()) {
  72 + if (typeEnum.value.equals(value)) {
  73 + return typeEnum.getName();
  74 + }
  75 + }
  76 + return "";
  77 + }
  78 +}
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java 0 → 100644
  1 +package cn.fw.valhalla.domain.query;
  2 +
  3 +import cn.fw.valhalla.common.utils.DateUtil;
  4 +import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
  6 +import lombok.ToString;
  7 +import org.apache.commons.lang3.StringUtils;
  8 +import org.apache.commons.lang3.math.NumberUtils;
  9 +
  10 +import javax.validation.constraints.NotNull;
  11 +import java.time.Instant;
  12 +import java.time.LocalDateTime;
  13 +import java.time.ZoneId;
  14 +import java.util.Date;
  15 +
  16 +/**
  17 + * @author : kurisu
  18 + * @className : SecretReportHistoryQuery
  19 + * @description : 查询条件
  20 + * @date: 2021-02-21 15:55
  21 + */
  22 +@EqualsAndHashCode(callSuper = true)
  23 +@Data
  24 +@ToString(callSuper = true)
  25 +public class SecretReportHistoryQuery extends PoolQuery {
  26 + @NotNull(message = "跟进类型不能为空")
  27 + private Integer taskType;
  28 +
  29 + /**
  30 + * 通话时间段(区间)
  31 + */
  32 + private String callTime;
  33 +
  34 +
  35 + public Date getStartTime1() {
  36 + if (StringUtils.isBlank(callTime)) {
  37 + return null;
  38 + }
  39 + String[] times = callTime.split(",");
  40 + if (StringUtils.isNotBlank(times[0]) && NumberUtils.isDigits(times[0])) {
  41 + LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(times[0])).atZone(ZoneId.systemDefault()).toLocalDateTime();
  42 + return DateUtil.getBeginInTime(DateUtil.localDateTime2Date(localDateTime));
  43 + }
  44 + return null;
  45 + }
  46 +
  47 + public Date getStartTime2() {
  48 + if (StringUtils.isBlank(callTime)) {
  49 + return null;
  50 + }
  51 + String[] times = callTime.split(",");
  52 + if (times.length < TIME_STR_LENGTH) {
  53 + return null;
  54 + }
  55 + if (StringUtils.isNotBlank(times[1]) && NumberUtils.isDigits(times[1])) {
  56 + LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(times[1])).atZone(ZoneId.systemDefault()).toLocalDateTime();
  57 + return DateUtil.getEndInTime(DateUtil.localDateTime2Date(localDateTime));
  58 + }
  59 + return null;
  60 + }
  61 +}
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java 0 → 100644
  1 +package cn.fw.valhalla.domain.vo;
  2 +
  3 +import cn.fw.valhalla.domain.enums.CallTypeEnum;
  4 +import lombok.Data;
  5 +
  6 +import java.util.Date;
  7 +import java.util.Objects;
  8 +
  9 +/**
  10 + * @author : kurisu
  11 + * @className : SecretReportHistoryVO
  12 + * @description : 智能通话池
  13 + * @date: 2021-02-21 15:40
  14 + */
  15 +@Data
  16 +public class SecretReportHistoryVO {
  17 + private Long id;
  18 + /**
  19 + * 任务id
  20 + */
  21 + private Long taskId;
  22 + /**
  23 + * 跟进类型
  24 + */
  25 + private Integer followType;
  26 + /**
  27 + * 跟进id
  28 + */
  29 + private Long followRecordId;
  30 + /**
  31 + * 是否首次通话(针对跟进任务来说)
  32 + */
  33 + private Boolean firstCall;
  34 + /**
  35 + * 通话id
  36 + */
  37 + private String callId;
  38 + /**
  39 + * 工作人员id
  40 + */
  41 + private Long staffId;
  42 + /**
  43 + * 工作人员名称
  44 + */
  45 + private String staffName;
  46 + /**
  47 + * 客户id
  48 + */
  49 + private Long customerId;
  50 + /**
  51 + * 客户名称
  52 + */
  53 + private String customerName;
  54 + /**
  55 + * 车牌号
  56 + */
  57 + private String plateNo;
  58 + /**
  59 + * 呼叫类型
  60 + */
  61 + private CallTypeEnum callType;
  62 + /**
  63 + * 呼叫时间
  64 + */
  65 + private Date callTime;
  66 + /**
  67 + * 通话时长
  68 + */
  69 + private Long callDuration;
  70 + /**
  71 + * 门店id
  72 + */
  73 + private Long shopId;
  74 + /**
  75 + * 集团id
  76 + */
  77 + private Long groupId;
  78 +
  79 + public String getCallTypeDesc() {
  80 + if (Objects.isNull(callType)) {
  81 + return null;
  82 + }
  83 + return callType.getName();
  84 + }
  85 +}
... ...
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java
... ... @@ -9,7 +9,9 @@ import cn.fw.security.auth.client.annotation.IgnoreAuth;
9 9 import cn.fw.security.auth.client.enums.AuthType;
10 10 import cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO;
11 11 import cn.fw.valhalla.domain.query.FollowPoolQueryVO;
  12 +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery;
12 13 import cn.fw.valhalla.domain.query.StammkundePoolQueryVO;
  14 +import cn.fw.valhalla.domain.vo.SecretReportHistoryVO;
13 15 import cn.fw.valhalla.domain.vo.follow.FollowDetailVO;
14 16 import cn.fw.valhalla.domain.vo.pool.*;
15 17 import cn.fw.valhalla.service.bus.follow.FollowBizService;
... ... @@ -161,4 +163,19 @@ public class PoolController {
161 163 return failureWithMessage(QUERY_FAILURE);
162 164 }
163 165 }
  166 +
  167 + @GetMapping("/secret/report/list")
  168 + @IgnoreAuth
  169 + public Message<AppPage<SecretReportHistoryVO>> reportList(@CurrentUser LoginAuthBean currentUser, final SecretReportHistoryQuery queryVO) {
  170 + final String msg = "查询智能通话记录池列表[pool/clue/list]";
  171 + try {
  172 + log.info("{}: param[{}]", msg, queryVO);
  173 + queryVO.setGroupId(currentUser.getGroupId());
  174 + AppPage<SecretReportHistoryVO> page = poolBizService.secretReportList(queryVO);
  175 + return success(page, data -> log.info("dataSize: {}", CollectionUtils.isEmpty(data.getData()) ? 0 : data.getData().size()));
  176 + } catch (Exception ex) {
  177 + handleException(ex, e -> log.error("{}失败:param[{}]", msg, queryVO.getTaskType(), e));
  178 + return failureWithMessage(QUERY_FAILURE);
  179 + }
  180 + }
164 181 }
... ...
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java
... ... @@ -90,7 +90,6 @@ public class CallReportDealTask {
90 90 dto.setStaffId(info.getId());
91 91 dto.setGroupId(info.getGroupId());
92 92 }
93   - // todo 记录通话记录(报表用)
94 93 followBizService.readCallReport(dto, true, queryAccidentCar(mobileNo, groupId));
95 94 followBizService.readCallReport(dto, false, queryCustomerIds(mobileNo, groupId));
96 95 } catch (Exception e) {
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java
1 1 package cn.fw.valhalla.component;
2 2  
  3 +import cn.fw.pstn.sdk.enums.DialTypeEnum;
3 4 import cn.fw.pstn.sdk.mq.CallReport;
4 5 import cn.fw.valhalla.common.utils.StringUtils;
5 6 import cn.fw.valhalla.domain.dto.CallReportDTO;
  7 +import cn.fw.valhalla.domain.enums.CallTypeEnum;
6 8 import cn.fw.valhalla.rpc.ehr.EhrRpcService;
7 9 import cn.fw.valhalla.rpc.ehr.dto.StaffInfoDTO;
8 10 import com.alibaba.fastjson.JSON;
... ... @@ -52,6 +54,10 @@ public class CallReportConsumer implements RocketMQListener&lt;CallReport&gt; {
52 54 }
53 55 CallReportDTO dto = new CallReportDTO();
54 56 BeanUtils.copyProperties(t, dto);
  57 + dto.setDialType(CallTypeEnum.CALL);
  58 + if (DialTypeEnum.P_CALL.equals(t.getCallType())) {
  59 + dto.setDialType(CallTypeEnum.P_CALL);
  60 + }
55 61 String staffMobile = t.getStaffMobile();
56 62 if (StringUtils.isEmpty(staffMobile)) {
57 63 return;
... ... @@ -59,6 +65,7 @@ public class CallReportConsumer implements RocketMQListener&lt;CallReport&gt; {
59 65 StaffInfoDTO info = ehrRpcService.queryStaffInfoByMobile(staffMobile);
60 66 if (Objects.nonNull(info)) {
61 67 dto.setStaffId(info.getId());
  68 + dto.setStaffName(info.getName());
62 69 dto.setGroupId(info.getGroupId());
63 70 }
64 71 redisTemplate.opsForList().rightPush(getCallReportKey(), JSONObject.toJSONString(dto));
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java
... ... @@ -6,7 +6,9 @@ import cn.fw.common.web.auth.LoginAuthBean;
6 6 import cn.fw.valhalla.common.utils.DateUtil;
7 7 import cn.fw.valhalla.domain.db.ApproveRecord;
8 8 import cn.fw.valhalla.domain.db.OriginalData;
  9 +import cn.fw.valhalla.domain.db.SecretReportHistory;
9 10 import cn.fw.valhalla.domain.db.follow.FollowRecord;
  11 +import cn.fw.valhalla.domain.db.follow.FollowRecordLog;
10 12 import cn.fw.valhalla.domain.db.follow.FollowTask;
11 13 import cn.fw.valhalla.domain.db.pool.CustomerCluePool;
12 14 import cn.fw.valhalla.domain.dto.CallReportDTO;
... ... @@ -23,10 +25,7 @@ import cn.fw.valhalla.rpc.flow.FlowApproveRpc;
23 25 import cn.fw.valhalla.rpc.flow.dto.FlowDto;
24 26 import cn.fw.valhalla.sdk.enums.DataTypeEnum;
25 27 import cn.fw.valhalla.service.bus.follow.strategy.FollowStrategy;
26   -import cn.fw.valhalla.service.data.ApproveRecordService;
27   -import cn.fw.valhalla.service.data.CustomerCluePoolService;
28   -import cn.fw.valhalla.service.data.FollowRecordService;
29   -import cn.fw.valhalla.service.data.FollowTaskService;
  28 +import cn.fw.valhalla.service.data.*;
30 29 import cn.fw.valhalla.service.event.TaskCancelEvent;
31 30 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
32 31 import lombok.Getter;
... ... @@ -67,6 +66,8 @@ public class FollowBizService {
67 66 private final UserService userService;
68 67 private final DistributedLocker distributedLocker;
69 68 private final CustomerCluePoolService customerCluePoolService;
  69 + private final SecretReportHistoryService secretReportHistoryService;
  70 + private final FollowRecordLogService followRecordLogService;
70 71  
71 72 @Value("${follow.flowNo}")
72 73 @Getter
... ... @@ -84,7 +85,9 @@ public class FollowBizService {
84 85 final FollowRecordService followRecordService,
85 86 final UserService userService,
86 87 final DistributedLocker distributedLocker,
87   - final CustomerCluePoolService customerCluePoolService) {
  88 + final CustomerCluePoolService customerCluePoolService,
  89 + final SecretReportHistoryService secretReportHistoryService,
  90 + final FollowRecordLogService followRecordLogService) {
88 91 this.followMap = followStrategyList.stream().collect(Collectors.toMap(FollowStrategy::getFollowType, v -> v));
89 92 this.flowApproveRpc = flowApproveRpc;
90 93 this.approveRecordService = approveRecordService;
... ... @@ -93,6 +96,8 @@ public class FollowBizService {
93 96 this.userService = userService;
94 97 this.distributedLocker = distributedLocker;
95 98 this.customerCluePoolService = customerCluePoolService;
  99 + this.secretReportHistoryService = secretReportHistoryService;
  100 + this.followRecordLogService = followRecordLogService;
96 101 }
97 102  
98 103 /**
... ... @@ -493,7 +498,7 @@ public class FollowBizService {
493 498 .last(" limit 1")
494 499 );
495 500 if (Objects.nonNull(cluePool)) {
496   - completeRecord(cluePool.getId(), staffId, dto.getCallId());
  501 + completeRecord(dto, cluePool.getId(), staffId, dto.getCallId());
497 502 }
498 503 } else {
499 504 List<CustomerCluePool> list = customerCluePoolService.list(Wrappers.<CustomerCluePool>lambdaQuery()
... ... @@ -502,7 +507,7 @@ public class FollowBizService {
502 507 .in(CustomerCluePool::getRefererId, Arrays.asList(idArr))
503 508 );
504 509 if (!CollectionUtils.isEmpty(list)) {
505   - list.forEach(cluePool -> completeRecord(cluePool.getId(), staffId, dto.getCallId()));
  510 + list.forEach(cluePool -> completeRecord(dto, cluePool.getId(), staffId, dto.getCallId()));
506 511 }
507 512 }
508 513 }
... ... @@ -544,7 +549,7 @@ public class FollowBizService {
544 549 ) > 0;
545 550 }
546 551  
547   - private void completeRecord(final Long clueId, final Long staffId, final String callId) {
  552 + private void completeRecord(CallReportDTO reportDTO, final Long clueId, final Long staffId, final String callId) {
548 553 FollowTask followTask = followTaskService.queryOngoingTaskByClueId(clueId);
549 554 if (Objects.isNull(followTask)) {
550 555 return;
... ... @@ -564,6 +569,7 @@ public class FollowBizService {
564 569  
565 570 FollowStrategy strategy = followMap.get(followType);
566 571 Assert.notNull(strategy, "strategy cannot be null");
  572 + List<SecretReportHistory> reportHistoryList = new ArrayList<>();
567 573  
568 574 for (FollowRecord record : list) {
569 575 FollowAttachmentDTO dto = new FollowAttachmentDTO();
... ... @@ -573,6 +579,31 @@ public class FollowBizService {
573 579 dto.setFeedbackType(FollowTypeEnum.AC.equals(followType) ? FeedbackTypeEnum.OTHER.getValue() : null);
574 580 dto.setAttType(AttTypeEnum.SMART_PHONE.getValue());
575 581 strategy.uploadAtt(dto, staffId);
  582 + reportHistoryList.add(createHistory(reportDTO, record, followType));
576 583 }
  584 + secretReportHistoryService.saveBatch(reportHistoryList);
  585 + }
  586 +
  587 +
  588 + private SecretReportHistory createHistory(CallReportDTO reportDTO, FollowRecord record, FollowTypeEnum followTypeEnum) {
  589 + SecretReportHistory history = new SecretReportHistory();
  590 + history.setTaskId(record.getTaskId());
  591 + history.setTaskType(followTypeEnum);
  592 + history.setFollowRecordId(record.getId());
  593 + history.setCallId(reportDTO.getCallId());
  594 + history.setStaffId(reportDTO.getStaffId());
  595 + history.setStaffName(reportDTO.getStaffName());
  596 + history.setCustomerId(record.getCustomerId());
  597 + history.setCallType(reportDTO.getDialType());
  598 + history.setCallTime(reportDTO.getCallTime());
  599 + history.setCallDuration(reportDTO.getTalkTime());
  600 + history.setShopId(record.getShopId());
  601 + history.setGroupId(record.getGroupId());
  602 + int count = followRecordLogService.count(Wrappers.<FollowRecordLog>lambdaQuery()
  603 + .eq(FollowRecordLog::getTaskId, record.getTaskId())
  604 + .eq(FollowRecordLog::getAttType, AttTypeEnum.SMART_PHONE)
  605 + );
  606 + history.setFirstCall(count <= 0);
  607 + return history;
577 608 }
578 609 }
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java
... ... @@ -8,13 +8,12 @@ import cn.fw.valhalla.domain.db.customer.AffiliationRecord;
8 8 import cn.fw.valhalla.domain.db.pool.PublicPool;
9 9 import cn.fw.valhalla.domain.dto.CustomerCluePoolDTO;
10 10 import cn.fw.valhalla.domain.dto.FollowPoolDTO;
  11 +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO;
11 12 import cn.fw.valhalla.domain.dto.StammkundePoolDTO;
12 13 import cn.fw.valhalla.domain.enums.*;
13   -import cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO;
14   -import cn.fw.valhalla.domain.query.FollowPoolQueryVO;
15   -import cn.fw.valhalla.domain.query.PoolQuery;
16   -import cn.fw.valhalla.domain.query.StammkundePoolQueryVO;
  14 +import cn.fw.valhalla.domain.query.*;
17 15 import cn.fw.valhalla.domain.vo.AppPageVO;
  16 +import cn.fw.valhalla.domain.vo.SecretReportHistoryVO;
18 17 import cn.fw.valhalla.domain.vo.pool.*;
19 18 import cn.fw.valhalla.rpc.erp.UserService;
20 19 import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
... ... @@ -55,6 +54,7 @@ public class PoolBizService {
55 54 private final UserService userService;
56 55 private final AffiliationRecordService affiliationRecordService;
57 56 private final OrderRpcService orderRpcService;
  57 + private final SecretReportHistoryService secretReportHistoryService;
58 58  
59 59  
60 60 /**
... ... @@ -191,6 +191,32 @@ public class PoolBizService {
191 191 return vo;
192 192 }
193 193  
  194 + /**
  195 + * 查询通话记录池
  196 + *
  197 + * @param query
  198 + * @return
  199 + */
  200 + public AppPage<SecretReportHistoryVO> secretReportList(SecretReportHistoryQuery query) {
  201 + BV.isNotEmpty(query.getShopIds(), () -> "人员权限范围不正确,请确认是否有管理权限");
  202 + AppPageVO<SecretReportHistoryVO> page = AppPageVO.init(query);
  203 + long total = secretReportHistoryService.secretReportCount(query);
  204 + if (total <= 0) {
  205 + return page;
  206 + }
  207 + page.setTotal(total);
  208 + List<SecretReportHistoryDTO> list = secretReportHistoryService.secretReportList(query);
  209 + List<SecretReportHistoryVO> appList = new ArrayList<>();
  210 + for (SecretReportHistoryDTO dto : list) {
  211 + SecretReportHistoryVO vo = new SecretReportHistoryVO();
  212 + BeanUtils.copyProperties(dto, vo);
  213 + vo.setCallType(CallTypeEnum.ofValue(dto.getDialType()));
  214 + appList.add(vo);
  215 + }
  216 + page.setData(appList);
  217 + return page;
  218 + }
  219 +
194 220 private FollowPoolListVO trans2FollowPool(FollowPoolDTO poolDTO) {
195 221 FollowPoolListVO vo = new FollowPoolListVO();
196 222 BeanUtils.copyProperties(poolDTO, vo);
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java 0 → 100644
  1 +package cn.fw.valhalla.service.data;
  2 +
  3 +import cn.fw.valhalla.domain.db.SecretReportHistory;
  4 +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO;
  5 +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery;
  6 +import com.baomidou.mybatisplus.extension.service.IService;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * @author : kurisu
  12 + * @className : SecretReportHistoryService
  13 + * @description : 通话记录
  14 + * @date: 2021-02-21 14:58
  15 + */
  16 +public interface SecretReportHistoryService extends IService<SecretReportHistory> {
  17 + /**
  18 + * 通话记录池
  19 + * @param query
  20 + * @return
  21 + */
  22 + List<SecretReportHistoryDTO> secretReportList(SecretReportHistoryQuery query);
  23 +
  24 + /**
  25 + * 查询总数
  26 + * @param query
  27 + * @return
  28 + */
  29 + Long secretReportCount(SecretReportHistoryQuery query);
  30 +}
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java 0 → 100644
  1 +package cn.fw.valhalla.service.data.impl;
  2 +
  3 +import cn.fw.valhalla.dao.mapper.SecretReportHistoryMapper;
  4 +import cn.fw.valhalla.domain.db.SecretReportHistory;
  5 +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO;
  6 +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery;
  7 +import cn.fw.valhalla.service.data.SecretReportHistoryService;
  8 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  9 +import lombok.extern.slf4j.Slf4j;
  10 +import org.springframework.stereotype.Service;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.List;
  14 +import java.util.Optional;
  15 +
  16 +/**
  17 + * @author : kurisu
  18 + * @className : SecretReportHistoryServiceImpl
  19 + * @description : 通话记录
  20 + * @date: 2021-02-21 14:58
  21 + */
  22 +@Slf4j
  23 +@Service
  24 +public class SecretReportHistoryServiceImpl extends ServiceImpl<SecretReportHistoryMapper, SecretReportHistory> implements SecretReportHistoryService {
  25 + @Override
  26 + public List<SecretReportHistoryDTO> secretReportList(SecretReportHistoryQuery queryVO) {
  27 + Integer current = queryVO.getCurrent();
  28 + Integer pageSize = queryVO.getPageSize();
  29 + Integer startIndex = (current - 1) * pageSize;
  30 + return Optional.ofNullable(getBaseMapper().secretReportList(startIndex, pageSize, queryVO)).orElse(new ArrayList<>());
  31 + }
  32 +
  33 + @Override
  34 + public Long secretReportCount(SecretReportHistoryQuery query) {
  35 + return Optional.ofNullable(getBaseMapper().secretReportCount(query)).orElse(0L);
  36 + }
  37 +}
... ...