fetch data to calling list prepared
This commit is contained in:
parent
d1113d152b
commit
097a53d4a7
1
campaign/callinglist.json
Normal file
1
campaign/callinglist.json
Normal file
@ -0,0 +1 @@
|
||||
{"retcode":"0","taskdata":[{"outid":"656694","phone":"18671402209"},{"outid":"656701","phone":"18339470008"},{"outid":"656708","phone":"13820815649"},{"outid":"656715","phone":"18620840613"},{"outid":"656722","phone":"18530024796"},{"outid":"656729","phone":"18337990129"},{"outid":"656736","phone":"13972751126"},{"outid":"656743","phone":"18048296447"},{"outid":"656750","phone":"15045375827"},{"outid":"656757","phone":"13552399373"},{"outid":"656764","phone":"13584900871"},{"outid":"656771","phone":"15112369347"},{"outid":"656778","phone":"18344011082"},{"outid":"656785","phone":"18789155467"},{"outid":"656792","phone":"18859590598"},{"outid":"656799","phone":"15736441459"},{"outid":"656806","phone":"13526890557"},{"outid":"656813","phone":"13819686988"},{"outid":"656820","phone":"15561105009"},{"outid":"656827","phone":"13503845660"},{"outid":"656834","phone":"17614804562"},{"outid":"656841","phone":"13713311129"},{"outid":"656848","phone":"13653333266"},{"outid":"656855","phone":"15522990086"}],"taskid":"5694"}
|
@ -1,7 +1,6 @@
|
||||
package com.pudonghot.yo.campaign.service.impl;
|
||||
|
||||
import lombok.val;
|
||||
import java.util.Map;
|
||||
import lombok.Setter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -21,13 +20,14 @@ import com.pudonghot.yo.mapper.CallingListMapper;
|
||||
import com.pudonghot.yo.model.domain.CallingList;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import com.pudonghot.yo.mapper.CallingListPreparedMapper;
|
||||
import com.pudonghot.yo.model.domain.CallingListPrepared;
|
||||
import com.pudonghot.yo.campaign.service.CampaignService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import com.pudonghot.yo.campaign.service.CallingListService;
|
||||
import com.wacai.tigon.service.support.BaseCrudServiceSupport;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.pudonghot.yo.campaign.feign.response.RespCallingList;
|
||||
import static com.pudonghot.yo.model.domain.Campaign.TargetType.QUEUE;
|
||||
import com.pudonghot.yo.campaign.feign.service.FeignCallingListService;
|
||||
|
||||
@ -47,6 +47,8 @@ public class CallingListServiceImpl
|
||||
private IdSequence idSeq;
|
||||
@Autowired
|
||||
private FeignCallingListService callingListService;
|
||||
@Autowired
|
||||
private CallingListPreparedMapper callingListPreparedMapper;
|
||||
|
||||
@Value("${yo.campaign.calling-list-lock-expire.seconds:300}")
|
||||
private int expireLockDuration;
|
||||
@ -56,7 +58,7 @@ public class CallingListServiceImpl
|
||||
@Scheduled(fixedRateString = "${yo.campaign.calling-list-lock-expire.rate:120000}")
|
||||
public void expireLock() {
|
||||
log.info("Expire calling list lock task.");
|
||||
final Map<String, Object> update = new HashMap<>(8);
|
||||
val update = new HashMap<String, Object>(8);
|
||||
update.put(CallingList.STATUS, CallingList.Status.READY);
|
||||
update.put(CallingList.LOCK_KEY, null);
|
||||
update.put(CallingList.LOCK_TIME, null);
|
||||
@ -108,8 +110,7 @@ public class CallingListServiceImpl
|
||||
callingListService.fetchCallingList(fetchSize,
|
||||
campaignKey,
|
||||
campaign.getName());
|
||||
final RespCallingList.CallingData[] data =
|
||||
callingList.getData();
|
||||
val data = callingList.getData();
|
||||
|
||||
if (data == null || data.length == 0) {
|
||||
log.error("Fetch calling list data error caused. code [{}], error [{}].",
|
||||
@ -122,26 +123,18 @@ public class CallingListServiceImpl
|
||||
campaignId, campaignKey, StringUtils.join(data, "|"));
|
||||
}
|
||||
|
||||
mapper.insert(Stream.of(data).map(it -> {
|
||||
final CallingList cl = new CallingList();
|
||||
cl.setTenantId(campaign.getTenantId());
|
||||
cl.setTenantCode(campaign.getTenantCode());
|
||||
cl.setCampaignId(campaignId);
|
||||
cl.setCampaignKey(campaignKey);
|
||||
cl.setDailyFrom(campaign.getDailyFrom());
|
||||
cl.setDailyTo(campaign.getDailyTo());
|
||||
cl.setStatus(CallingList.Status.NOT_READY);
|
||||
cl.setType(CallingList.Type.FRESH);
|
||||
cl.setTaskKey(taskKey);
|
||||
cl.setCaseKey(it.getCaseKey());
|
||||
cl.setPhone(PhoneNumberUtils.cleanupMobile(it.getPhone()));
|
||||
cl.setLastConnected(false);
|
||||
final Date now = new Date();
|
||||
cl.setAddedTime(now);
|
||||
cl.setCalledTimes(0);
|
||||
cl.setCreatedTime(now);
|
||||
cl.setNote("NEW_DATA");
|
||||
return cl;
|
||||
callingListPreparedMapper.insert(Stream.of(data).map(it -> {
|
||||
val record = new CallingListPrepared();
|
||||
record.setTenantId(campaign.getTenantId());
|
||||
record.setTenantCode(campaign.getTenantCode());
|
||||
record.setCampaignId(campaignId);
|
||||
record.setCampaignKey(campaignKey);
|
||||
record.setInsertBatchKey(taskKey);
|
||||
record.setCaseKey(it.getCaseKey());
|
||||
record.setPhone(PhoneNumberUtils.cleanupMobile(it.getPhone()));
|
||||
record.setAddedTime(new Date());
|
||||
record.setNote("NEW_DATA");
|
||||
return record;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
return true;
|
||||
@ -152,13 +145,13 @@ public class CallingListServiceImpl
|
||||
*/
|
||||
@Override
|
||||
public List<CallingList> listReady(final Integer campaignId, final int limit) {
|
||||
final String lockKey = idSeq.get();
|
||||
final Map<String, Object> update = new HashMap<>(8);
|
||||
val lockKey = idSeq.get();
|
||||
val update = new HashMap<String, Object>(8);
|
||||
update.put(CallingList.LOCK_KEY, lockKey);
|
||||
update.put(CallingList.LOCK_TIME, new Date());
|
||||
update.put(CallingList.STATUS, CallingList.Status.ACHIEVED);
|
||||
|
||||
final int secondOfDay = TimeUtils.secondOfDay(new Date());
|
||||
val secondOfDay = TimeUtils.secondOfDay(new Date());
|
||||
|
||||
mapper.update(update,
|
||||
new Search(CallingList.CAMPAIGN_ID, campaignId)
|
||||
|
@ -29,6 +29,8 @@ dubbo.registry.file=${user.home}/dubbo-cache/${spring.application.name}/dubbo.ca
|
||||
yo.fsagent.dubbo.service.version=1.0.0
|
||||
|
||||
# Calling List
|
||||
yo.campaign.feign.calling-list.base-url=http://localhost:8093/callinglist
|
||||
yo.campaign.feign.calling-list.channel=dx-hzqw
|
||||
#yo.campaign.feign.calling-list.base-url=http://localhost:8093/callinglist
|
||||
#yo.campaign.feign.calling-list.channel=dx-hzqw
|
||||
|
||||
yo.campaign.feign.calling-list.base-url=http://localhost:1116
|
||||
yo.campaign.feign.calling-list.channel=callinglist.json
|
||||
|
Loading…
x
Reference in New Issue
Block a user