Commit 00ed6086 by unknown

Merge branch 'release' of 192.168.10.6:caosy/fun-admin into release

parents ea868d5f 95cd57e3
...@@ -115,7 +115,7 @@ public class SipPhoneControl { ...@@ -115,7 +115,7 @@ public class SipPhoneControl {
// String agentAid = request.getAttribute("userName").toString(); // String agentAid = request.getAttribute("userName").toString();
String agentAid = SpringSecurityUtil.getCurrentUserName(); String agentAid = SpringSecurityUtil.getCurrentUserName();
String sipPhoneName = request.getParameter("sipPhoneName"); String sipPhoneName = request.getParameter("sipPhoneName");
System.out.println("bbbbbbbbbbbbbbbbbbbbb:"+agentAid+" "+ sipPhoneName+" "); // System.out.println("bbbbbbbbbbbbbbbbbbbbb:"+agentAid+" "+ sipPhoneName+" ");
return sipPhoneService.bind(agentAid, sipPhoneName); return sipPhoneService.bind(agentAid, sipPhoneName);
} }
......
...@@ -20,6 +20,7 @@ import org.springframework.ui.ModelMap; ...@@ -20,6 +20,7 @@ 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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; 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;
...@@ -42,6 +43,7 @@ import com.ctrip.fun.admin.service.system.UserService; ...@@ -42,6 +43,7 @@ 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.admin.vo.callcenter.AbstractEventHandler;
import com.ctrip.fun.admin.vo.callcenter.RsmwNewStateEvent;
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;
...@@ -104,6 +106,12 @@ public class CallCenterController { ...@@ -104,6 +106,12 @@ public class CallCenterController {
} }
} }
@RequestMapping(value = "/tools/validCode/{mobileNo}", method = RequestMethod.GET)
public String validFail(HttpServletRequest request, @PathVariable String mobileNo, ModelMap model) {
model.put("mobileNo", mobileNo);
return "/tools/validCode";
}
/** /**
* *
* @return * @return
...@@ -119,7 +127,7 @@ public class CallCenterController { ...@@ -119,7 +127,7 @@ public class CallCenterController {
JSONObject commandJSONObject = null; JSONObject commandJSONObject = null;
commandJSONObject = JSON.parseObject(eventJsonString); commandJSONObject = JSON.parseObject(eventJsonString);
String event = commandJSONObject.getString("event"); String event = commandJSONObject.getString("event");
// System.out.println("bbbbbbbbbbb: "+event);
if(StringUtils.isBlank(event)){ if(StringUtils.isBlank(event)){
result = "收到的消息缺少event字段: "+ eventJsonString; result = "收到的消息缺少event字段: "+ eventJsonString;
logger.warn(result); logger.warn(result);
...@@ -128,12 +136,28 @@ public class CallCenterController { ...@@ -128,12 +136,28 @@ public class CallCenterController {
// 1)找出具体的命令实例。 // 1)找出具体的命令实例。
logger.debug("event [" + event + "] is ready to execute..."); logger.debug("event [" + event + "] is ready to execute...");
logger.debug(eventJsonString); logger.debug(eventJsonString);
System.out.println("EEEEEEEEEEEEEEEEEEEEEEEEEEEEE: "+eventJsonString);
AbstractEventHandler eventHandler = eventHandlerMap.get(event); AbstractEventHandler eventHandler = eventHandlerMap.get(event);
// 2)执行命令并返回结果 // 2)执行命令并返回结果
if(eventHandler!=null){ if(eventHandler!=null){
eventHandler.handle(commandJSONObject); if("newStateEvent".equals(event)){
RsmwNewStateEvent event111 = JSON.toJavaObject(commandJSONObject, RsmwNewStateEvent.class);
// String sipPeerName = event111.getChannel().replace("SIP/", "");
if ("RINGING".equals(event111.getChannelState())) {
String mobileNo = event111.getConnectedLineNumber().replaceFirst("^0*", "");
String callerIdNumber = event111.getChannel().substring(4, 8);
UserExtBean user = userService.getUserByMobile(mobileNo);
String uid = "";
if(user != null){
uid = user.getUid();
}
NewStateEventHandler newStatehandler = new NewStateEventHandler();
newStatehandler.handle(callerIdNumber,uid, mobileNo);
}
}else{
eventHandler.handle(commandJSONObject);
}
return "Success"; return "Success";
}else{ }else{
result = "event=" + event + ", event字段有误,没有找到对应的eventHandler"; result = "event=" + event + ", event字段有误,没有找到对应的eventHandler";
......
...@@ -2,12 +2,15 @@ package com.ctrip.fun.admin.eventhandler; ...@@ -2,12 +2,15 @@ package com.ctrip.fun.admin.eventhandler;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.service.system.UserService;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler; import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
import com.ctrip.fun.admin.vo.callcenter.RsmwNewStateEvent; import com.ctrip.fun.admin.vo.callcenter.RsmwNewStateEvent;
import com.ctrip.fun.common.vo.user.UserExtBean;
...@@ -18,11 +21,19 @@ import com.ctrip.fun.admin.vo.callcenter.RsmwNewStateEvent; ...@@ -18,11 +21,19 @@ import com.ctrip.fun.admin.vo.callcenter.RsmwNewStateEvent;
* *
* @author jyf * @author jyf
*/ */
@Controller
public class NewStateEventHandler extends AbstractEventHandler { public class NewStateEventHandler extends AbstractEventHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
// private String uid;
public void handle(String callerIdNumber,String uid,String mobileNo) {
// this.uid = uid;
// this.handle(jsonObject);
NewStateWebSocket.unicast(callerIdNumber,uid,mobileNo);
}
@Override @Override
public String handle(JSONObject jsonObject) { public String handle(JSONObject jsonObject) {
// 先从json对象转成java对象,方便get // 先从json对象转成java对象,方便get
...@@ -37,13 +48,20 @@ public class NewStateEventHandler extends AbstractEventHandler { ...@@ -37,13 +48,20 @@ public class NewStateEventHandler extends AbstractEventHandler {
sipPeerName = sipPeerName.split("/")[0]; sipPeerName = sipPeerName.split("/")[0];
if ("RINGING".equals(event.getChannelState())) { if ("RINGING".equals(event.getChannelState())) {
logger.debug("收到了ringing消息: " + event.getChannel() + event.getConnectedLineNumber()); /* logger.debug("收到了ringing消息: " + event.getChannel() + event.getConnectedLineNumber());
//来电手机号码 //来电手机号码
String mobileNo = event.getConnectedLineNumber().replaceFirst("^0*", ""); String mobileNo = event.getConnectedLineNumber().replaceFirst("^0*", "");
// String callerIdNumber = event.getCallerIdNumber();
String callerIdNumber = event.getChannel().substring(4, 8); String callerIdNumber = event.getChannel().substring(4, 8);
NewStateWebSocket.unicast(callerIdNumber,mobileNo); UserExtBean user = userService.getUserByMobile(mobileNo);
String uid = "";
if(user != null){
uid = user.getUid();
}
NewStateWebSocket.unicast(callerIdNumber,uid,mobileNo);*/
} }
return ""; return "";
} }
......
...@@ -14,14 +14,11 @@ import javax.websocket.server.ServerEndpoint; ...@@ -14,14 +14,11 @@ import javax.websocket.server.ServerEndpoint;
/** /**
* userName : 代表分机号 * userName : 代表分机号
* @author lyhuang * @author lyhuang
*
*/ */
@ServerEndpoint("/websocket/{userName}") @ServerEndpoint("/websocket/{userName}")
public class NewStateWebSocket { public class NewStateWebSocket {
public NewStateWebSocket(){} public NewStateWebSocket(){}
private static Map<String, Session> sessionMap=new HashMap<String, Session>();//在线的客户端session集合,只在第一次new的时候初始化。 private static Map<String, Session> sessionMap=new HashMap<String, Session>();//在线的客户端session集合,只在第一次new的时候初始化。
/** /**
* 接收信息事件 * 接收信息事件
...@@ -50,10 +47,8 @@ public class NewStateWebSocket { ...@@ -50,10 +47,8 @@ public class NewStateWebSocket {
*/ */
@OnOpen @OnOpen
public void onOpen(Session session,@PathParam(value="userName")String userName) throws Exception { public void onOpen(Session session,@PathParam(value="userName")String userName) throws Exception {
System.out.println("打开连接成功!");
sessionMap.put(userName, session); sessionMap.put(userName, session);
System.out.println("用户"+userName+"进来了。。。"); // System.out.println("用户"+userName+"进来了。。。"+"当前在线人数:"+sessionMap.size());
System.out.println("当前在线人数:"+sessionMap.size());
} }
/** /**
...@@ -61,10 +56,8 @@ public class NewStateWebSocket { ...@@ -61,10 +56,8 @@ public class NewStateWebSocket {
*/ */
@OnClose @OnClose
public void onClose(Session session,@PathParam(value="userName")String userName) { public void onClose(Session session,@PathParam(value="userName")String userName) {
System.out.println("关闭连接成功!"); // System.out.println("用户"+userName+"离开了。。。"+"当前在线人数:"+sessionMap.size());
System.out.println("用户"+userName+"离开了。。。");
sessionMap.remove(userName); sessionMap.remove(userName);
System.out.println("当前在线人数:"+sessionMap.size());
} }
/** /**
...@@ -80,14 +73,19 @@ public class NewStateWebSocket { ...@@ -80,14 +73,19 @@ public class NewStateWebSocket {
} }
public static void unicast(String username, String mobileNo) { public static void unicast(String username, String uid, String mobileNo) {
String message = "/system/user/"+mobileNo+"/detailByUid"; String message = "/system/user/"+uid+"/detailByUid";
Session session = sessionMap.get(username); Session session = sessionMap.get(username);
System.out.println("unicast--------------------------------------------------"+message); if(session == null){
// NewStateWebSocket socket = NewStateWebSocket.getInstance(); System.out.println("Callcenter pop window:分机号"+username+"没有绑定任何账户或者绑定的账户没有登录。无法为其弹窗");
return ;
}
if("".equals(uid)){
System.out.println("Callcenter pop window:手机号码"+mobileNo+"没有注册!");
message = "/cc/tools/validCode/"+mobileNo;
}
try { try {
session.getBasicRemote().sendText(message); session.getBasicRemote().sendText(message);
// socket.onMessage(message, session, username);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -8,6 +8,7 @@ import org.springframework.http.HttpMethod; ...@@ -8,6 +8,7 @@ import org.springframework.http.HttpMethod;
import com.ctrip.fun.admin.exception.CommonException; import com.ctrip.fun.admin.exception.CommonException;
import com.ctrip.fun.admin.service.BaseService; import com.ctrip.fun.admin.service.BaseService;
import com.ctrip.fun.common.vo.Request;
import com.ctrip.fun.common.vo.Response; import com.ctrip.fun.common.vo.Response;
import com.ctrip.fun.common.vo.user.RegisterBean; import com.ctrip.fun.common.vo.user.RegisterBean;
import com.ctrip.fun.common.vo.user.RegisterResultBean; import com.ctrip.fun.common.vo.user.RegisterResultBean;
...@@ -35,7 +36,8 @@ public class CallCenterService extends BaseService { ...@@ -35,7 +36,8 @@ public class CallCenterService extends BaseService {
*/ */
public UserBean getMemberInfo(String userId, UserQuery requestDto) throws CommonException { public UserBean getMemberInfo(String userId, UserQuery requestDto) throws CommonException {
String uri = super.getServiceUri("uri.cc.MemberInfo"); String uri = super.getServiceUri("uri.cc.MemberInfo");
HttpEntity<UserQuery> entity = new HttpEntity<UserQuery>(requestDto); Request<UserQuery> request = new Request<UserQuery>("", requestDto);
HttpEntity<Request<UserQuery>> entity = new HttpEntity<Request<UserQuery>>(request);
Response<UserBean> response = super.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<Response<UserBean>>() { Response<UserBean> response = super.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<Response<UserBean>>() {
}).getBody(); }).getBody();
if (response == null) { if (response == null) {
...@@ -59,14 +61,18 @@ public class CallCenterService extends BaseService { ...@@ -59,14 +61,18 @@ public class CallCenterService extends BaseService {
*/ */
public VerifyResultBean sendVerifyCode(String userId, VerifyCodeBean requestDto) throws CommonException { public VerifyResultBean sendVerifyCode(String userId, VerifyCodeBean requestDto) throws CommonException {
String uri = super.getServiceUri("uri.cc.sendVerifyCode"); String uri = super.getServiceUri("uri.cc.sendVerifyCode");
HttpEntity<VerifyCodeBean> entity = new HttpEntity<VerifyCodeBean>(requestDto); // HttpEntity<VerifyCodeBean> entity = new HttpEntity<VerifyCodeBean>(requestDto);
VerifyResultBean response = super.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<VerifyResultBean>() { Request<VerifyCodeBean> request = new Request<VerifyCodeBean>("", requestDto);
}).getBody(); HttpEntity<Request<VerifyCodeBean>> entity = new HttpEntity<Request<VerifyCodeBean>>(request);
if (response == null) {
Response<VerifyResultBean> response = super.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<Response<VerifyResultBean>>() {}).getBody();
VerifyResultBean bean = response.getBody();
if (bean == null) {
logger.error(String.format("[sendVerifyCode response is null!]")); logger.error(String.format("[sendVerifyCode response is null!]"));
throw new CommonException(-01, "sendVerifyCode response is null"); throw new CommonException(-01, "sendVerifyCode response is null");
} }
return response; return bean;
} }
/** /**
...@@ -79,17 +85,20 @@ public class CallCenterService extends BaseService { ...@@ -79,17 +85,20 @@ public class CallCenterService extends BaseService {
*/ */
public VerifyResultBean validateMobilePhone(String userId, VerifyCodeBean requestDto) throws CommonException { public VerifyResultBean validateMobilePhone(String userId, VerifyCodeBean requestDto) throws CommonException {
String uri = super.getServiceUri("uri.cc.validateMobilePhone"); String uri = super.getServiceUri("uri.cc.validateMobilePhone");
HttpEntity<VerifyCodeBean> entity = new HttpEntity<VerifyCodeBean>(requestDto);
VerifyResultBean response = super.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<VerifyResultBean>() { Request<VerifyCodeBean> request = new Request<VerifyCodeBean>("", requestDto);
HttpEntity<Request<VerifyCodeBean>> entity = new HttpEntity<Request<VerifyCodeBean>>(request);
Response<VerifyResultBean> response = super.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<Response<VerifyResultBean>>() {
}).getBody(); }).getBody();
if (response == null) { VerifyResultBean bean = response.getBody();
if (bean == null) {
logger.error(String.format("validateMobilePhone response is null")); logger.error(String.format("validateMobilePhone response is null"));
throw new CommonException(-01, "validateMobilePhone response is null"); throw new CommonException(-01, "validateMobilePhone response is null");
} else if (response.getReturnCode() != 0) { } else if (bean.getReturnCode() != 0) {
logger.error(String.format("[validateMobilePhone response code is %s, message is %s!]", response.getReturnCode(), response.getMessage())); logger.error(String.format("[validateMobilePhone response code is %s, message is %s!]", bean.getReturnCode(), response.getMessage()));
throw new CommonException(response.getReturnCode(), response.getMessage()); throw new CommonException(bean.getReturnCode(), response.getMessage());
} }
return response; return bean;
} }
/** /**
...@@ -102,16 +111,18 @@ public class CallCenterService extends BaseService { ...@@ -102,16 +111,18 @@ public class CallCenterService extends BaseService {
*/ */
public RegisterResultBean mobileClientRegister(String userId, RegisterBean requestDto) throws CommonException { public RegisterResultBean mobileClientRegister(String userId, RegisterBean requestDto) throws CommonException {
String uri = super.getServiceUri("uri.cc.mobileClientRegister"); String uri = super.getServiceUri("uri.cc.mobileClientRegister");
HttpEntity<RegisterBean> entity = new HttpEntity<RegisterBean>(requestDto); Request<RegisterBean> request = new Request<RegisterBean>("", requestDto);
RegisterResultBean response = super.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<RegisterResultBean>() { HttpEntity<Request<RegisterBean>> entity = new HttpEntity<Request<RegisterBean>>(request);
Response<RegisterResultBean> response = super.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<Response<RegisterResultBean>>() {
}).getBody(); }).getBody();
if (response == null) { RegisterResultBean bean = response.getBody();
if (bean == null) {
logger.error(String.format("mobileClientRegister response is null")); logger.error(String.format("mobileClientRegister response is null"));
throw new CommonException(-01, "mobileClientRegister response is null"); throw new CommonException(-01, "mobileClientRegister response is null");
} else if (response.getReturnCode() != 0) { } else if (bean.getReturnCode() != 0) {
logger.error(String.format("[mobileClientRegister response code is %s, message is %s!]", response.getReturnCode(), response.getMessage())); logger.error(String.format("[mobileClientRegister response code is %s, message is %s!]", bean.getReturnCode(), bean.getMessage()));
throw new CommonException(response.getReturnCode(), response.getMessage()); throw new CommonException(bean.getReturnCode(), response.getMessage());
} }
return response; return bean;
} }
} }
...@@ -94,6 +94,8 @@ ...@@ -94,6 +94,8 @@
$("#btnSendCode").val("请在" + curCount + "秒后再获取验证码"); $("#btnSendCode").val("请在" + curCount + "秒后再获取验证码");
} }
} }
</script> </script>
</#assign> </#assign>
<@com.layout title="电话注册 " module="system" pageJs=pageJsContent> <@com.layout title="电话注册 " module="system" pageJs=pageJsContent>
...@@ -102,8 +104,7 @@ ...@@ -102,8 +104,7 @@
<input type="hidden" id="oriMobileNo" name="oriMobileNo" value="${mobileNo!}" /> <input type="hidden" id="oriMobileNo" name="oriMobileNo" value="${mobileNo!}" />
<div> <div>
手机号码: 手机号码:
<input type="text" name="mobileNo" id="mobileNo" title="请输入手机号" placeholder="请输入正确手机号" value="${mobileNo!}" <input type="text" name="mobileNo" id="mobileNo" title="请输入手机号" placeholder="请输入正确手机号" value="${mobileNo!}" />
/>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<input type="button" id="btnSendCode" class="btn btn-primary" value="获取验证码" <input type="button" id="btnSendCode" class="btn btn-primary" value="获取验证码"
onclick="sendValidCode()" /> onclick="sendValidCode()" />
......
...@@ -9,7 +9,19 @@ ...@@ -9,7 +9,19 @@
webSocket.onerror = function(event) {}; webSocket.onerror = function(event) {};
webSocket.onopen = function(event) {}; webSocket.onopen = function(event) {};
webSocket.onmessage = function(event) { webSocket.onmessage = function(event) {
window.open(event.data, "用户来电通知"); // if(event.data.startsWith("/cc/tools/validCode")){
/*var message = event.data;
var msgArr = message.split(" ");
var popupwin = window.open(msgArr[0], "用户来电通知");
var params = new Array();
params[0] = new Array("mobileNo",msgArr[1]);
popupwin.onload = function(e){
popupwin.postMessage(params,"http://"+window.location.host);
}*/
window.open(event.data);
// }
}; };
webSocket.onclose = function(event){}; webSocket.onclose = function(event){};
} }
......
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