|
|
@ -9,6 +9,7 @@ import com.baiye.module.dao.ReportTokerRepository;
|
|
|
|
import com.baiye.module.entity.ClueMiddle;
|
|
|
|
import com.baiye.module.entity.ClueMiddle;
|
|
|
|
import com.baiye.module.entity.ReportToker;
|
|
|
|
import com.baiye.module.entity.ReportToker;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
@ -20,6 +21,7 @@ import java.util.stream.Collectors;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
public class ReportSync {
|
|
|
|
public class ReportSync {
|
|
|
|
private final ClueMiddleRepository clueMiddleRepository;
|
|
|
|
private final ClueMiddleRepository clueMiddleRepository;
|
|
|
|
private final UserClient userClient;
|
|
|
|
private final UserClient userClient;
|
|
|
@ -28,14 +30,16 @@ public class ReportSync {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 每天晚上23点,定时统计外呼信息
|
|
|
|
* 每天晚上23点,定时统计外呼信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
// @Scheduled(cron = "0 0/5 * * * ? ")
|
|
|
|
@Scheduled(cron = "0 0 23 * * ? ")
|
|
|
|
@Scheduled(cron = "0 0 23 * * ? ")
|
|
|
|
// @Scheduled(cron = "0 0/1 * * * ? ")
|
|
|
|
|
|
|
|
public void reportToker() {
|
|
|
|
public void reportToker() {
|
|
|
|
|
|
|
|
log.info("拓客投流统计 开始------------------{}", DateUtil.date());
|
|
|
|
//当前时间
|
|
|
|
//当前时间
|
|
|
|
String beginOfDay = DateUtil.formatDateTime(DateUtil.yesterday());
|
|
|
|
String beginOfDay = DateUtil.formatDateTime(DateUtil.yesterday());
|
|
|
|
String endOfDay = DateUtil.formatDateTime(DateUtil.date());
|
|
|
|
String endOfDay = DateUtil.formatDateTime(DateUtil.date());
|
|
|
|
List<ReportToker> list = dealData(beginOfDay, endOfDay);
|
|
|
|
List<ReportToker> list = dealData(beginOfDay, endOfDay);
|
|
|
|
reportTokerRepository.saveAll(list);
|
|
|
|
reportTokerRepository.saveAll(list);
|
|
|
|
|
|
|
|
log.info("拓客投流统计 结束------------------{}", DateUtil.date());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<ReportToker> dealData(String beginOfDay, String endOfDay) {
|
|
|
|
public List<ReportToker> dealData(String beginOfDay, String endOfDay) {
|
|
|
@ -43,9 +47,6 @@ public class ReportSync {
|
|
|
|
List<Integer> clueTypes = Arrays.asList(ClueTypeConstants.TOKER_TYPE);
|
|
|
|
List<Integer> clueTypes = Arrays.asList(ClueTypeConstants.TOKER_TYPE);
|
|
|
|
List<ClueMiddle> clueMiddles = clueMiddleRepository.queryClueByClueType(beginOfDay, endOfDay, clueTypes);
|
|
|
|
List<ClueMiddle> clueMiddles = clueMiddleRepository.queryClueByClueType(beginOfDay, endOfDay, clueTypes);
|
|
|
|
List<ReportToker> list = new ArrayList<>();
|
|
|
|
List<ReportToker> list = new ArrayList<>();
|
|
|
|
int intention = 0;
|
|
|
|
|
|
|
|
int notIntention = 0;
|
|
|
|
|
|
|
|
int notTurnOn = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//按人员id分组
|
|
|
|
//按人员id分组
|
|
|
|
HashMap<Long, List<ClueMiddle>> mapByUserId = new HashMap<>(clueMiddles.stream().collect(Collectors.groupingBy(ClueMiddle::getMemberId, Collectors.toList())));
|
|
|
|
HashMap<Long, List<ClueMiddle>> mapByUserId = new HashMap<>(clueMiddles.stream().collect(Collectors.groupingBy(ClueMiddle::getMemberId, Collectors.toList())));
|
|
|
@ -53,21 +54,32 @@ public class ReportSync {
|
|
|
|
Map<Long, String> userNameList = userClient.findById(userIds);
|
|
|
|
Map<Long, String> userNameList = userClient.findById(userIds);
|
|
|
|
for (Long memberId : mapByUserId.keySet()) {
|
|
|
|
for (Long memberId : mapByUserId.keySet()) {
|
|
|
|
List<ClueMiddle> clueMiddlesByUserId = mapByUserId.get(memberId);
|
|
|
|
List<ClueMiddle> clueMiddlesByUserId = mapByUserId.get(memberId);
|
|
|
|
for (ClueMiddle clueMiddle : clueMiddlesByUserId) {
|
|
|
|
//任务分组
|
|
|
|
//标签
|
|
|
|
HashMap<Long, List<ClueMiddle>> mapByTaskId = new HashMap<>(clueMiddlesByUserId.stream().collect(Collectors.groupingBy(ClueMiddle::getTaskId, Collectors.toList())));
|
|
|
|
String sourceLabel = clueMiddle.getSourceLabel().get(0);
|
|
|
|
for (Long taskId : mapByTaskId.keySet()) {
|
|
|
|
switch (sourceLabel) {
|
|
|
|
List<ClueMiddle> clueMiddlesByTaskId = mapByTaskId.get(taskId);
|
|
|
|
case SourceLabelConstants.INTENTION:
|
|
|
|
int intention = 0;
|
|
|
|
intention += 1;
|
|
|
|
int notIntention = 0;
|
|
|
|
break;
|
|
|
|
int notTurnOn = 0;
|
|
|
|
case SourceLabelConstants.NOT_INTENTION:
|
|
|
|
for (ClueMiddle clueMiddle : clueMiddlesByTaskId) {
|
|
|
|
notIntention += 1;
|
|
|
|
//标签
|
|
|
|
break;
|
|
|
|
String sourceLabel = "";
|
|
|
|
case SourceLabelConstants.NOT_TURN_ON:
|
|
|
|
if (clueMiddle.getSourceLabel().size() > 0) {
|
|
|
|
notTurnOn += 1;
|
|
|
|
sourceLabel = clueMiddle.getSourceLabel().get(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
switch (sourceLabel) {
|
|
|
|
break;
|
|
|
|
case SourceLabelConstants.INTENTION:
|
|
|
|
|
|
|
|
intention += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SourceLabelConstants.NOT_INTENTION:
|
|
|
|
|
|
|
|
notIntention += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SourceLabelConstants.NOT_TURN_ON:
|
|
|
|
|
|
|
|
notTurnOn += 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ReportToker reportToker = new ReportToker();
|
|
|
|
ReportToker reportToker = new ReportToker();
|
|
|
|
reportToker.setIntention(intention);
|
|
|
|
reportToker.setIntention(intention);
|
|
|
@ -76,7 +88,7 @@ public class ReportSync {
|
|
|
|
reportToker.setCreateTime(DateUtil.date());
|
|
|
|
reportToker.setCreateTime(DateUtil.date());
|
|
|
|
reportToker.setMemberId(memberId);
|
|
|
|
reportToker.setMemberId(memberId);
|
|
|
|
reportToker.setMemberName(userNameList.get(memberId));
|
|
|
|
reportToker.setMemberName(userNameList.get(memberId));
|
|
|
|
reportToker.setTaskId(clueMiddle.getTaskId());
|
|
|
|
reportToker.setTaskId(taskId);
|
|
|
|
list.add(reportToker);
|
|
|
|
list.add(reportToker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|