opt redial
This commit is contained in:
parent
122b49431c
commit
96b7dada5d
@ -78,11 +78,17 @@ public class CallingListServiceImpl
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int redial(final FormRedial form) {
|
||||
val arg = form.copy(new ReqCallingListRedial());
|
||||
arg.setOperator(form.getAuthUser());
|
||||
log.info("RedialCallingList|{}", arg);
|
||||
return mapper.redial(arg);
|
||||
mapper.redial(arg);
|
||||
mapper.removeAnswered(arg);
|
||||
mapper.removeCalled7Times(arg);
|
||||
mapper.removeCalledTwiceToday(arg);
|
||||
mapper.removeCalledIn4Hours(arg);
|
||||
return mapper.readyRedial(arg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,46 @@ public interface CallingListMapper extends BaseMapper<Integer, CallingList> {
|
||||
*/
|
||||
int redial(@Param("arg") ReqCallingListRedial arg);
|
||||
|
||||
/**
|
||||
* 删除接通过
|
||||
*
|
||||
* @param arg arg
|
||||
* @return update rows
|
||||
*/
|
||||
int removeAnswered(@Param("arg") ReqCallingListRedial arg);
|
||||
|
||||
/**
|
||||
* 删除拨打超过7次
|
||||
*
|
||||
* @param arg arg
|
||||
* @return update rows
|
||||
*/
|
||||
int removeCalled7Times(@Param("arg") ReqCallingListRedial arg);
|
||||
|
||||
/**
|
||||
* 删除今日拨打超过1次
|
||||
*
|
||||
* @param arg arg
|
||||
* @return update rows
|
||||
*/
|
||||
int removeCalledTwiceToday(@Param("arg") ReqCallingListRedial arg);
|
||||
|
||||
/**
|
||||
* 删除4小时内拨打过
|
||||
*
|
||||
* @param arg arg
|
||||
* @return update rows
|
||||
*/
|
||||
int removeCalledIn4Hours(@Param("arg") ReqCallingListRedial arg);
|
||||
|
||||
/**
|
||||
* Ready redial
|
||||
*
|
||||
* @param arg arg
|
||||
* @return update rows
|
||||
*/
|
||||
int readyRedial(@Param("arg") ReqCallingListRedial arg);
|
||||
|
||||
/**
|
||||
* insert prepared calling list
|
||||
*
|
||||
|
@ -81,52 +81,15 @@
|
||||
</select>
|
||||
|
||||
<update id="redial">
|
||||
update br_calling_list c
|
||||
update <include refid="table" /> c
|
||||
|
||||
<!-- 过去接通过 -->
|
||||
<![CDATA[
|
||||
left join (select called_number
|
||||
from br_call_detail_record
|
||||
where start_stamp > date(subdate(now(), 21))
|
||||
group by called_number
|
||||
having count(answer_stamp) > 0) t1
|
||||
]]>
|
||||
on c.phone = t1.called_number
|
||||
<!-- 过去累计拨打次数超过7 -->
|
||||
<![CDATA[
|
||||
left join (select called_number
|
||||
from br_call_detail_record
|
||||
where start_stamp > date(subdate(now(), 21))
|
||||
group by called_number
|
||||
having count(id) > 7) t2
|
||||
]]>
|
||||
on c.phone = t2.called_number
|
||||
<!-- 今日拨打次数超过1 -->
|
||||
<![CDATA[
|
||||
left join (select called_number
|
||||
from br_call_detail_record
|
||||
where start_stamp > date(now())
|
||||
group by called_number
|
||||
having count(id) > 1) t3
|
||||
]]>
|
||||
on c.phone = t3.called_number
|
||||
<!-- 4小时内拨打过 -->
|
||||
<![CDATA[
|
||||
left join (select called_number
|
||||
from br_call_detail_record
|
||||
where start_stamp > date(now())
|
||||
group by called_number
|
||||
having max(start_stamp) > now() - interval 4 hour) t4
|
||||
]]>
|
||||
on c.phone = t4.called_number
|
||||
|
||||
set c.status = 'READY',
|
||||
c.daily_from = time_to_sec(now()),
|
||||
c.daily_to = time_to_sec(now() + interval 2 hour),
|
||||
set c.status = 'REDIAL',
|
||||
c.note = concat('REDIAL_', c.note),
|
||||
c.updated_by = #{arg.operator}
|
||||
c.updated_by = #{arg.operator},
|
||||
c.updated_time = now()
|
||||
|
||||
where c.campaign_id = #{arg.campaignId}
|
||||
where c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
@ -135,14 +98,244 @@
|
||||
and c.status = 'CALLED'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and last_call_start_time between
|
||||
now() - interval 12 hour
|
||||
and now() - interval 4 hour
|
||||
and c.last_call_start_time between
|
||||
date(now()) and now() - interval 4 hour
|
||||
</update>
|
||||
|
||||
and t1.called_number is null
|
||||
and t2.called_number is null
|
||||
and t3.called_number is null
|
||||
and t4.called_number is null
|
||||
<update id="removeAnswered">
|
||||
update <include refid="table" /> c
|
||||
|
||||
join (
|
||||
select c.phone
|
||||
from <include refid="table" /> c
|
||||
|
||||
join br_call_detail_record cdr
|
||||
on c.phone = cdr.called_number
|
||||
|
||||
<![CDATA[
|
||||
where cdr.start_stamp > date(now() - interval 21 day)
|
||||
and cdr.tenant_id = #{arg.tenantId}
|
||||
and cdr.answer_stamp is not null
|
||||
|
||||
and c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
date(now()) and now() - interval 4 hour
|
||||
|
||||
group by cdr.called_number
|
||||
having count(cdr.id) > 0
|
||||
]]>
|
||||
) t1
|
||||
on c.phone = t1.phone
|
||||
|
||||
set c.active = 0,
|
||||
c.note = 'Answered',
|
||||
c.updated_by = #{arg.operator},
|
||||
c.updated_time = now()
|
||||
|
||||
where c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
date(now()) and now() - interval 4 hour
|
||||
|
||||
</update>
|
||||
|
||||
<update id="removeCalled7Times">
|
||||
update <include refid="table" /> c
|
||||
|
||||
join (
|
||||
select c.phone
|
||||
from <include refid="table" /> c
|
||||
|
||||
join br_call_detail_record cdr
|
||||
on c.phone = cdr.called_number
|
||||
|
||||
<![CDATA[
|
||||
where cdr.start_stamp > date(now() - interval 21 day)
|
||||
and cdr.tenant_id = #{arg.tenantId}
|
||||
|
||||
and c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
date(now()) and now() - interval 4 hour
|
||||
|
||||
group by cdr.called_number
|
||||
having count(cdr.id) > 7
|
||||
]]>
|
||||
) t1
|
||||
on c.phone = t1.phone
|
||||
|
||||
set c.active = 0,
|
||||
c.note = 'Exceed 7 Times',
|
||||
c.updated_by = #{arg.operator},
|
||||
c.updated_time = now()
|
||||
|
||||
where c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
date(now()) and now() - interval 4 hour
|
||||
|
||||
</update>
|
||||
|
||||
<update id="removeCalledTwiceToday">
|
||||
update <include refid="table" /> c
|
||||
|
||||
join (
|
||||
select c.phone
|
||||
from <include refid="table" /> c
|
||||
|
||||
join br_call_detail_record cdr
|
||||
on c.phone = cdr.called_number
|
||||
|
||||
<![CDATA[
|
||||
where cdr.start_stamp > date(now())
|
||||
and cdr.tenant_id = #{arg.tenantId}
|
||||
|
||||
and c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
date(now()) and now() - interval 4 hour
|
||||
|
||||
group by cdr.called_number
|
||||
having count(cdr.id) > 1
|
||||
]]>
|
||||
) t1
|
||||
on c.phone = t1.phone
|
||||
|
||||
set c.active = 0,
|
||||
c.note = 'Exceed 1 Times Today',
|
||||
c.updated_by = #{arg.operator},
|
||||
c.updated_time = now()
|
||||
|
||||
where c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
date(now()) and now() - interval 4 hour
|
||||
</update>
|
||||
|
||||
<update id="removeCalledIn4Hours">
|
||||
update <include refid="table" /> c
|
||||
|
||||
join (
|
||||
select c.phone
|
||||
from <include refid="table" /> c
|
||||
|
||||
join br_call_detail_record cdr
|
||||
on c.phone = cdr.called_number
|
||||
|
||||
<![CDATA[
|
||||
where cdr.start_stamp > now() - interval 4 hour
|
||||
and cdr.tenant_id = #{arg.tenantId}
|
||||
|
||||
and c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
date(now()) and now() - interval 4 hour
|
||||
|
||||
group by cdr.called_number
|
||||
having count(cdr.id) > 0
|
||||
]]>
|
||||
) t1
|
||||
on c.phone = t1.phone
|
||||
|
||||
set c.active = 0,
|
||||
c.note = 'Called In 4 Hours',
|
||||
c.updated_by = #{arg.operator},
|
||||
c.updated_time = now()
|
||||
|
||||
where c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
date(now())
|
||||
and now() - interval 4 hour
|
||||
</update>
|
||||
|
||||
<update id="readyRedial">
|
||||
update <include refid="table" /> c
|
||||
|
||||
set c.status = 'READY',
|
||||
c.daily_from = time_to_sec(now()),
|
||||
c.daily_to = time_to_sec(now() + interval 2 hour),
|
||||
c.updated_by = #{arg.operator},
|
||||
c.updated_time = now()
|
||||
|
||||
where c.tenant_id = #{arg.tenantId}
|
||||
and c.campaign_id = #{arg.campaignId}
|
||||
and c.task_key = #{arg.taskKey}
|
||||
and c.daily_from = #{arg.dailyFrom}
|
||||
and c.daily_to = #{arg.dailyTo}
|
||||
and c.type = #{arg.type}
|
||||
and c.active = 1
|
||||
and c.status = 'REDIAL'
|
||||
and c.called_times = 1
|
||||
and c.last_call_duration = 0
|
||||
and c.last_call_start_time between
|
||||
now() - interval 12 hour
|
||||
and now() - interval 4 hour
|
||||
</update>
|
||||
|
||||
<insert id="insertPrepared">
|
||||
|
@ -37,14 +37,16 @@ public class CallingListMapperTest {
|
||||
@Test
|
||||
public void testRedial() {
|
||||
val arg = new ReqCallingListRedial();
|
||||
arg.setTenantId(1);
|
||||
arg.setOperator("donghuang");
|
||||
arg.setCampaignId(6);
|
||||
arg.setTaskKey("5f72bca1361812638aa13494");
|
||||
arg.setTaskKey("43AAAFC1F2B4C09B8DF1AF023458FA8");
|
||||
arg.setType(CallingList.Type.OLD);
|
||||
arg.setDailyFrom(new DailyTime(49200));
|
||||
arg.setDailyTo(new DailyTime(54000));
|
||||
arg.setDailyFrom(new DailyTime(52200));
|
||||
arg.setDailyTo(new DailyTime(72000));
|
||||
|
||||
val result = mapper.redial(arg);
|
||||
// val result = mapper.readyRedial(arg);
|
||||
log.info("Redial: {}", result);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import lombok.experimental.FieldNameConstants;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Table("br_calling_list")
|
||||
@Table("br_calling_list_test")
|
||||
@FieldNameConstants(prefix = "")
|
||||
public class CallingList extends BaseDomain {
|
||||
@NotUpdate
|
||||
@ -52,7 +52,7 @@ public class CallingList extends BaseDomain {
|
||||
private Date lockTime;
|
||||
|
||||
public enum Status {
|
||||
NOT_READY, READY, ACHIEVED, DIALING, CALLED, CANCELED, REVERT, BLOCKED
|
||||
NOT_READY, READY, ACHIEVED, DIALING, CALLED, CANCELED, REVERT, BLOCKED, REDIAL
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
@ -17,6 +17,7 @@ import com.pudonghot.yo.model.domain.CallingList;
|
||||
public class ReqCallingListRedial implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer tenantId;
|
||||
private String operator;
|
||||
private Integer campaignId;
|
||||
private CallingList.Type type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user