add work record

This commit is contained in:
东皇大叔 2020-07-13 15:15:31 +08:00
parent 544c37b6d0
commit e089015173
28 changed files with 287 additions and 42 deletions

View File

@ -20,7 +20,8 @@ public class CreateFormSequence extends BaseCreateForm {
@Min(2)
@Max(16)
private int length;
@Min(1)
@Min(0)
@Max(999999999L)
@NotNull
private Long initVal;
@Min(1)

View File

@ -22,7 +22,7 @@ yo.fs.datasource.username=freeswitch
yo.fs.datasource.password=RR!h5IpirsnJ
# Redis
spring.redis.host=172.16.92.232
spring.redis.host=172.18.4.35
spring.redis.port=6379
spring.redis.password=123456

View File

@ -15,13 +15,13 @@ yo.datasource.url=jdbc:mysql://172.18.4.35/yoqw?useUnicode=true&characterEncodin
yo.datasource.username=yoqw
yo.datasource.password=yoqw_query!
# Datasource
# Datasource FreeSWITCH
yo.fs.datasource.url=jdbc:mysql://172.18.4.35/freeswitch?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
yo.fs.datasource.username=freeswitch
yo.fs.datasource.password=RR!h5IpirsnJ
# Redis
spring.redis.host=172.16.92.232
spring.redis.host=172.18.4.35
spring.redis.port=6379
spring.redis.password=123456

View File

@ -26,7 +26,7 @@
<action application="set" data="x_agent_type=${callerAgent.type}" />
<!-- Recording -->
<#include "/dialplan/rec.xml">
<#include "rec.xml">
<!-- /Recording -->
<!--

View File

@ -24,7 +24,7 @@
<action application="set" data="x_agent_type=${calledAgent.type}" />
<!-- Recording -->
<#include "/dialplan/rec.xml">
<#include "rec.xml">
<!-- /Recording -->
<!--

View File

@ -13,7 +13,7 @@
<!-- </#noparse> -->
<!-- Recording -->
<#include "/dialplan/rec.xml">
<#include "rec.xml">
<!-- /Recording -->
<action application="set" data="x_conn_id=${connId}" />

View File

@ -26,7 +26,7 @@
<action application="set" data="x_agent_type=${callerAgent.type}" />
<!-- Recording -->
<#include "/dialplan/rec.xml">
<#include "rec.xml">
<!-- /Recording -->
<!--

View File

@ -19,7 +19,7 @@
<action application="set" data="x_call_type=OUTBOUND" />
<!-- Recording -->
<#include "/dialplan/rec.xml">
<#include "rec.xml">
<!-- /Recording -->
<!--

View File

@ -0,0 +1,12 @@
package com.pudonghot.yo.mapper;
import com.wacai.tigon.mybatis.BaseMapper;
import com.pudonghot.yo.model.domain.WorkRecord;
/**
* @author Donghuang
* @date Jul 13, 2020 10:17:22
*/
public interface WorkRecordMapper extends BaseMapper<Integer, WorkRecord> {
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--
/**
* @author Donghuang
* @date Jul 13, 2020 10:20:37
*/
-->
<mapper namespace="com.pudonghot.yo.mapper.WorkRecordMapper">
</mapper>

View File

@ -0,0 +1,25 @@
package com.pudonghot.yo.mapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Donghuang
* @date Jul 13, 2020 10:22:12
*/
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath*:spring/spring-*.xml")
public class WorkRecordMapperTest {
@Autowired
private WorkRecordMapper mapper;
@Test
public void testList() {
log.info("Result [{}].", mapper.list(null));
}
}

View File

@ -6,6 +6,6 @@ yo.datasource.username=yoqw
yo.datasource.password=yoqw_query!
# Redis
spring.redis.host=172.16.92.232
spring.redis.host=172.18.4.35
spring.redis.port=6379
spring.redis.password=123456

View File

@ -0,0 +1,46 @@
package com.pudonghot.yo.model.domain;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import com.wacai.tigon.mybatis.Table;
import com.wacai.tigon.mybatis.NotUpdate;
import lombok.experimental.FieldNameConstants;
/**
* @author Donghuang
* @date Mar 09, 2020 16:11:08
*/
@Getter
@Setter
@Table("br_work_record")
@FieldNameConstants(prefix = "")
public class WorkRecord extends TenantDomain {
@NotUpdate
private Integer agentId;
@NotUpdate
private String account;
private String connId;
private String takePhone;
private Date callStartTime;
private Date callEndTime;
/**
* hangup type,
* 01 -> Agent hangup
* 02 -> Customer hangup
*/
private String hangupType;
private PackType packType;
private String packRemark;
public enum PackType {
/**
* business success
*/
Y,
/**
* business fail
*/
N
}
}

View File

@ -12,10 +12,14 @@ import lombok.RequiredArgsConstructor;
public enum ErrorCode {
NO_PERM("000-003", "没有权限调用接口"),
// 分机
DN_NOT_REGISTERED("001-001", "分机未注册"),
DN_OFFLINE("001-002", "分机已掉线"),
DN_IS_BUSY("001-003", "话机正忙"),
// 工作记录
WORK_RECORD_PARAM_ACCOUNT_NOT_MATCH("004-001", "工号参数不匹配"),
SIGN_IN_PARAM_ERROR("100-001", "座席签入的时候,登录参数为空或者参数异常"),
AGENT_SIGNED_IN("100-002", "坐席已签入"),
INVALID_ACCOUNT_OR_PASSWORD("100-004", "座席签入使用的用户名或者密码错误"),

View File

@ -1,7 +1,7 @@
spring.application.name=yo-mybatis-cache
# Redis
spring.redis.host=172.16.92.232
spring.redis.host=172.18.4.35
spring.redis.port=6379
spring.redis.password=123456

View File

@ -1,7 +1,7 @@
spring.application.name=yo-redis-raw
# Redis
spring.redis.host=172.16.92.232
spring.redis.host=172.18.4.35
spring.redis.port=6379
spring.redis.password=123456
spring.redis.database=0

View File

@ -14,7 +14,7 @@ yo.fs.datasource.username=freeswitch
yo.fs.datasource.password=RR!h5IpirsnJ
# Redis
spring.redis.host=172.16.92.232
spring.redis.host=172.18.4.35
spring.redis.port=6379
spring.redis.password=123456

View File

@ -0,0 +1,55 @@
package com.pudonghot.yo.openapi.controller;
import com.pudonghot.yo.model.domain.Agent;
import lombok.extern.slf4j.Slf4j;
import com.pudonghot.yo.model.domain.Tenant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import com.pudonghot.yo.model.exception.AssertUtils;
import com.pudonghot.yo.openapi.auth.SessionAbility;
import com.pudonghot.yo.openapi.service.AgentService;
import com.pudonghot.yo.openapi.request.ReqSaveWorkRecord;
import com.pudonghot.yo.openapi.service.WorkRecordService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import static com.pudonghot.yo.model.exception.ErrorCode.WORK_RECORD_PARAM_ACCOUNT_NOT_MATCH;
/**
* @author Donghuang
* @date Jul 13, 2020 11:44:13
*/
@Slf4j
@Controller
public class WorkRecordController implements SessionAbility {
@Autowired
private WorkRecordService workRecordService;
@Autowired
private AgentService agentService;
@PostMapping("/resource/receive_agent_post/{account}")
public void save(
@PathVariable("account")
final String account,
@RequestBody
final ReqSaveWorkRecord body) {
final Tenant tenant = getTenant();
final Integer tenantId = tenant.getId();
final Agent agent = agentService.findValid(tenantId, account);
final String bodyAccount = body.getAccount();
if (StringUtils.isNotBlank(bodyAccount)) {
AssertUtils.state(account.equals(bodyAccount), WORK_RECORD_PARAM_ACCOUNT_NOT_MATCH);
}
else {
body.setAccount(account);
}
body.setTenantId(tenantId);
body.setTenantCode(tenant.getCode());
body.setAgentId(agent.getId());
workRecordService.create(body);
}
}

View File

@ -0,0 +1,46 @@
package com.pudonghot.yo.openapi.request;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Date;
import com.pudonghot.yo.model.domain.WorkRecord;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
* @author Donghuang
* @date Jul 02, 2020 11:54:30
*/
@Getter
@Setter
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqSaveWorkRecord {
@JsonIgnore
private Integer tenantId;
@JsonIgnore
private String tenantCode;
@JsonIgnore
private Integer agentId;
@JsonAlias("work_no")
private String account;
@JsonAlias("call_id")
private String connId;
@JsonAlias("cust_phone")
private String takePhone;
@JsonAlias("call_begin_date")
@JsonFormat(shape = JsonFormat.Shape.STRING, timezone = "Asia/Shanghai", pattern = "yyyy-MM-dd HH:mm:ss")
private Date callStartTime;
@JsonAlias("call_end_date")
@JsonFormat(shape = JsonFormat.Shape.STRING, timezone = "Asia/Shanghai", pattern = "yyyy-MM-dd HH:mm:ss")
private Date callEndTime;
@JsonAlias("hang_up_way")
private String hangupType;
@JsonAlias("pack_type")
private WorkRecord.PackType packType;
@JsonAlias("pack_remark")
private String packRemark;
}

View File

@ -0,0 +1,18 @@
package com.pudonghot.yo.openapi.service;
import com.wacai.tigon.service.BaseCrudService;
import com.pudonghot.yo.model.domain.WorkRecord;
import com.pudonghot.yo.openapi.request.ReqSaveWorkRecord;
/**
* @author Donghuang
* @date Jul 13, 2020 10:24:57
*/
public interface WorkRecordService extends BaseCrudService<Integer, WorkRecord> {
/**
* create work record
* @param req
*/
void create(ReqSaveWorkRecord req);
}

View File

@ -0,0 +1,34 @@
package com.pudonghot.yo.openapi.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.pudonghot.yo.mapper.WorkRecordMapper;
import com.pudonghot.yo.model.domain.WorkRecord;
import com.pudonghot.yo.openapi.request.ReqSaveWorkRecord;
import com.pudonghot.yo.openapi.service.WorkRecordService;
import com.wacai.tigon.service.support.BaseCrudServiceSupport;
/**
* @author Donghuang
* @date Jul 13, 2020 10:25:41
*/
@Slf4j
@Service
public class WorkRecordServiceImpl
extends BaseCrudServiceSupport<Integer,
WorkRecord,
WorkRecordMapper>
implements WorkRecordService {
/**
* {@inheritDoc}
*/
@Override
public void create(final ReqSaveWorkRecord req) {
final WorkRecord workRecord = new WorkRecord();
BeanUtils.copyProperties(req, workRecord);
workRecord.setCreatedBy(workRecord.getAccount());
create(workRecord);
}
}

View File

@ -15,8 +15,13 @@ yo.datasource.url=jdbc:mysql://172.18.4.35/yoqw?useUnicode=true&characterEncodin
yo.datasource.username=yoqw
yo.datasource.password=yoqw_query!
# Datasource FreeSWITCH
yo.fs.datasource.url=jdbc:mysql://172.18.4.35/freeswitch?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
yo.fs.datasource.username=freeswitch
yo.fs.datasource.password=RR!h5IpirsnJ
# Redis
spring.redis.host=172.16.92.232
spring.redis.host=172.18.4.35
spring.redis.port=6379
spring.redis.password=123456

View File

@ -2,7 +2,10 @@ package com.pudonghot.yo.openapi;
import org.junit.Test;
import java.util.UUID;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pudonghot.yo.openapi.request.ReqSaveWorkRecord;
/**
* @author Donghuang <br>
@ -18,4 +21,12 @@ public class TestDriver {
+ Long.toHexString(uuid.getLeastSignificantBits());
log.info("UUID: {}", id);
}
@Test
public void testDeserializeJson() throws IOException {
final ObjectMapper objectMapper = new ObjectMapper();
final ReqSaveWorkRecord reqSaveWorkRecord =
objectMapper.readValue("{\"work_no\":\"8002\",\"call_id\":\"sas665448855-8878992544\",\"cust_phone\":\"13888888888\",\"pack_type\":\"Y\",\"pack_remark\":\"新快线外呼,营销成功\",\"call_begin_date\":\"2018-05-29 09:53:30\",\"call_end_date\":\"2018-05-29 09:53:59\",\"hang_up_way\":\"01\"}", ReqSaveWorkRecord.class);
log.info("Result [{}].", reqSaveWorkRecord);
}
}

View File

@ -8,12 +8,4 @@ import com.wacai.tigon.service.BaseCrudService;
* Oct 26, 2019 15:59:44
*/
public interface AgentService extends BaseCrudService<Integer, Agent> {
/**
* find valid agent
* @param tenantId tennat id
* @param account account
* @return agent
*/
Agent findValid(Integer tenantId, String account);
}

View File

@ -1,12 +1,9 @@
package com.pudonghot.yo.state.service.impl;
import com.pudonghot.yo.model.exception.AssertUtils;
import com.pudonghot.yo.model.exception.ErrorCode;
import com.pudonghot.yo.state.service.AgentService;
import com.wacai.tigon.mybatis.Search;
import org.springframework.stereotype.Service;
import com.pudonghot.yo.mapper.AgentMapper;
import com.pudonghot.yo.model.domain.Agent;
import org.springframework.stereotype.Service;
import com.pudonghot.yo.state.service.AgentService;
import com.wacai.tigon.service.support.BaseCrudServiceSupport;
/**
@ -17,17 +14,4 @@ import com.wacai.tigon.service.support.BaseCrudServiceSupport;
public class AgentServiceImpl
extends BaseCrudServiceSupport<Integer, Agent, AgentMapper>
implements AgentService {
/**
* {@inheritDoc}
*/
@Override
public Agent findValid(final Integer tenantId, final String account) {
final Agent agent = find(
new Search(Agent.TENANT_ID, tenantId)
.eq(Agent.ACCOUNT, account));
AssertUtils.state(agent != null, ErrorCode.AGENT_NOT_FOUND);
AssertUtils.state(agent.getActive(), ErrorCode.AGENT_DISABLED);
return agent;
}
}

View File

@ -10,7 +10,7 @@ yo.datasource.username=yoqw
yo.datasource.password=yoqw_query!
# Redis
spring.redis.host=172.16.92.232
spring.redis.host=172.18.4.35
spring.redis.port=6379
spring.redis.password=123456

View File

@ -22,7 +22,8 @@ export default Service.extend({
presence: true,
numericality: {
onlyInteger: true,
greaterThan: 1
greaterThanOrEqualTo: 0,
lessThanOrEqualTo: 999999999
}
},
step: {