add list idle agent log
This commit is contained in:
parent
5f00590697
commit
a71798da69
@ -1,9 +1,10 @@
|
||||
package com.pudonghot.yo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import me.chyxion.tigon.mybatis.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.pudonghot.yo.model.domain.AgentStatus;
|
||||
import com.pudonghot.yo.mapper.request.ReqLockIdleOfQueue;
|
||||
import com.pudonghot.yo.mapper.request.LockIdleOfQueueMapperReq;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
@ -16,14 +17,21 @@ public interface AgentStatusMapper extends BaseMapper<Integer, AgentStatus> {
|
||||
*
|
||||
* @return idle agent locked
|
||||
*/
|
||||
int lockIdleOfQueue(@Param("arg") ReqLockIdleOfQueue arg);
|
||||
int lockIdleOfQueue(@Param("arg") LockIdleOfQueueMapperReq arg);
|
||||
|
||||
/**
|
||||
* lock idle agent of queue
|
||||
*
|
||||
* @return idle agent locked
|
||||
*/
|
||||
int lockIdleOfQueue2(@Param("arg") ReqLockIdleOfQueue arg);
|
||||
int lockIdleOfQueue2(@Param("arg") LockIdleOfQueueMapperReq arg);
|
||||
|
||||
/**
|
||||
* lock idle agent of queue
|
||||
*
|
||||
* @return idle agent locked
|
||||
*/
|
||||
List<AgentStatus> listIdleOfQueue(@Param("arg") LockIdleOfQueueMapperReq arg);
|
||||
|
||||
/**
|
||||
* lock idle agent of group
|
||||
|
@ -108,6 +108,23 @@
|
||||
s.updated_time = now()
|
||||
</update>
|
||||
|
||||
|
||||
<select id="listIdleOfQueue" resultType="com.pudonghot.yo.model.domain.AgentStatus">
|
||||
select s.*
|
||||
|
||||
from <include refid="table"/> s
|
||||
|
||||
join br_agent a
|
||||
on a.id = s.agent_id
|
||||
|
||||
join br_queue_agent qa
|
||||
on qa.agent_id = a.id
|
||||
|
||||
where qa.queue_id = #{arg.queueId}
|
||||
<include refid="idleCondition" />
|
||||
order by s.idle_time asc
|
||||
</select>
|
||||
|
||||
<update id="lockIdleOfGroup">
|
||||
update <include refid="table" /> s
|
||||
join (
|
||||
|
@ -12,7 +12,7 @@ import java.io.Serializable;
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ReqLockIdleOfQueue implements Serializable {
|
||||
public class LockIdleOfQueueMapperReq implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer tenantId;
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chyxion.tigon.mybatis.Search;
|
||||
import com.pudonghot.yo.mapper.request.ReqLockIdleOfQueue;
|
||||
import com.pudonghot.yo.mapper.request.LockIdleOfQueueMapperReq;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@ -36,7 +36,7 @@ public class AgentStatusMapperTest {
|
||||
|
||||
@Test
|
||||
public void testLockIdleOfQueue() {
|
||||
val arg = new ReqLockIdleOfQueue();
|
||||
val arg = new LockIdleOfQueueMapperReq();
|
||||
arg.setTenantId(1);
|
||||
arg.setCampaignId(6);
|
||||
arg.setQueueId(10);
|
||||
@ -48,7 +48,7 @@ public class AgentStatusMapperTest {
|
||||
@Test
|
||||
public void testLockIdleOfQueue2() {
|
||||
// TODO test lock idle of queue2
|
||||
val arg = new ReqLockIdleOfQueue();
|
||||
val arg = new LockIdleOfQueueMapperReq();
|
||||
arg.setTenantId(1);
|
||||
arg.setQueueId(10);
|
||||
|
||||
@ -57,6 +57,14 @@ public class AgentStatusMapperTest {
|
||||
log.info("Result [{}].", mapper.lockIdleOfQueue2(arg));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListIdleOfQueue2() {
|
||||
val arg = new LockIdleOfQueueMapperReq();
|
||||
arg.setTenantId(1);
|
||||
arg.setQueueId(15);
|
||||
log.info("Result [{}].", mapper.listIdleOfQueue(arg));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcwCleanup() {
|
||||
mapper.countOnlineOfQueue(1);
|
||||
|
@ -7,11 +7,12 @@ import java.util.function.Function;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import com.wacai.tigon.sequence.IdSequence;
|
||||
import com.pudonghot.yo.model.domain.Agent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import com.pudonghot.yo.service.CommonAgentService;
|
||||
import com.wacai.tigon.service.support.BaseServiceSupport;
|
||||
import com.pudonghot.yo.mapper.request.ReqLockIdleOfQueue;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.pudonghot.yo.mapper.request.LockIdleOfQueueMapperReq;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
@ -44,9 +45,12 @@ public class CommonAgentServiceImpl
|
||||
@Override
|
||||
public Agent lockIdleOfQueue(final Integer tenantId, final Integer campaignId, final Integer queueId) {
|
||||
log.info("Lock idle agent of queue [{}][{}][{}].", tenantId, campaignId, queueId);
|
||||
return lockIdle(lockKey ->
|
||||
agentStatusMapper.lockIdleOfQueue2(
|
||||
new ReqLockIdleOfQueue(tenantId, campaignId, queueId, lockKey, 1)));
|
||||
return lockIdle(lockKey -> {
|
||||
val req = new LockIdleOfQueueMapperReq(tenantId, campaignId, queueId, lockKey, 1);
|
||||
val agentStatusList = agentStatusMapper.listIdleOfQueue(req);
|
||||
log.info("Idle agent status [{}].", StringUtils.join(agentStatusList, "\n"));
|
||||
return agentStatusMapper.lockIdleOfQueue2(req);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user