Commit 94138452 by lyhuang

呼叫弹屏功能添加

parent 3cf033f7
...@@ -2,8 +2,11 @@ package com.ctrip.fun.admin.controller.tools; ...@@ -2,8 +2,11 @@ package com.ctrip.fun.admin.controller.tools;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -17,17 +20,28 @@ import org.springframework.ui.ModelMap; ...@@ -17,17 +20,28 @@ import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError; import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.exception.CommonException; import com.ctrip.fun.admin.exception.CommonException;
import com.ctrip.fun.admin.form.tools.UserRegisterForm; import com.ctrip.fun.admin.form.tools.UserRegisterForm;
import com.ctrip.fun.admin.eventhandler.BindEventHandler;
import com.ctrip.fun.admin.eventhandler.BridgeEventHandler;
import com.ctrip.fun.admin.eventhandler.CdrEventHandler;
import com.ctrip.fun.admin.eventhandler.ChannelRouteEventHandler;
import com.ctrip.fun.admin.eventhandler.NewStateEventHandler;
import com.ctrip.fun.admin.eventhandler.QueueMemberPauseEventHandler;
import com.ctrip.fun.admin.eventhandler.SqeEventHandler;
import com.ctrip.fun.admin.service.system.UserService; import com.ctrip.fun.admin.service.system.UserService;
import com.ctrip.fun.admin.service.tools.CallCenterService; import com.ctrip.fun.admin.service.tools.CallCenterService;
import com.ctrip.fun.admin.utility.Util; import com.ctrip.fun.admin.utility.Util;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
import com.ctrip.fun.common.vo.PagedResponseBean; import com.ctrip.fun.common.vo.PagedResponseBean;
import com.ctrip.fun.common.vo.basic.UserExtQuery; import com.ctrip.fun.common.vo.basic.UserExtQuery;
import com.ctrip.fun.common.vo.user.RegisterBean; import com.ctrip.fun.common.vo.user.RegisterBean;
...@@ -44,6 +58,19 @@ public class CallCenterController { ...@@ -44,6 +58,19 @@ public class CallCenterController {
private static final Logger logger = LoggerFactory.getLogger(CallCenterController.class); private static final Logger logger = LoggerFactory.getLogger(CallCenterController.class);
public static final Map<String, AbstractEventHandler> eventHandlerMap = new ConcurrentHashMap<String, AbstractEventHandler>() {
private static final long serialVersionUID = 1565306516357059751L;
{
put("cdrEvent", new CdrEventHandler());
put("newStateEvent",new NewStateEventHandler());
put("bridgeEvent",new BridgeEventHandler());
put("channelRouteEvent",new ChannelRouteEventHandler());
put("sqeEvent",new SqeEventHandler());
put("queueMemberPauseEvent",new QueueMemberPauseEventHandler());
put("bindEvent",new BindEventHandler());
}
};
@Autowired @Autowired
private CallCenterService ccService; private CallCenterService ccService;
...@@ -77,6 +104,51 @@ public class CallCenterController { ...@@ -77,6 +104,51 @@ public class CallCenterController {
} }
} }
/**
*
* @return
*/
@RequestMapping(value = "/callback", method = RequestMethod.POST)
public String callbackEvent(HttpServletRequest request, HttpServletResponse response, @RequestBody String eventJsonString) {
String result = "";
try {
// System.out.println("AAA controller: " + eventJsonString);
logger.debug("从" + request.getRemoteAddr() + "收到event:" + eventJsonString);
JSONObject commandJSONObject = null;
commandJSONObject = JSON.parseObject(eventJsonString);
String event = commandJSONObject.getString("event");
if(StringUtils.isBlank(event)){
result = "收到的消息缺少event字段: "+ eventJsonString;
logger.warn(result);
return result;
}
// 1)找出具体的命令实例。
logger.debug("event [" + event + "] is ready to execute...");
logger.debug(eventJsonString);
AbstractEventHandler eventHandler = eventHandlerMap.get(event);
// 2)执行命令并返回结果
if(eventHandler!=null){
result = eventHandler.handle(commandJSONObject);
}else{
result = "event=" + event + ", event字段有误,没有找到对应的eventHandler";
logger.warn("event=" + event + ", event字段有误,没有找到对应的eventHandler");
return result;
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
return e.getMessage();
}
return result;
}
@RequestMapping(value = "/userRegister", method = RequestMethod.POST) @RequestMapping(value = "/userRegister", method = RequestMethod.POST)
public String userRegister(HttpServletRequest request, @ModelAttribute("form") UserRegisterForm form, BindingResult binding, ModelMap model) { public String userRegister(HttpServletRequest request, @ModelAttribute("form") UserRegisterForm form, BindingResult binding, ModelMap model) {
String uid = null; String uid = null;
......
package com.ctrip.fun.admin.eventhandler;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
/**
*
*
* @author jyf
*
*/
public class BindEventHandler extends AbstractEventHandler {
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public String handle(JSONObject jsonObject) {
return"";
}
}
package com.ctrip.fun.admin.eventhandler;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
import com.ctrip.fun.admin.vo.callcenter.BridgeEvent;
/**
*
* channel bridge
*
* @author jyf
*
*/
public class BridgeEventHandler extends AbstractEventHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public String handle(JSONObject jsonObject) {
logger.debug(jsonObject.toJSONString());
/*BridgeEvent event = JSON.toJavaObject(jsonObject, BridgeEvent.class);
//1)处理群呼清理QqdCache.groupCallChannelMap的逻辑
String phoneNumber = event.getCallerInNumber1();
if(StringUtils.isNotBlank(phoneNumber)){
QqdCache.groupCallItemBeanMap.remove(phoneNumber);
logger.debug("MMMMMM 群呼正在接听清理号码:"+phoneNumber +" 内容为:"+JSON.toJSONString(QqdCache.groupCallItemBeanMap));
}*/
return"";
}
}
package com.ctrip.fun.admin.eventhandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
import com.ctrip.fun.admin.vo.callcenter.RsmwCdrEvent;
//import cc.rssoft.framework.springutil.ApplicationHelper;
//import cc.rssoft.qqd.mod_callcenter.service.GroupCallTaskService;
//import cc.rssoft.qqd.mod_callcenter.service.OutboundtaskItemService;
//import cc.rssoft.qqd.mod_customer.service.CustomerContactHistoryCategoryService;
//import cc.rssoft.qqd.rsmwapi.internal.AbstractEventHandler;
//import cc.rssoft.qqd.rsmwapi.internal.RsmwCdrEvent;
/**
*
* CDR
*
* @author jyf
*
*/
public class CdrEventHandler extends AbstractEventHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public String handle(JSONObject jsonObject) {
// 先从json对象转成java对象,方便get
RsmwCdrEvent event = JSON.toJavaObject(jsonObject, RsmwCdrEvent.class);
// System.out.println("AAA cdrhandler:" + event.getCallUuid());
logger.debug("receive CDR from RSMW:" + jsonObject.toJSONString());
// 这里处理【业务逻辑1:更新outboundtaskItem】
/*
OutboundtaskItemService outboundtaskItemService = ApplicationHelper.getApplicationContext()
.getBean("outboundtaskItemService", OutboundtaskItemService.class);
if (outboundtaskItemService != null) {
outboundtaskItemService.updateOutboundtaskItemAfterCall(event);
}
//......
// 这里处理【业务逻辑2:更新客户更进记录】
// 找出src,dst中的外部号码(非exten),作为customerPhoneNumber处理,处理过程如下:
// 先获取:customerService.getCustomerByPhonenNumber(phoneNumber);
// 如果没有customer就新增一条customer记录(类席newtateevent里的逻辑)
// 拿到customerid后,去insert CustomerContactHistory,setcontent=calluuid
CustomerContactHistoryCategoryService customerContactHistoryCategoryService = ApplicationHelper
.getApplicationContext()
.getBean("customerContactHistoryCategoryService", CustomerContactHistoryCategoryService.class);
if (customerContactHistoryCategoryService != null) {
customerContactHistoryCategoryService.saveCustomerContactHistory(event, 1L);
}
// 这里处理【业务逻辑3:更新群呼任务item】
// 群呼模块.
String userfield = event.getUserfield();
JSONObject userData = JSONObject.parseObject(userfield);
if (userData != null) {
logger.debug(userData.toJSONString());
Long gcTaskId = userData.getLong("gcTaskId");
Long gcTaskItemId = userData.getLong("gcTaskItemId");
Long questionnaireId = userData.getLong("questionnaireId");
Long customerId = userData.getLong("customerId");
if (gcTaskItemId != null) {
// 更新群呼item的记录
GroupCallTaskService groupCallTaskService = ApplicationHelper.getApplicationContext()
.getBean("groupCallTaskService", GroupCallTaskService.class);
if (groupCallTaskService != null) {
groupCallTaskService.updateGcTaskItemAfterCall(event, gcTaskId, gcTaskItemId, questionnaireId, customerId);
}
}else{
logger.debug("没有清理callUuid: gcTaskId == null");
}
}else{
logger.debug("没有清理callUuid: userData == null");
}*/
return "";
}
}
package com.ctrip.fun.admin.eventhandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
import com.ctrip.fun.admin.vo.callcenter.RsmwChannelRouteEvent;
/**
*
*
* @author jyf
*
*/
public class ChannelRouteEventHandler extends AbstractEventHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public String handle(JSONObject jsonObject) {
logger.debug(jsonObject.toJSONString());
RsmwChannelRouteEvent event = JSON.toJavaObject(jsonObject, RsmwChannelRouteEvent.class);
logger.debug(event.getUserData());
return"";
}
}
package com.ctrip.fun.admin.eventhandler;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
/**
*
*
* @author jyf
*
*/
public class QueueMemberPauseEventHandler extends AbstractEventHandler {
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public String handle(JSONObject jsonObject) {
return"";
}
}
package com.ctrip.fun.admin.eventhandler;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
/**
*
*
* @author jyf
*
*/
public class SqeEventHandler extends AbstractEventHandler {
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public String handle(JSONObject jsonObject) {
return"";
}
}
package com.ctrip.fun.admin.vo.callcenter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
/**
* @author Jiangyifen
*
*/
public abstract class AbstractEventHandler {
protected Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 处理具体的event
*
* @return
*/
public abstract String handle(JSONObject t);
private Long timestamp = 0L;
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
}
package com.ctrip.fun.admin.vo.callcenter;
public class BridgeEvent{
private String event = "";
private Boolean bridge = null;
private String channel1 = "";
private String uniqueId1 = "";
private String callerInNumber1 = "";
private String channel2 = "";
private String uniqueId2 = "";
private String callerInNumber2 = "";
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public Boolean getBridge() {
return bridge;
}
public void setBridge(Boolean bridge) {
this.bridge = bridge;
}
public String getChannel1() {
return channel1;
}
public void setChannel1(String channel1) {
this.channel1 = channel1;
}
public String getUniqueId1() {
return uniqueId1;
}
public void setUniqueId1(String uniqueId1) {
this.uniqueId1 = uniqueId1;
}
public String getCallerInNumber1() {
return callerInNumber1;
}
public void setCallerInNumber1(String callerInNumber1) {
this.callerInNumber1 = callerInNumber1;
}
public String getChannel2() {
return channel2;
}
public void setChannel2(String channel2) {
this.channel2 = channel2;
}
public String getUniqueId2() {
return uniqueId2;
}
public void setUniqueId2(String uniqueId2) {
this.uniqueId2 = uniqueId2;
}
public String getCallerInNumber2() {
return callerInNumber2;
}
public void setCallerInNumber2(String callerInNumber2) {
this.callerInNumber2 = callerInNumber2;
}
}
package com.ctrip.fun.admin.vo.callcenter;
/**
*
* @author root
*
*/
public class RsmwCdrEvent {
private Long timestamp = null;
private String event = "";
private String serverId = "";
private String callUuid = "";
private String uniqueId = "";
private String callerId = "";
private String src = "";
private String dstContext = "";
private String dst = "";
private String srcChannel = "";
private String dstChannel = "";
private String startTime = "";
private String answerTime = "";
private String endTime = "";
private Long duration = 0L;
private Long billSeconds = 0L;
private String disposition = "";
private String srcAgentAid = "";
private String srcAgentName = "";
private String dstAgentAid = "";
private String dstAgentName = "";
private String srcAccessNumber = "";
private String srcGateway = "";
private String dstAccessNumber = "";
private String dstGateway = "";
private String callDirection = "";
private Boolean answered = null;
private Boolean bridged = null;
private String recordUrl = "";
private String ivrKeyPressed = "";
private String userfield = "";
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getServerId() {
return serverId;
}
public void setServerId(String serverId) {
this.serverId = serverId;
}
public String getUniqueId() {
return uniqueId;
}
public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId;
}
public String getCallerId() {
return callerId;
}
public void setCallerId(String callerId) {
this.callerId = callerId;
}
public String getSrc() {
return src;
}
public void setSrc(String src) {
this.src = src;
}
public String getDstContext() {
return dstContext;
}
public void setDstContext(String dstContext) {
this.dstContext = dstContext;
}
public String getDst() {
return dst;
}
public void setDst(String dst) {
this.dst = dst;
}
public String getSrcChannel() {
return srcChannel;
}
public void setSrcChannel(String srcChannel) {
this.srcChannel = srcChannel;
}
public String getDstChannel() {
return dstChannel;
}
public void setDstChannel(String dstChannel) {
this.dstChannel = dstChannel;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getAnswerTime() {
return answerTime;
}
public void setAnswerTime(String answerTime) {
this.answerTime = answerTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public Long getDuration() {
return duration;
}
public void setDuration(Long duration) {
this.duration = duration;
}
public Long getBillSeconds() {
return billSeconds;
}
public void setBillSeconds(Long billSeconds) {
this.billSeconds = billSeconds;
}
public String getSrcAgentAid() {
return srcAgentAid;
}
public void setSrcAgentAid(String srcAgentAid) {
this.srcAgentAid = srcAgentAid;
}
public String getSrcAgentName() {
return srcAgentName;
}
public void setSrcAgentName(String srcAgentName) {
this.srcAgentName = srcAgentName;
}
public String getDstAgentAid() {
return dstAgentAid;
}
public void setDstAgentAid(String dstAgentAid) {
this.dstAgentAid = dstAgentAid;
}
public String getDstAgentName() {
return dstAgentName;
}
public void setDstAgentName(String dstAgentName) {
this.dstAgentName = dstAgentName;
}
public String getSrcAccessNumber() {
return srcAccessNumber;
}
public void setSrcAccessNumber(String srcAccessNumber) {
this.srcAccessNumber = srcAccessNumber;
}
public String getSrcGateway() {
return srcGateway;
}
public void setSrcGateway(String srcGateway) {
this.srcGateway = srcGateway;
}
public String getDstAccessNumber() {
return dstAccessNumber;
}
public void setDstAccessNumber(String dstAccessNumber) {
this.dstAccessNumber = dstAccessNumber;
}
public String getDstGateway() {
return dstGateway;
}
public void setDstGateway(String dstGateway) {
this.dstGateway = dstGateway;
}
public String getCallDirection() {
return callDirection;
}
public void setCallDirection(String callDirection) {
this.callDirection = callDirection;
}
public Boolean getAnswered() {
return answered;
}
public void setAnswered(Boolean answered) {
this.answered = answered;
}
public String getRecordUrl() {
return recordUrl;
}
public void setRecordUrl(String recordUrl) {
this.recordUrl = recordUrl;
}
public String getCallUuid() {
return callUuid;
}
public void setCallUuid(String callUuid) {
this.callUuid = callUuid;
}
public String getDisposition() {
return disposition;
}
public void setDisposition(String disposition) {
this.disposition = disposition;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getIvrKeyPressed() {
return ivrKeyPressed;
}
public void setIvrKeyPressed(String ivrKeyPressed) {
this.ivrKeyPressed = ivrKeyPressed;
}
public String getUserfield() {
return userfield;
}
public void setUserfield(String userfield) {
this.userfield = userfield;
}
public Boolean getBridged() {
return bridged;
}
public void setBridged(Boolean bridged) {
this.bridged = bridged;
}
}
package com.ctrip.fun.admin.vo.callcenter;
public class RsmwChannelRouteEvent{
private String event = "";
private String accessDate = "";
private String uniqueId = "";
private String channel = "";
private String callerIdNumber = "";
private String srcGateway = "";
private String srcAccessNumber = "";
private String dstGateway = "";
private String dstAccessNumber = "";
private String userData = "";
public String getSrcGateway() {
return srcGateway;
}
public void setSrcGateway(String srcGateway) {
this.srcGateway = srcGateway;
}
public String getSrcAccessNumber() {
return srcAccessNumber;
}
public void setSrcAccessNumber(String srcAccessNumber) {
this.srcAccessNumber = srcAccessNumber;
}
public String getDstGateway() {
return dstGateway;
}
public void setDstGateway(String dstGateway) {
this.dstGateway = dstGateway;
}
public String getDstAccessNumber() {
return dstAccessNumber;
}
public void setDstAccessNumber(String dstAccessNumber) {
this.dstAccessNumber = dstAccessNumber;
}
private String exten = "";
private String extenType = "";
private String extenDescription = "";
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getExten() {
return exten;
}
public void setExten(String exten) {
this.exten = exten;
}
public String getExtenType() {
return extenType;
}
public void setExtenType(String extenType) {
this.extenType = extenType;
}
public String getExtenDescription() {
return extenDescription;
}
public void setExtenDescription(String extenDescription) {
this.extenDescription = extenDescription;
}
public String getCallerIdNumber() {
return callerIdNumber;
}
public void setCallerIdNumber(String callerIdNumber) {
this.callerIdNumber = callerIdNumber;
}
public String getUniqueId() {
return uniqueId;
}
public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public String getAccessDate() {
return accessDate;
}
public void setAccessDate(String accessDate) {
this.accessDate = accessDate;
}
public String getUserData() {
return userData;
}
public void setUserData(String userData) {
this.userData = userData;
}
}
package com.ctrip.fun.admin.vo.callcenter;
public class RsmwNewStateEvent{
private String event = "";
private String uniqueId = "";
private String channel = "";
private String channelState = "";
private Integer cause = null;
private String causeDesc = "";
private String callerIdName = "";
private String callerIdNumber = "";
private String connectedLineName = "";
private String connectedLineNumber = "";
// private String callUuid = "";
public String getUniqueId() {
return uniqueId;
}
public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public String getChannelState() {
return channelState;
}
public void setChannelState(String channelState) {
this.channelState = channelState;
}
public Integer getCause() {
return cause;
}
public void setCause(Integer cause) {
this.cause = cause;
}
public String getCauseDesc() {
return causeDesc;
}
public void setCauseDesc(String causeDesc) {
this.causeDesc = causeDesc;
}
public String getCallerIdName() {
return callerIdName;
}
public void setCallerIdName(String callerIdName) {
this.callerIdName = callerIdName;
}
public String getCallerIdNumber() {
return callerIdNumber;
}
public void setCallerIdNumber(String callerIdNumber) {
this.callerIdNumber = callerIdNumber;
}
public String getConnectedLineName() {
return connectedLineName;
}
public void setConnectedLineName(String connectedLineName) {
this.connectedLineName = connectedLineName;
}
public String getConnectedLineNumber() {
return connectedLineNumber;
}
public void setConnectedLineNumber(String connectedLineNumber) {
this.connectedLineNumber = connectedLineNumber;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
// public String getCallUuid() {
// return callUuid;
// }
// public void setCallUuid(String callUuid) {
// this.callUuid = callUuid;
// }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment