add agent status idle time
This commit is contained in:
parent
d6be550e1b
commit
1acb437c17
@ -1,12 +1,22 @@
|
||||
package com.pudonghot.yo.cms.controller;
|
||||
|
||||
import lombok.val;
|
||||
import com.wacai.tigon.form.FormList;
|
||||
import com.wacai.tigon.model.ViewModel;
|
||||
import me.chyxion.tigon.mybatis.Search;
|
||||
import com.wacai.tigon.model.ListResult;
|
||||
import com.pudonghot.yo.model.domain.Queue;
|
||||
import com.wacai.tigon.web.annotation.ListApi;
|
||||
import com.wacai.tigon.web.annotation.OrderCol;
|
||||
import com.wacai.tigon.web.controller.ArgQuery;
|
||||
import com.wacai.tigon.web.annotation.FilterCol;
|
||||
import com.pudonghot.yo.cms.auth.SessionAbility;
|
||||
import com.pudonghot.yo.cms.service.QueueService;
|
||||
import com.pudonghot.yo.model.domain.AgentStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.pudonghot.yo.cms.annotation.TenantResource;
|
||||
import com.wacai.tigon.web.controller.BaseQueryController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
@ -22,11 +32,32 @@ filterCols = {
|
||||
@FilterCol(param = AgentStatus.STATUS, type = AgentStatus.Status.class),
|
||||
@FilterCol(param = AgentStatus.STATE, type = AgentStatus.State.class),
|
||||
@FilterCol(param = AgentStatus.REGISTERED, type = boolean.class),
|
||||
@FilterCol(param = AgentStatus.QUEUE_ID, type = Integer.class, col = "qa.queue_id"),
|
||||
},
|
||||
orderCols = {
|
||||
@OrderCol(AgentStatus.IDLE_TIME)
|
||||
})
|
||||
@TenantResource
|
||||
@RequestMapping("/cms/api/agent-status")
|
||||
public class AgentStatusController
|
||||
extends BaseQueryController<Integer,
|
||||
AgentStatus,
|
||||
FormList> {
|
||||
FormList> implements SessionAbility {
|
||||
|
||||
@Autowired
|
||||
private QueueService queueService;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void after(final ArgQuery<?> arg) {
|
||||
super.after(arg);
|
||||
|
||||
if (arg.getType() == ArgQuery.Type.LIST) {
|
||||
val vmList = (ViewModel<ListResult<AgentStatus>>) arg.getResult();
|
||||
vmList.setAttr("queues", queueService.list(
|
||||
new Search(Queue.TENANT_ID, getTenantId())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.cms.controller;
|
||||
|
||||
import lombok.val;
|
||||
import java.util.Arrays;
|
||||
import com.wacai.tigon.form.FormList;
|
||||
import me.chyxion.tigon.mybatis.Search;
|
||||
@ -79,10 +80,10 @@ public class CampaignController
|
||||
|
||||
@RequestMapping("/create-data")
|
||||
public ViewModel<Campaign> createData() {
|
||||
final ArgQuery<ViewModel<Campaign>> argQuery = new ArgQuery<>();
|
||||
val argQuery = new ArgQuery<ViewModel<Campaign>>();
|
||||
argQuery.setController(getClass());
|
||||
argQuery.setType(ArgQuery.Type.FIND);
|
||||
final Campaign campaign = new Campaign();
|
||||
val campaign = new Campaign();
|
||||
campaign.setType(Campaign.Type.AGENT);
|
||||
campaign.setTargetType(Campaign.TargetType.QUEUE);
|
||||
campaign.setNumOfChannels(32);
|
||||
@ -98,7 +99,7 @@ public class CampaignController
|
||||
}
|
||||
|
||||
private void updateStatus(final Integer id, final Campaign.Status status) {
|
||||
final Campaign campaign = crudService.find(id);
|
||||
val campaign = crudService.find(id);
|
||||
Assert.state(campaign != null,
|
||||
() -> "Campaign [" + id + "] not found");
|
||||
Assert.state(campaign.getActive(),
|
||||
@ -123,7 +124,7 @@ public class CampaignController
|
||||
super.after(arg);
|
||||
final ViewModel<?> result = arg.getResult();
|
||||
|
||||
final Integer tenantId = getTenantId();
|
||||
val tenantId = getTenantId();
|
||||
result.attr("tagsList", tagService.list(
|
||||
new Search(Tag.TENANT_ID, tenantId)));
|
||||
result.attr("trunkStrategiesList",
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.pudonghot.yo.cms.service.impl;
|
||||
|
||||
import lombok.val;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.stream.Collectors;
|
||||
@ -144,13 +145,9 @@ public class AgentServiceImpl
|
||||
final Integer queueId,
|
||||
final SessionForm form) {
|
||||
|
||||
final QueueAgent arg = new QueueAgent();
|
||||
arg.setTenantId(form.getTenantId());
|
||||
arg.setTenantCode(form.getTenantCode());
|
||||
val arg = new QueueAgent();
|
||||
arg.setQueueId(queueId);
|
||||
arg.setAgentId(agent.getId());
|
||||
arg.setAccount(agent.getAccount());
|
||||
arg.setAgent(agent.getAgent());
|
||||
arg.setCreatedBy(form.getAuthUser());
|
||||
queueAgentMapper.insert(arg);
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.pudonghot.yo.cms.service.impl;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.wacai.tigon.model.ViewModel;
|
||||
import me.chyxion.tigon.mybatis.Search;
|
||||
import com.wacai.tigon.model.ListResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.pudonghot.yo.mapper.AgentStatusMapper;
|
||||
import com.pudonghot.yo.model.domain.AgentStatus;
|
||||
@ -10,10 +14,22 @@ import com.wacai.tigon.service.support.BaseQueryServiceSupport;
|
||||
* @author Donghuang <br>
|
||||
* Dec 24, 2019 16:49:51
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AgentStatusServiceImpl
|
||||
extends BaseQueryServiceSupport<Integer,
|
||||
AgentStatus,
|
||||
AgentStatusMapper>
|
||||
implements AgentStatusService {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ListResult<ViewModel<AgentStatus>> listViewModelsPage(final Search search) {
|
||||
log.debug("List agent status page by search [{}].", search);
|
||||
return new ListResult<>(
|
||||
toViewModel(mapper.cmsList(search)),
|
||||
mapper.cmsCount(search));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.pudonghot.yo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import me.chyxion.tigon.mybatis.Search;
|
||||
import me.chyxion.tigon.mybatis.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.pudonghot.yo.model.domain.AgentStatus;
|
||||
@ -78,4 +79,20 @@ public interface AgentStatusMapper extends BaseMapper<Integer, AgentStatus> {
|
||||
* @return updated rows
|
||||
*/
|
||||
int acwCleanup();
|
||||
|
||||
/**
|
||||
* cms count
|
||||
*
|
||||
* @param search search
|
||||
* @return count
|
||||
*/
|
||||
int cmsCount(@Param(PARAM_SEARCH_KEY) Search search);
|
||||
|
||||
/**
|
||||
* cms list
|
||||
*
|
||||
* @param search search
|
||||
* @return agent list
|
||||
*/
|
||||
List<AgentStatus> cmsList(@Param(PARAM_SEARCH_KEY) Search search);
|
||||
}
|
||||
|
@ -235,4 +235,21 @@
|
||||
)
|
||||
and s.idle_time is not null
|
||||
</sql>
|
||||
|
||||
<select id="cmsCount" resultType="int">
|
||||
select count(1)
|
||||
from <include refid="table"/> s
|
||||
left join br_queue_agent qa
|
||||
on s.agent_id = qa.agent_id
|
||||
<include refid="Tigon.searchForCount" />
|
||||
</select>
|
||||
|
||||
<select id="cmsList" resultType="com.pudonghot.yo.model.domain.AgentStatus">
|
||||
select s.*, qa.queue_id
|
||||
from <include refid="table"/> s
|
||||
left join br_queue_agent qa
|
||||
on s.agent_id = qa.agent_id
|
||||
<include refid="Tigon.search" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -5,6 +5,7 @@ import lombok.Setter;
|
||||
import java.util.Date;
|
||||
import me.chyxion.tigon.mybatis.Table;
|
||||
import me.chyxion.tigon.mybatis.NotUpdate;
|
||||
import me.chyxion.tigon.mybatis.Transient;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
/**
|
||||
@ -30,11 +31,18 @@ public class AgentStatus extends TenantDomain {
|
||||
private String eventKey;
|
||||
private String lockKey;
|
||||
private String checkRegKey;
|
||||
|
||||
/**
|
||||
* 空闲时间
|
||||
*/
|
||||
private Date idleTime;
|
||||
|
||||
/**
|
||||
* queue id
|
||||
*/
|
||||
@Transient
|
||||
private Integer queueId;
|
||||
|
||||
public enum Status {
|
||||
OFFLINE,
|
||||
READY,
|
||||
|
@ -15,16 +15,8 @@ import lombok.experimental.FieldNameConstants;
|
||||
@Table("br_queue_agent")
|
||||
@FieldNameConstants(prefix = "")
|
||||
public class QueueAgent extends BaseDomain {
|
||||
@NotUpdate
|
||||
private Integer tenantId;
|
||||
@NotUpdate
|
||||
private String tenantCode;
|
||||
@NotUpdate
|
||||
private Integer queueId;
|
||||
@NotUpdate
|
||||
private Integer agentId;
|
||||
@NotUpdate
|
||||
private String account;
|
||||
@NotUpdate
|
||||
private String agent;
|
||||
}
|
||||
|
@ -68,12 +68,8 @@ public class CommonCampaignServiceImpl
|
||||
}
|
||||
|
||||
val queueAgent = new QueueAgent();
|
||||
queueAgent.setTenantId(agent.getTenantId());
|
||||
queueAgent.setTenantCode(agent.getTenantCode());
|
||||
queueAgent.setQueueId(queueId);
|
||||
queueAgent.setAgentId(agentId);
|
||||
queueAgent.setAgent(agent.getAgent());
|
||||
queueAgent.setAccount(agent.getAccount());
|
||||
queueAgent.setCreatedBy(agent.getAccount());
|
||||
queueAgentMapper.insert(queueAgent);
|
||||
return queueId;
|
||||
|
@ -10,9 +10,6 @@
|
||||
<th>
|
||||
账户
|
||||
</th>
|
||||
<th>
|
||||
分机
|
||||
</th>
|
||||
<th>
|
||||
{{th-filter name='registered'
|
||||
text='注册状态'
|
||||
@ -42,6 +39,17 @@
|
||||
)
|
||||
}}
|
||||
</th>
|
||||
{{#sortable-th name='idleTime'}}
|
||||
空闲时间
|
||||
{{/sortable-th}}
|
||||
<th>
|
||||
{{th-filter name='queueId'
|
||||
text='队列'
|
||||
options=model.queues
|
||||
value-field='id'
|
||||
text-field='name'
|
||||
}}
|
||||
</th>
|
||||
<th>
|
||||
事件Key
|
||||
</th>
|
||||
@ -51,10 +59,7 @@
|
||||
{{#each model.data as |it|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{it.account}}
|
||||
</td>
|
||||
<td>
|
||||
{{it.agent}}
|
||||
{{it.account}}({{it.agent}})
|
||||
</td>
|
||||
<td>
|
||||
{{status-cell model=it
|
||||
@ -63,10 +68,21 @@
|
||||
disabled-text='离线'}}
|
||||
</td>
|
||||
<td>
|
||||
{{it.status}}
|
||||
{{option-text (array (hash value='READY' text='就绪')
|
||||
(hash value='NOT_READY' text='未就绪')
|
||||
(hash value='OFFLINE' text='离线')) it.status}}
|
||||
</td>
|
||||
<td>
|
||||
{{it.state}}
|
||||
{{option-text (array
|
||||
(hash value='IDLE' text='空闲')
|
||||
(hash value='IN_A_CALL' text='通话中')
|
||||
(hash value='ACW' text='话后事务')) it.state}}
|
||||
</td>
|
||||
<td>
|
||||
{{date-cell value=it.idleTime}}
|
||||
</td>
|
||||
<td>
|
||||
{{option-text model.queues it.queueId 'id' 'name'}}
|
||||
</td>
|
||||
<td>
|
||||
{{it.eventKey}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user