Commit d5b50661 by Java - 段鹏举

席位登录时增加判断,如果当前账号已经登录了关联的其他席位,则不允许登录当前席位

parent 915797f7
package com.ejweb.modules.user.api; package com.ejweb.modules.user.api;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ejweb.core.api.RequestBean; import com.ejweb.core.api.RequestBean;
...@@ -36,26 +17,27 @@ import com.ejweb.modules.role.bean.UserRolesBean; ...@@ -36,26 +17,27 @@ import com.ejweb.modules.role.bean.UserRolesBean;
import com.ejweb.modules.role.entity.InformationEntity; import com.ejweb.modules.role.entity.InformationEntity;
import com.ejweb.modules.role.entity.UserRolesEntity; import com.ejweb.modules.role.entity.UserRolesEntity;
import com.ejweb.modules.role.service.UserRolesService; import com.ejweb.modules.role.service.UserRolesService;
import com.ejweb.modules.user.bean.CompanyListBean; import com.ejweb.modules.user.bean.*;
import com.ejweb.modules.user.bean.LoginBean;
import com.ejweb.modules.user.bean.OuterUserAddBean;
import com.ejweb.modules.user.bean.OuterUserBean;
import com.ejweb.modules.user.bean.SeatLoginBean;
import com.ejweb.modules.user.bean.UserBean;
import com.ejweb.modules.user.bean.UserFindByCodeBean;
import com.ejweb.modules.user.bean.UserLogoutBean;
import com.ejweb.modules.user.bean.UserPhotoBean;
import com.ejweb.modules.user.bean.UserRefreshBean;
import com.ejweb.modules.user.bean.UserSeatMobileBean;
import com.ejweb.modules.user.entity.LoginUserEntity; import com.ejweb.modules.user.entity.LoginUserEntity;
import com.ejweb.modules.user.entity.UserDeviceInfoEntity;
import com.ejweb.modules.user.entity.UserEntity; import com.ejweb.modules.user.entity.UserEntity;
import com.ejweb.modules.user.entity.UserLoginInfoEntity;
import com.ejweb.modules.user.entity.UserLoginLogEntity; import com.ejweb.modules.user.entity.UserLoginLogEntity;
import com.ejweb.modules.user.entity.UserSeatEntity; import com.ejweb.modules.user.entity.UserSeatEntity;
import com.ejweb.modules.user.service.UserService; import com.ejweb.modules.user.service.UserService;
import com.huawei.esdk.uc.professional.local.bean.south.UserState; import com.huawei.esdk.uc.professional.local.bean.south.UserState;
import com.jdair.util.http.client.HTTPClientUtil; import com.jdair.util.http.client.HTTPClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.net.URLDecoder;
import java.util.*;
@Controller @Controller
@RequestMapping("/api/user") @RequestMapping("/api/user")
...@@ -80,7 +62,7 @@ public class UserController { ...@@ -80,7 +62,7 @@ public class UserController {
/** /**
* 根据用户CODE查询用户信息 * 根据用户CODE查询用户信息
* *
* @param req * @param requestBean
* @param errors * @param errors
* @return * @return
*/ */
...@@ -111,7 +93,7 @@ public class UserController { ...@@ -111,7 +93,7 @@ public class UserController {
/** /**
* 注册用户信息 * 注册用户信息
* *
* @param req * @param requestBean
* @param errors * @param errors
* @return * @return
*/ */
...@@ -142,8 +124,8 @@ public class UserController { ...@@ -142,8 +124,8 @@ public class UserController {
/** /**
* 用户登录 * 用户登录
* *
* @param req * @param request
* @param errors * @param requestBean
* @return * @return
*/ */
@ResponseBody @ResponseBody
...@@ -272,7 +254,7 @@ public class UserController { ...@@ -272,7 +254,7 @@ public class UserController {
// } // }
// } // }
// if(Util.isInValue(entityTmp.getCurState(), "1", "3", "4") == false){// 用户不在线 // if(Util.isInValue(entityTmp.getCurState(), "1", "3", "4") == false){// 用户不在线
// //
// entityTmp.setPhoto(Util.getAbsoluteUrl(GConstants.DEFAULT_SEAT_PHOTO)); // entityTmp.setPhoto(Util.getAbsoluteUrl(GConstants.DEFAULT_SEAT_PHOTO));
// } // }
// } // }
...@@ -364,8 +346,8 @@ public class UserController { ...@@ -364,8 +346,8 @@ public class UserController {
/** /**
* 获取验证码 * 获取验证码
* *
* @param req * @param request
* @param errors * @param requestBean
* @return * @return
*/ */
@ResponseBody @ResponseBody
...@@ -418,8 +400,8 @@ public class UserController { ...@@ -418,8 +400,8 @@ public class UserController {
/** /**
* 席位登录 更新 * 席位登录 更新
* *
* @param request
* @param requestBean * @param requestBean
* @param errors
* @return * @return
*/ */
@ResponseBody @ResponseBody
...@@ -447,6 +429,38 @@ public class UserController { ...@@ -447,6 +429,38 @@ public class UserController {
} }
} }
*/ */
// 同一个账户只能登录一个身份
// 查询用户的所有身份
LoginUserEntity userEntity = new LoginUserEntity();
userEntity.setId(seatloginBean.getUserId());
List<UserSeatEntity> userSeatList = userService.getUserSeatByUserCode(userEntity);
if (userSeatList != null && userSeatList.size() > 0) {
// 查询所有身份的状态
List<String> seatIds = new ArrayList<>();
Map<String, UserSeatEntity> userSeatEntityMap = new HashMap<>();
for (UserSeatEntity userSeatEntity : userSeatList) {
seatIds.add(userSeatEntity.getSeatId());
userSeatEntityMap.put(userSeatEntity.getSeatId(), userSeatEntity);
}
if (seatIds.size() > 0) {
// 调用华为接口查询席位状态列表
List<UserState> seatStates = huaweiInterfaseService.queryUserStateList(seatIds);
if (seatStates != null && seatStates.size() > 0) {
for (UserState userState : seatStates) {
// 如果有身份处于在线状态,且不是当前正在登录的,则返回在线席位的信息
if (Util.isInValue(String.valueOf(userState.getNewState()), "1", "3", "4")
&& !seatloginBean.getSeatId().equals(userState.getOrigin())) {
responseBean.setData(userSeatEntityMap.get(userState.getOrigin()));
responseBean.setMessage("用户已在其他席位登录");
responseBean.setStatus(ErrorCode.STATUS_CODE_4301);
return responseBean;
}
}
}
}
}
String clientip = StringUtils.isEmpty(seatloginBean.getClientip()) ? Util.getOnlineIP(request) : seatloginBean.getClientip(); String clientip = StringUtils.isEmpty(seatloginBean.getClientip()) ? Util.getOnlineIP(request) : seatloginBean.getClientip();
UserLoginLogEntity deviceInfoEntity = new UserLoginLogEntity(); UserLoginLogEntity deviceInfoEntity = new UserLoginLogEntity();
deviceInfoEntity.setUserId(seatloginBean.getUserId()); deviceInfoEntity.setUserId(seatloginBean.getUserId());
......
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 to comment