Merge branch 'feature/2021' of 118.31.72.164:donghuang/yoqw into feature/2021
This commit is contained in:
commit
9e02cdf5c9
@ -1,6 +1,5 @@
|
||||
package com.pudonghot.yo.campaign.service.impl;
|
||||
|
||||
import com.pudonghot.yo.config.ConfigService;
|
||||
import lombok.val;
|
||||
import lombok.Setter;
|
||||
import java.util.*;
|
||||
@ -10,6 +9,7 @@ import com.pudonghot.yo.util.LogMDC;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chyxion.tigon.mybatis.Search;
|
||||
import com.pudonghot.yo.util.TimeUtils;
|
||||
import com.pudonghot.yo.config.ConfigService;
|
||||
import com.pudonghot.yo.mapper.CampaignMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.pudonghot.yo.model.domain.Campaign;
|
||||
@ -17,6 +17,8 @@ import com.pudonghot.yo.model.domain.BaseDomain;
|
||||
import com.pudonghot.yo.mapper.AgentStatusMapper;
|
||||
import com.pudonghot.yo.model.domain.CallingList;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import com.pudonghot.yo.mapper.PhoneBlacklistMapper;
|
||||
import com.pudonghot.yo.model.domain.PhoneBlacklist;
|
||||
import com.pudonghot.yo.service.CommonCallDataService;
|
||||
import com.pudonghot.yo.service.LeaderElectionService;
|
||||
import com.pudonghot.yo.fsagent.api.CampaignDialService;
|
||||
@ -61,6 +63,8 @@ public class CampaignServiceImpl
|
||||
private FeignCiticBlackListService blackListService;
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
@Autowired
|
||||
private PhoneBlacklistMapper phoneBlacklistMapper;
|
||||
|
||||
@Scheduled(fixedRateString = "${yo.campaign.task-scheduler.fixed-rate:6000}",
|
||||
initialDelayString = "${yo.campaign.task-scheduler.init-delay:32000}")
|
||||
@ -142,9 +146,24 @@ public class CampaignServiceImpl
|
||||
}
|
||||
|
||||
if (configService.isCiticBlackListBatch()) {
|
||||
val phonesBlacklist = new HashSet<String>(
|
||||
phoneBlacklistMapper.listCol(PhoneBlacklist.PHONE,
|
||||
new Search(PhoneBlacklist.TENANT_ID, campaign.getTenantId())
|
||||
.in(PhoneBlacklist.PHONE, callingLists.stream()
|
||||
.map(CallingList::getPhone)
|
||||
.collect(Collectors.toSet()))
|
||||
.isTrue(PhoneBlacklist.ACTIVE)));
|
||||
|
||||
removeBlacklist(callingLists, phonesBlacklist);
|
||||
if (callingLists.isEmpty()) {
|
||||
log.info("Campaign dial calling list all blocked, ignore.");
|
||||
return;
|
||||
}
|
||||
|
||||
val blackListVerifyRespData = blackListService.batchVerify(
|
||||
callingLists.stream().map(CallingList::getPhone)
|
||||
.collect(Collectors.toSet())).getData();
|
||||
callingLists.stream()
|
||||
.map(CallingList::getPhone)
|
||||
.collect(Collectors.toSet())).getData();
|
||||
|
||||
if (blackListVerifyRespData != null
|
||||
&& blackListVerifyRespData.length > 0) {
|
||||
@ -153,25 +172,7 @@ public class CampaignServiceImpl
|
||||
.map(BlackListFeignResp::getPhone)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (!blackList.isEmpty()) {
|
||||
log.info("Remove black list [{}].", blackList);
|
||||
val callingListIt = callingLists.iterator();
|
||||
while (callingListIt.hasNext()) {
|
||||
val it = callingListIt.next();
|
||||
|
||||
if (blackList.contains(it.getPhone())) {
|
||||
log.info("Calling list [{}] is in black list, update status to BLOCKED.", it);
|
||||
|
||||
it.setStatus(CallingList.Status.BLOCKED);
|
||||
it.setUpdatedTime(new Date());
|
||||
it.setUpdatedBy(BaseDomain.SYSTEM);
|
||||
callingListService.update(it);
|
||||
|
||||
// remove from list
|
||||
callingListIt.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
removeBlacklist(callingLists, blackList);
|
||||
|
||||
if (callingLists.isEmpty()) {
|
||||
log.info("Campaign dial calling list all blocked, ignore.");
|
||||
@ -189,4 +190,28 @@ public class CampaignServiceImpl
|
||||
log.info("Campaign [{}] dial [{}].", campaignId, dataList);
|
||||
dialService.queueDial(req);
|
||||
}
|
||||
|
||||
void removeBlacklist(final List<CallingList> callingLists,
|
||||
final Set<String> blacklist) {
|
||||
|
||||
if (!blacklist.isEmpty()) {
|
||||
log.info("Remove black list [{}].", blacklist);
|
||||
val callingListIt = callingLists.iterator();
|
||||
while (callingListIt.hasNext()) {
|
||||
val it = callingListIt.next();
|
||||
|
||||
if (blacklist.contains(it.getPhone())) {
|
||||
log.info("Calling list [{}] is in black list, update status to BLOCKED.", it);
|
||||
|
||||
it.setStatus(CallingList.Status.BLOCKED);
|
||||
it.setUpdatedTime(new Date());
|
||||
it.setUpdatedBy(BaseDomain.SYSTEM);
|
||||
callingListService.update(it);
|
||||
|
||||
// remove from list
|
||||
callingListIt.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user