diff --git a/cms/local-repo/com/pudonghot/yo/yo-cms-web/0.0.1-SNAPSHOT/yo-cms-web-0.0.1-SNAPSHOT.jar b/cms/local-repo/com/pudonghot/yo/yo-cms-web/0.0.1-SNAPSHOT/yo-cms-web-0.0.1-SNAPSHOT.jar index e94b35e9..d3947aa3 100644 Binary files a/cms/local-repo/com/pudonghot/yo/yo-cms-web/0.0.1-SNAPSHOT/yo-cms-web-0.0.1-SNAPSHOT.jar and b/cms/local-repo/com/pudonghot/yo/yo-cms-web/0.0.1-SNAPSHOT/yo-cms-web-0.0.1-SNAPSHOT.jar differ diff --git a/cms/src/main/java/com/pudonghot/yo/cms/form/create/CreateFormSequence.java b/cms/src/main/java/com/pudonghot/yo/cms/form/create/CreateFormSequence.java index b32bb5cc..a68c2733 100644 --- a/cms/src/main/java/com/pudonghot/yo/cms/form/create/CreateFormSequence.java +++ b/cms/src/main/java/com/pudonghot/yo/cms/form/create/CreateFormSequence.java @@ -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) diff --git a/cms/src/main/resources/application.properties b/cms/src/main/resources/application.properties index 480bae2d..17622470 100644 --- a/cms/src/main/resources/application.properties +++ b/cms/src/main/resources/application.properties @@ -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 diff --git a/fsagent/src/main/resources/application.properties b/fsagent/src/main/resources/application.properties index 7f304eb3..2b353432 100644 --- a/fsagent/src/main/resources/application.properties +++ b/fsagent/src/main/resources/application.properties @@ -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 diff --git a/fsagent/src/main/resources/templates/dialplan/agent-to-agent.xml b/fsagent/src/main/resources/templates/dialplan/agent-to-agent.xml index e8d8ee2b..fd46fce9 100644 --- a/fsagent/src/main/resources/templates/dialplan/agent-to-agent.xml +++ b/fsagent/src/main/resources/templates/dialplan/agent-to-agent.xml @@ -26,7 +26,7 @@ - <#include "/dialplan/rec.xml"> + <#include "rec.xml"> - <#include "/dialplan/rec.xml"> + <#include "rec.xml"> - <#include "/dialplan/rec.xml"> + <#include "rec.xml"> diff --git a/fsagent/src/main/resources/templates/dialplan/local-extension.xml b/fsagent/src/main/resources/templates/dialplan/local-extension.xml index b95b10e0..dd6df574 100644 --- a/fsagent/src/main/resources/templates/dialplan/local-extension.xml +++ b/fsagent/src/main/resources/templates/dialplan/local-extension.xml @@ -26,7 +26,7 @@ - <#include "/dialplan/rec.xml"> + <#include "rec.xml"> - <#include "/dialplan/rec.xml"> + <#include "rec.xml"> + + diff --git a/lib/mapper/src/test/java/com/pudonghot/yo/mapper/WorkRecordMapperTest.java b/lib/mapper/src/test/java/com/pudonghot/yo/mapper/WorkRecordMapperTest.java new file mode 100644 index 00000000..0cf7ae5e --- /dev/null +++ b/lib/mapper/src/test/java/com/pudonghot/yo/mapper/WorkRecordMapperTest.java @@ -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)); + } +} diff --git a/lib/mapper/src/test/resources/application.properties b/lib/mapper/src/test/resources/application.properties index 275a1367..174e4e8b 100644 --- a/lib/mapper/src/test/resources/application.properties +++ b/lib/mapper/src/test/resources/application.properties @@ -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 diff --git a/lib/model/src/main/java/com/pudonghot/yo/model/domain/WorkRecord.java b/lib/model/src/main/java/com/pudonghot/yo/model/domain/WorkRecord.java new file mode 100644 index 00000000..9f8b4c70 --- /dev/null +++ b/lib/model/src/main/java/com/pudonghot/yo/model/domain/WorkRecord.java @@ -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 + } +} diff --git a/lib/model/src/main/java/com/pudonghot/yo/model/exception/ErrorCode.java b/lib/model/src/main/java/com/pudonghot/yo/model/exception/ErrorCode.java index 6d392276..965bdfda 100644 --- a/lib/model/src/main/java/com/pudonghot/yo/model/exception/ErrorCode.java +++ b/lib/model/src/main/java/com/pudonghot/yo/model/exception/ErrorCode.java @@ -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", "座席签入使用的用户名或者密码错误"), diff --git a/lib/mybatis-cache/src/test/resources/application.properties b/lib/mybatis-cache/src/test/resources/application.properties index 2a1ee2e3..9545a549 100644 --- a/lib/mybatis-cache/src/test/resources/application.properties +++ b/lib/mybatis-cache/src/test/resources/application.properties @@ -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 diff --git a/lib/redis/raw/src/test/resources/application.properties b/lib/redis/raw/src/test/resources/application.properties index 5952de3c..8babc457 100644 --- a/lib/redis/raw/src/test/resources/application.properties +++ b/lib/redis/raw/src/test/resources/application.properties @@ -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 diff --git a/lib/service-common/src/test/resources/application.properties b/lib/service-common/src/test/resources/application.properties index cd4201ac..3ca9e05b 100644 --- a/lib/service-common/src/test/resources/application.properties +++ b/lib/service-common/src/test/resources/application.properties @@ -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 diff --git a/openapi/src/main/java/com/pudonghot/yo/openapi/controller/WorkRecordController.java b/openapi/src/main/java/com/pudonghot/yo/openapi/controller/WorkRecordController.java new file mode 100644 index 00000000..ecddaaaf --- /dev/null +++ b/openapi/src/main/java/com/pudonghot/yo/openapi/controller/WorkRecordController.java @@ -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); + } +} diff --git a/openapi/src/main/java/com/pudonghot/yo/openapi/request/ReqSaveWorkRecord.java b/openapi/src/main/java/com/pudonghot/yo/openapi/request/ReqSaveWorkRecord.java new file mode 100644 index 00000000..cdcf518f --- /dev/null +++ b/openapi/src/main/java/com/pudonghot/yo/openapi/request/ReqSaveWorkRecord.java @@ -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; +} diff --git a/openapi/src/main/java/com/pudonghot/yo/openapi/service/WorkRecordService.java b/openapi/src/main/java/com/pudonghot/yo/openapi/service/WorkRecordService.java new file mode 100644 index 00000000..bf0dde10 --- /dev/null +++ b/openapi/src/main/java/com/pudonghot/yo/openapi/service/WorkRecordService.java @@ -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 { + + /** + * create work record + * @param req + */ + void create(ReqSaveWorkRecord req); +} diff --git a/openapi/src/main/java/com/pudonghot/yo/openapi/service/impl/WorkRecordServiceImpl.java b/openapi/src/main/java/com/pudonghot/yo/openapi/service/impl/WorkRecordServiceImpl.java new file mode 100644 index 00000000..d9bc5728 --- /dev/null +++ b/openapi/src/main/java/com/pudonghot/yo/openapi/service/impl/WorkRecordServiceImpl.java @@ -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 + 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); + } +} diff --git a/openapi/src/main/resources/application.properties b/openapi/src/main/resources/application.properties index 03954c5c..0f8be7ab 100644 --- a/openapi/src/main/resources/application.properties +++ b/openapi/src/main/resources/application.properties @@ -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 diff --git a/openapi/src/test/java/com/pudonghot/yo/openapi/TestDriver.java b/openapi/src/test/java/com/pudonghot/yo/openapi/TestDriver.java index 0e79fddf..7a8f8740 100644 --- a/openapi/src/test/java/com/pudonghot/yo/openapi/TestDriver.java +++ b/openapi/src/test/java/com/pudonghot/yo/openapi/TestDriver.java @@ -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
@@ -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); + } } diff --git a/state/src/main/java/com/pudonghot/yo/state/service/AgentService.java b/state/src/main/java/com/pudonghot/yo/state/service/AgentService.java index 1b9fa28f..c75aead5 100644 --- a/state/src/main/java/com/pudonghot/yo/state/service/AgentService.java +++ b/state/src/main/java/com/pudonghot/yo/state/service/AgentService.java @@ -8,12 +8,4 @@ import com.wacai.tigon.service.BaseCrudService; * Oct 26, 2019 15:59:44 */ public interface AgentService extends BaseCrudService { - - /** - * find valid agent - * @param tenantId tennat id - * @param account account - * @return agent - */ - Agent findValid(Integer tenantId, String account); } diff --git a/state/src/main/java/com/pudonghot/yo/state/service/impl/AgentServiceImpl.java b/state/src/main/java/com/pudonghot/yo/state/service/impl/AgentServiceImpl.java index 99e75938..21d4677a 100644 --- a/state/src/main/java/com/pudonghot/yo/state/service/impl/AgentServiceImpl.java +++ b/state/src/main/java/com/pudonghot/yo/state/service/impl/AgentServiceImpl.java @@ -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 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; - } } diff --git a/state/src/main/resources/application.properties b/state/src/main/resources/application.properties index 6dc1d05d..5caad1a8 100644 --- a/state/src/main/resources/application.properties +++ b/state/src/main/resources/application.properties @@ -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 diff --git a/web/cms/app/services/sequence/service.js b/web/cms/app/services/sequence/service.js index 85dd5b71..c9ad71db 100644 --- a/web/cms/app/services/sequence/service.js +++ b/web/cms/app/services/sequence/service.js @@ -22,7 +22,8 @@ export default Service.extend({ presence: true, numericality: { onlyInteger: true, - greaterThan: 1 + greaterThanOrEqualTo: 0, + lessThanOrEqualTo: 999999999 } }, step: {