From 8c7566e01d21eef21671fd81026f413675865432 Mon Sep 17 00:00:00 2001 From: Kurisu Date: Sun, 21 Feb 2021 16:43:41 +0800 Subject: [PATCH] :sparkles: 新增通话记录池 --- doc/v1.1.3/sql.sql | 33 ++++++++++++++++++++++++++++++++- fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java | 37 +++++++++++++++++++++++++++++++++++++ fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java | 9 +++++++++ fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java | 17 +++++++++++++++++ fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java | 1 - fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java | 7 +++++++ fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java | 47 +++++++++++++++++++++++++++++++++++++++-------- fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java | 34 ++++++++++++++++++++++++++++++---- fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java | 30 ++++++++++++++++++++++++++++++ fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java | 37 +++++++++++++++++++++++++++++++++++++ 16 files changed, 720 insertions(+), 14 deletions(-) create mode 100644 fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java create mode 100644 fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml create mode 100644 fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java create mode 100644 fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java create mode 100644 fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java create mode 100644 fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java create mode 100644 fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java create mode 100644 fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java create mode 100644 fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java diff --git a/doc/v1.1.3/sql.sql b/doc/v1.1.3/sql.sql index d0d2e75..1a47b3c 100644 --- a/doc/v1.1.3/sql.sql +++ b/doc/v1.1.3/sql.sql @@ -3,4 +3,35 @@ alter table follow_record_log update follow_record_log t1 set task_id = (select w1.task_id from follow_record w1 where w1.id = t1.record_id) -where t1.task_id is null; \ No newline at end of file +where t1.task_id is null; + + +create table secret_report_history +( + id bigint auto_increment, + task_id bigint not null comment '任务id', + task_type int(3) not null comment '跟进类型 ', + follow_record_id bigint not null comment '跟进记录id', + first_call tinyint(1) not null comment '是否是首次通话', + call_id varchar(225) not null comment '通话记录id', + staff_id bigint not null comment '工作人员id', + staff_name varchar(64) null comment '工作人员名称', + customer_id bigint not null comment '客户id', + call_type int(3) not null comment '主/被叫', + call_time datetime not null comment '呼叫时间', + call_duration bigint null comment '通话时长(秒)', + shop_id bigint not null comment '门店id', + group_id bigint not null comment '集团id', + constraint secret_report_history_pk + primary key (id) +) + comment '智能电话通话记录'; + +create index secret_report_history_call_time_index + on secret_report_history (call_time); + +create index secret_report_history_customer_id_index + on secret_report_history (customer_id); + +create index secret_report_history_staff_id_index + on secret_report_history (staff_id); \ No newline at end of file diff --git a/fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java b/fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java new file mode 100644 index 0000000..f039209 --- /dev/null +++ b/fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java @@ -0,0 +1,37 @@ +package cn.fw.valhalla.dao.mapper; + +import cn.fw.valhalla.domain.db.SecretReportHistory; +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO; +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author : kurisu + * @className : SecretReportHistoryMapper + * @description : 通话记录mapper + * @date: 2021-02-21 14:54 + */ +@Repository +public interface SecretReportHistoryMapper extends BaseMapper { + /** + * 查询通话记录池 + * + * @param startIndex + * @param pageSize + * @param queryVO + * @return + */ + List secretReportList(@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize, @Param("condition") SecretReportHistoryQuery queryVO); + + /** + * 查询通话记录总数 + * + * @param queryVO + * @return + */ + Long secretReportCount(@Param("condition") SecretReportHistoryQuery queryVO); +} diff --git a/fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml b/fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml new file mode 100644 index 0000000..a2996ed --- /dev/null +++ b/fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml @@ -0,0 +1,108 @@ + + + + + + + + diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java new file mode 100644 index 0000000..1c8ae2f --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java @@ -0,0 +1,74 @@ +package cn.fw.valhalla.domain.db; + +import cn.fw.common.data.entity.BaseEntity; +import cn.fw.valhalla.domain.enums.CallTypeEnum; +import cn.fw.valhalla.domain.enums.FollowTypeEnum; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; + +/** + * @author : kurisu + * @className : SecretReportHistory + * @description : 通话记录 + * @date: 2021-02-21 11:41 + */ +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class SecretReportHistory extends BaseEntity { + /** + * 任务id + */ + private Long taskId; + /** + * 跟进类型 + */ + private FollowTypeEnum taskType; + /** + * 跟进id + */ + private Long followRecordId; + /** + * 是否首次通话(针对跟进任务来说) + */ + private Boolean firstCall; + /** + * 通话id + */ + private String callId; + /** + * 工作人员id + */ + private Long staffId; + /** + * 工作人员名称 + */ + private String staffName; + /** + * 客户id + */ + private Long customerId; + /** + * 呼叫类型 + */ + private CallTypeEnum callType; + /** + * 呼叫时间 + */ + private Date callTime; + /** + * 通话时长 + */ + private Long callDuration; + /** + * 门店id + */ + private Long shopId; + /** + * 集团id + */ + private Long groupId; +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java index 938a14f..91029c6 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java @@ -1,5 +1,6 @@ package cn.fw.valhalla.domain.dto; +import cn.fw.valhalla.domain.enums.CallTypeEnum; import lombok.Data; import java.time.LocalDateTime; @@ -22,6 +23,10 @@ public class CallReportDTO { */ private Long staffId; /** + * 工作人员名称 + */ + private String staffName; + /** * 用户号码 */ private String staffMobile; @@ -38,6 +43,10 @@ public class CallReportDTO { */ private Long talkTime; /** + * 呼叫类型 + */ + private CallTypeEnum dialType; + /** * 集团id */ private Long groupId; diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java new file mode 100644 index 0000000..a23b620 --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java @@ -0,0 +1,76 @@ +package cn.fw.valhalla.domain.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * @author : kurisu + * @className : SecretReportHistoryDTO + * @description : + * @date: 2021-02-21 15:47 + */ +@Data +public class SecretReportHistoryDTO { + private Long id; + /** + * 任务id + */ + private Long taskId; + /** + * 跟进类型 + */ + private Integer followType; + /** + * 跟进id + */ + private Long followRecordId; + /** + * 是否首次通话(针对跟进任务来说) + */ + private Boolean firstCall; + /** + * 通话id + */ + private String callId; + /** + * 工作人员id + */ + private Long staffId; + /** + * 工作人员名称 + */ + private String staffName; + /** + * 客户id + */ + private Long customerId; + /** + * 客户名称 + */ + private String customerName; + /** + * 车牌号 + */ + private String plateNo; + /** + * 呼叫类型 + */ + private Integer dialType; + /** + * 呼叫时间 + */ + private Date callTime; + /** + * 通话时长 + */ + private Long callDuration; + /** + * 门店id + */ + private Long shopId; + /** + * 集团id + */ + private Long groupId; +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java new file mode 100644 index 0000000..4c2b077 --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java @@ -0,0 +1,78 @@ +package cn.fw.valhalla.domain.enums; + +import com.baomidou.mybatisplus.core.enums.IEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; + +/** + * @author : kurisu + * @className : CallTypeEnum + * @description : 呼叫类型 + * @date: 2020-08-11 17:37 + */ +public enum CallTypeEnum implements IEnum { + /** + * 主叫 + */ + CALL(1, "主叫"), + /** + * 被叫 + */ + P_CALL(2, "被叫"), + ; + + /** + * 值 + */ + private final Integer value; + /** + * 名称 + */ + @Getter + private final String name; + + CallTypeEnum(final Integer value, final String name) { + this.value = value; + this.name = name; + } + + /** + * 根据枚举值获取枚举对象 + */ + @JsonCreator + public static CallTypeEnum ofValue(final Integer value) { + for (final CallTypeEnum typeEnum : CallTypeEnum.values()) { + if (typeEnum.value.equals(value)) { + return typeEnum; + } + } + return null; + } + + /** + * 获取值 + * + * @return 值 + */ + @JsonValue + @Override + public Integer getValue() { + return value; + } + + /** + * 获取描述 + * + * @return 值 + */ + @JsonCreator + public static String getNameByVale(final Integer value) { + for (final CallTypeEnum typeEnum : CallTypeEnum.values()) { + if (typeEnum.value.equals(value)) { + return typeEnum.getName(); + } + } + return ""; + } +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java new file mode 100644 index 0000000..6f95191 --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java @@ -0,0 +1,61 @@ +package cn.fw.valhalla.domain.query; + +import cn.fw.valhalla.common.utils.DateUtil; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import javax.validation.constraints.NotNull; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; + +/** + * @author : kurisu + * @className : SecretReportHistoryQuery + * @description : 查询条件 + * @date: 2021-02-21 15:55 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@ToString(callSuper = true) +public class SecretReportHistoryQuery extends PoolQuery { + @NotNull(message = "跟进类型不能为空") + private Integer taskType; + + /** + * 通话时间段(区间) + */ + private String callTime; + + + public Date getStartTime1() { + if (StringUtils.isBlank(callTime)) { + return null; + } + String[] times = callTime.split(","); + if (StringUtils.isNotBlank(times[0]) && NumberUtils.isDigits(times[0])) { + LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(times[0])).atZone(ZoneId.systemDefault()).toLocalDateTime(); + return DateUtil.getBeginInTime(DateUtil.localDateTime2Date(localDateTime)); + } + return null; + } + + public Date getStartTime2() { + if (StringUtils.isBlank(callTime)) { + return null; + } + String[] times = callTime.split(","); + if (times.length < TIME_STR_LENGTH) { + return null; + } + if (StringUtils.isNotBlank(times[1]) && NumberUtils.isDigits(times[1])) { + LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(times[1])).atZone(ZoneId.systemDefault()).toLocalDateTime(); + return DateUtil.getEndInTime(DateUtil.localDateTime2Date(localDateTime)); + } + return null; + } +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java new file mode 100644 index 0000000..f96420c --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java @@ -0,0 +1,85 @@ +package cn.fw.valhalla.domain.vo; + +import cn.fw.valhalla.domain.enums.CallTypeEnum; +import lombok.Data; + +import java.util.Date; +import java.util.Objects; + +/** + * @author : kurisu + * @className : SecretReportHistoryVO + * @description : 智能通话池 + * @date: 2021-02-21 15:40 + */ +@Data +public class SecretReportHistoryVO { + private Long id; + /** + * 任务id + */ + private Long taskId; + /** + * 跟进类型 + */ + private Integer followType; + /** + * 跟进id + */ + private Long followRecordId; + /** + * 是否首次通话(针对跟进任务来说) + */ + private Boolean firstCall; + /** + * 通话id + */ + private String callId; + /** + * 工作人员id + */ + private Long staffId; + /** + * 工作人员名称 + */ + private String staffName; + /** + * 客户id + */ + private Long customerId; + /** + * 客户名称 + */ + private String customerName; + /** + * 车牌号 + */ + private String plateNo; + /** + * 呼叫类型 + */ + private CallTypeEnum callType; + /** + * 呼叫时间 + */ + private Date callTime; + /** + * 通话时长 + */ + private Long callDuration; + /** + * 门店id + */ + private Long shopId; + /** + * 集团id + */ + private Long groupId; + + public String getCallTypeDesc() { + if (Objects.isNull(callType)) { + return null; + } + return callType.getName(); + } +} diff --git a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java index c1d691e..feeaee1 100644 --- a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java +++ b/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; import cn.fw.security.auth.client.enums.AuthType; import cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO; import cn.fw.valhalla.domain.query.FollowPoolQueryVO; +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery; import cn.fw.valhalla.domain.query.StammkundePoolQueryVO; +import cn.fw.valhalla.domain.vo.SecretReportHistoryVO; import cn.fw.valhalla.domain.vo.follow.FollowDetailVO; import cn.fw.valhalla.domain.vo.pool.*; import cn.fw.valhalla.service.bus.follow.FollowBizService; @@ -161,4 +163,19 @@ public class PoolController { return failureWithMessage(QUERY_FAILURE); } } + + @GetMapping("/secret/report/list") + @IgnoreAuth + public Message> reportList(@CurrentUser LoginAuthBean currentUser, final SecretReportHistoryQuery queryVO) { + final String msg = "查询智能通话记录池列表[pool/clue/list]"; + try { + log.info("{}: param[{}]", msg, queryVO); + queryVO.setGroupId(currentUser.getGroupId()); + AppPage page = poolBizService.secretReportList(queryVO); + return success(page, data -> log.info("dataSize: {}", CollectionUtils.isEmpty(data.getData()) ? 0 : data.getData().size())); + } catch (Exception ex) { + handleException(ex, e -> log.error("{}失败:param[{}]", msg, queryVO.getTaskType(), e)); + return failureWithMessage(QUERY_FAILURE); + } + } } diff --git a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java index 8ceae0b..7dab208 100644 --- a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java +++ b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java @@ -90,7 +90,6 @@ public class CallReportDealTask { dto.setStaffId(info.getId()); dto.setGroupId(info.getGroupId()); } - // todo 记录通话记录(报表用) followBizService.readCallReport(dto, true, queryAccidentCar(mobileNo, groupId)); followBizService.readCallReport(dto, false, queryCustomerIds(mobileNo, groupId)); } catch (Exception e) { diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java index b15205f..be15527 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java @@ -1,8 +1,10 @@ package cn.fw.valhalla.component; +import cn.fw.pstn.sdk.enums.DialTypeEnum; import cn.fw.pstn.sdk.mq.CallReport; import cn.fw.valhalla.common.utils.StringUtils; import cn.fw.valhalla.domain.dto.CallReportDTO; +import cn.fw.valhalla.domain.enums.CallTypeEnum; import cn.fw.valhalla.rpc.ehr.EhrRpcService; import cn.fw.valhalla.rpc.ehr.dto.StaffInfoDTO; import com.alibaba.fastjson.JSON; @@ -52,6 +54,10 @@ public class CallReportConsumer implements RocketMQListener { } CallReportDTO dto = new CallReportDTO(); BeanUtils.copyProperties(t, dto); + dto.setDialType(CallTypeEnum.CALL); + if (DialTypeEnum.P_CALL.equals(t.getCallType())) { + dto.setDialType(CallTypeEnum.P_CALL); + } String staffMobile = t.getStaffMobile(); if (StringUtils.isEmpty(staffMobile)) { return; @@ -59,6 +65,7 @@ public class CallReportConsumer implements RocketMQListener { StaffInfoDTO info = ehrRpcService.queryStaffInfoByMobile(staffMobile); if (Objects.nonNull(info)) { dto.setStaffId(info.getId()); + dto.setStaffName(info.getName()); dto.setGroupId(info.getGroupId()); } redisTemplate.opsForList().rightPush(getCallReportKey(), JSONObject.toJSONString(dto)); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java index b7ea1eb..f93ff69 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java +++ b/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; import cn.fw.valhalla.common.utils.DateUtil; import cn.fw.valhalla.domain.db.ApproveRecord; import cn.fw.valhalla.domain.db.OriginalData; +import cn.fw.valhalla.domain.db.SecretReportHistory; import cn.fw.valhalla.domain.db.follow.FollowRecord; +import cn.fw.valhalla.domain.db.follow.FollowRecordLog; import cn.fw.valhalla.domain.db.follow.FollowTask; import cn.fw.valhalla.domain.db.pool.CustomerCluePool; import cn.fw.valhalla.domain.dto.CallReportDTO; @@ -23,10 +25,7 @@ import cn.fw.valhalla.rpc.flow.FlowApproveRpc; import cn.fw.valhalla.rpc.flow.dto.FlowDto; import cn.fw.valhalla.sdk.enums.DataTypeEnum; import cn.fw.valhalla.service.bus.follow.strategy.FollowStrategy; -import cn.fw.valhalla.service.data.ApproveRecordService; -import cn.fw.valhalla.service.data.CustomerCluePoolService; -import cn.fw.valhalla.service.data.FollowRecordService; -import cn.fw.valhalla.service.data.FollowTaskService; +import cn.fw.valhalla.service.data.*; import cn.fw.valhalla.service.event.TaskCancelEvent; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.Getter; @@ -67,6 +66,8 @@ public class FollowBizService { private final UserService userService; private final DistributedLocker distributedLocker; private final CustomerCluePoolService customerCluePoolService; + private final SecretReportHistoryService secretReportHistoryService; + private final FollowRecordLogService followRecordLogService; @Value("${follow.flowNo}") @Getter @@ -84,7 +85,9 @@ public class FollowBizService { final FollowRecordService followRecordService, final UserService userService, final DistributedLocker distributedLocker, - final CustomerCluePoolService customerCluePoolService) { + final CustomerCluePoolService customerCluePoolService, + final SecretReportHistoryService secretReportHistoryService, + final FollowRecordLogService followRecordLogService) { this.followMap = followStrategyList.stream().collect(Collectors.toMap(FollowStrategy::getFollowType, v -> v)); this.flowApproveRpc = flowApproveRpc; this.approveRecordService = approveRecordService; @@ -93,6 +96,8 @@ public class FollowBizService { this.userService = userService; this.distributedLocker = distributedLocker; this.customerCluePoolService = customerCluePoolService; + this.secretReportHistoryService = secretReportHistoryService; + this.followRecordLogService = followRecordLogService; } /** @@ -493,7 +498,7 @@ public class FollowBizService { .last(" limit 1") ); if (Objects.nonNull(cluePool)) { - completeRecord(cluePool.getId(), staffId, dto.getCallId()); + completeRecord(dto, cluePool.getId(), staffId, dto.getCallId()); } } else { List list = customerCluePoolService.list(Wrappers.lambdaQuery() @@ -502,7 +507,7 @@ public class FollowBizService { .in(CustomerCluePool::getRefererId, Arrays.asList(idArr)) ); if (!CollectionUtils.isEmpty(list)) { - list.forEach(cluePool -> completeRecord(cluePool.getId(), staffId, dto.getCallId())); + list.forEach(cluePool -> completeRecord(dto, cluePool.getId(), staffId, dto.getCallId())); } } } @@ -544,7 +549,7 @@ public class FollowBizService { ) > 0; } - private void completeRecord(final Long clueId, final Long staffId, final String callId) { + private void completeRecord(CallReportDTO reportDTO, final Long clueId, final Long staffId, final String callId) { FollowTask followTask = followTaskService.queryOngoingTaskByClueId(clueId); if (Objects.isNull(followTask)) { return; @@ -564,6 +569,7 @@ public class FollowBizService { FollowStrategy strategy = followMap.get(followType); Assert.notNull(strategy, "strategy cannot be null"); + List reportHistoryList = new ArrayList<>(); for (FollowRecord record : list) { FollowAttachmentDTO dto = new FollowAttachmentDTO(); @@ -573,6 +579,31 @@ public class FollowBizService { dto.setFeedbackType(FollowTypeEnum.AC.equals(followType) ? FeedbackTypeEnum.OTHER.getValue() : null); dto.setAttType(AttTypeEnum.SMART_PHONE.getValue()); strategy.uploadAtt(dto, staffId); + reportHistoryList.add(createHistory(reportDTO, record, followType)); } + secretReportHistoryService.saveBatch(reportHistoryList); + } + + + private SecretReportHistory createHistory(CallReportDTO reportDTO, FollowRecord record, FollowTypeEnum followTypeEnum) { + SecretReportHistory history = new SecretReportHistory(); + history.setTaskId(record.getTaskId()); + history.setTaskType(followTypeEnum); + history.setFollowRecordId(record.getId()); + history.setCallId(reportDTO.getCallId()); + history.setStaffId(reportDTO.getStaffId()); + history.setStaffName(reportDTO.getStaffName()); + history.setCustomerId(record.getCustomerId()); + history.setCallType(reportDTO.getDialType()); + history.setCallTime(reportDTO.getCallTime()); + history.setCallDuration(reportDTO.getTalkTime()); + history.setShopId(record.getShopId()); + history.setGroupId(record.getGroupId()); + int count = followRecordLogService.count(Wrappers.lambdaQuery() + .eq(FollowRecordLog::getTaskId, record.getTaskId()) + .eq(FollowRecordLog::getAttType, AttTypeEnum.SMART_PHONE) + ); + history.setFirstCall(count <= 0); + return history; } } diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java index ed753f1..f150b0d 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java +++ b/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; import cn.fw.valhalla.domain.db.pool.PublicPool; import cn.fw.valhalla.domain.dto.CustomerCluePoolDTO; import cn.fw.valhalla.domain.dto.FollowPoolDTO; +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO; import cn.fw.valhalla.domain.dto.StammkundePoolDTO; import cn.fw.valhalla.domain.enums.*; -import cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO; -import cn.fw.valhalla.domain.query.FollowPoolQueryVO; -import cn.fw.valhalla.domain.query.PoolQuery; -import cn.fw.valhalla.domain.query.StammkundePoolQueryVO; +import cn.fw.valhalla.domain.query.*; import cn.fw.valhalla.domain.vo.AppPageVO; +import cn.fw.valhalla.domain.vo.SecretReportHistoryVO; import cn.fw.valhalla.domain.vo.pool.*; import cn.fw.valhalla.rpc.erp.UserService; import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; @@ -55,6 +54,7 @@ public class PoolBizService { private final UserService userService; private final AffiliationRecordService affiliationRecordService; private final OrderRpcService orderRpcService; + private final SecretReportHistoryService secretReportHistoryService; /** @@ -191,6 +191,32 @@ public class PoolBizService { return vo; } + /** + * 查询通话记录池 + * + * @param query + * @return + */ + public AppPage secretReportList(SecretReportHistoryQuery query) { + BV.isNotEmpty(query.getShopIds(), () -> "人员权限范围不正确,请确认是否有管理权限"); + AppPageVO page = AppPageVO.init(query); + long total = secretReportHistoryService.secretReportCount(query); + if (total <= 0) { + return page; + } + page.setTotal(total); + List list = secretReportHistoryService.secretReportList(query); + List appList = new ArrayList<>(); + for (SecretReportHistoryDTO dto : list) { + SecretReportHistoryVO vo = new SecretReportHistoryVO(); + BeanUtils.copyProperties(dto, vo); + vo.setCallType(CallTypeEnum.ofValue(dto.getDialType())); + appList.add(vo); + } + page.setData(appList); + return page; + } + private FollowPoolListVO trans2FollowPool(FollowPoolDTO poolDTO) { FollowPoolListVO vo = new FollowPoolListVO(); BeanUtils.copyProperties(poolDTO, vo); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java new file mode 100644 index 0000000..78c44c2 --- /dev/null +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java @@ -0,0 +1,30 @@ +package cn.fw.valhalla.service.data; + +import cn.fw.valhalla.domain.db.SecretReportHistory; +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO; +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * @author : kurisu + * @className : SecretReportHistoryService + * @description : 通话记录 + * @date: 2021-02-21 14:58 + */ +public interface SecretReportHistoryService extends IService { + /** + * 通话记录池 + * @param query + * @return + */ + List secretReportList(SecretReportHistoryQuery query); + + /** + * 查询总数 + * @param query + * @return + */ + Long secretReportCount(SecretReportHistoryQuery query); +} diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java new file mode 100644 index 0000000..beb4e5c --- /dev/null +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java @@ -0,0 +1,37 @@ +package cn.fw.valhalla.service.data.impl; + +import cn.fw.valhalla.dao.mapper.SecretReportHistoryMapper; +import cn.fw.valhalla.domain.db.SecretReportHistory; +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO; +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery; +import cn.fw.valhalla.service.data.SecretReportHistoryService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * @author : kurisu + * @className : SecretReportHistoryServiceImpl + * @description : 通话记录 + * @date: 2021-02-21 14:58 + */ +@Slf4j +@Service +public class SecretReportHistoryServiceImpl extends ServiceImpl implements SecretReportHistoryService { + @Override + public List secretReportList(SecretReportHistoryQuery queryVO) { + Integer current = queryVO.getCurrent(); + Integer pageSize = queryVO.getPageSize(); + Integer startIndex = (current - 1) * pageSize; + return Optional.ofNullable(getBaseMapper().secretReportList(startIndex, pageSize, queryVO)).orElse(new ArrayList<>()); + } + + @Override + public Long secretReportCount(SecretReportHistoryQuery query) { + return Optional.ofNullable(getBaseMapper().secretReportCount(query)).orElse(0L); + } +} -- libgit2 0.22.2