|  | @@ -44,165 +44,77 @@ public class A00002Service extends A00002BaseModel implements ExecProcessFlow {
 | 
	
		
			
				|  |  |       * 基础系统,“登录”业务核心处理
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public void transExecute() throws Exception {
 | 
	
		
			
				|  |  | -        String loginMedia = UtilTools.isNullOrBlank(this.getA_a00002().getLoginMedia()) ? LoginMedia.APP.getIndex() : this.getA_a00002().getLoginMedia();
 | 
	
		
			
				|  |  | -        if (LoginMedia.getLoginMedia(loginMedia) == null) {
 | 
	
		
			
				|  |  | -            throw new BusinessException("EB8000015");
 | 
	
		
			
				|  |  | +        //本地是否存在
 | 
	
		
			
				|  |  | +        SysUserMapper dao = UtilTools.getBean(SysUserMapper.class);
 | 
	
		
			
				|  |  | +        SysUserSQLBuilder sb = new SysUserSQLBuilder();
 | 
	
		
			
				|  |  | +        if ("0".equals(this.getA_a00002().getType())) {
 | 
	
		
			
				|  |  | +            sb.createCriteria().andUsermobnubEqualTo(this.getA_a00002().getPhoneNo().trim());
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +            sb.createCriteria().andUsernameEqualTo(this.getA_a00002().getUserName().trim());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        String loginType = UtilTools.isNullOrBlank(this.getA_a00002().getType()) ? LoginType.PASSWD.getIndex() : this.getA_a00002().getType();
 | 
	
		
			
				|  |  | -        if (LoginType.getLoginType(loginType) == null) {
 | 
	
		
			
				|  |  | -            throw new BusinessException("EB8000015");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //0手动登录 1-自动登录
 | 
	
		
			
				|  |  | -        String loginWay = UtilTools.isNullOrBlank(this.getA_a00002().getLoginWay()) ? LoginWay.MANUAL.getIndex() : this.getA_a00002().getLoginWay();
 | 
	
		
			
				|  |  | -        if (LoginWay.getLoginWay(loginWay) == null) {
 | 
	
		
			
				|  |  | -            throw new BusinessException("EB8000015");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        SysUser sysUser;
 | 
	
		
			
				|  |  | -        SysUserMapper sysUserDAO = UtilTools.getBean(SysUserMapper.class);
 | 
	
		
			
				|  |  | -        if (loginWay.equals(LoginWay.MANUAL.getIndex())) { //手动登录
 | 
	
		
			
				|  |  | -            if (UtilTools.isNotNullAndBlank(this.getA_a00002().getAuthCode())) {
 | 
	
		
			
				|  |  | -                //验证图片
 | 
	
		
			
				|  |  | -                LoginService.validateGraph(this.getA_a00002().getAuthCode(), this.getA_systemhead().getClientToken());
 | 
	
		
			
				|  |  | +//		sb.createCriteria().andUsernameEqualTo(this.getA_a00002().getUserName().trim());
 | 
	
		
			
				|  |  | +        List<SysUser> userInfoList = dao.selectByExample(sb);
 | 
	
		
			
				|  |  | +        if(CollectionUtils.isEmpty(userInfoList)){
 | 
	
		
			
				|  |  | +            sb = new SysUserSQLBuilder();
 | 
	
		
			
				|  |  | +            if ("0".equals(this.getA_a00002().getType())) {
 | 
	
		
			
				|  |  | +                sb.createCriteria().andUsermobnubEqualTo(this.getA_a00002().getPhoneNo().trim());
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                sb.createCriteria().andUseremailEqualTo(this.getA_a00002().getUserName().trim());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            //本地是否存在
 | 
	
		
			
				|  |  | -            SysUserSQLBuilder sysUserSQLBuilder = new SysUserSQLBuilder();
 | 
	
		
			
				|  |  | -            String loginName = this.getA_a00002().getLoginName().trim();
 | 
	
		
			
				|  |  | -            //先使用loginName查询用户,再用手机号查询
 | 
	
		
			
				|  |  | -            sysUserSQLBuilder.createCriteria().andUserstateNotEqualTo(UserState.delete.getIndex()).andUsernameEqualTo(loginName);
 | 
	
		
			
				|  |  | -            List<SysUser> userInfoList = sysUserDAO.selectByExample(sysUserSQLBuilder);
 | 
	
		
			
				|  |  | -            if (CollectionUtils.isEmpty(userInfoList)) {
 | 
	
		
			
				|  |  | -                //再用手机号查询
 | 
	
		
			
				|  |  | -                sysUserSQLBuilder = new SysUserSQLBuilder();
 | 
	
		
			
				|  |  | -                sysUserSQLBuilder.createCriteria().andUsermobnubEqualTo(loginName);
 | 
	
		
			
				|  |  | -                userInfoList = sysUserDAO.selectByExample(sysUserSQLBuilder);
 | 
	
		
			
				|  |  | -                if (CollectionUtils.isEmpty(userInfoList)) {
 | 
	
		
			
				|  |  | -                    // 不存在就报错
 | 
	
		
			
				|  |  | -                    throw new BusinessException("EB8000015");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            sysUser = userInfoList.get(0);
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            sysUser = sysUserDAO.selectByPrimaryKey(this.getA_systemhead().getUserId());
 | 
	
		
			
				|  |  | -            if (sysUser == null) {
 | 
	
		
			
				|  |  | +            userInfoList = dao.selectByExample(sb);
 | 
	
		
			
				|  |  | +            if(CollectionUtils.isEmpty(userInfoList)){
 | 
	
		
			
				|  |  | +                // 不存在就报错
 | 
	
		
			
				|  |  |                  throw new BusinessException("EB8000015");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        UserLoginMapper userLoginDAO = UtilTools.getBean(UserLoginMapper.class);
 | 
	
		
			
				|  |  | -        UserLogin userLogin = new UserLogin();
 | 
	
		
			
				|  |  | -        userLogin.setId(UtilTools.getUUid());
 | 
	
		
			
				|  |  | -        userLogin.setUid(sysUser.getId());
 | 
	
		
			
				|  |  | -        userLogin.setLoginName(this.getA_a00002().getLoginName());
 | 
	
		
			
				|  |  | -        userLogin.setLoginTime(XIDateTimeUtils.getNowDate());
 | 
	
		
			
				|  |  | -        userLogin.setLoginIp(XIUtils.getClientIp());
 | 
	
		
			
				|  |  | -        userLogin.setWrongTimes(0);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        userLogin.setLoginType(LoginType.getLoginType(loginType).getDesc());
 | 
	
		
			
				|  |  | -        userLogin.setLoginWay(LoginWay.getLoginWay(loginWay).getDesc()); //0手动登录 1-自动登录
 | 
	
		
			
				|  |  | -        userLogin.setLoginMedia(LoginMedia.getLoginMedia(loginMedia).getDesc());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        userLogin.setCreateTime(XIDateTimeUtils.getNowDate());
 | 
	
		
			
				|  |  | -        userLogin.setUpdateTime(userLogin.getCreateTime());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        userLogin.setStatus(Loginflag.sucess.getIndex()); //默认登录成功
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        userLogin.setLoginCode(XIUtils.getNormalReturnCode());
 | 
	
		
			
				|  |  | -        userLogin.setLoginMsg(Loginflag.sucess.getDesc());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if ("0".equals(this.getA_a00002().getType())) {// 如果是短信登录
 | 
	
		
			
				|  |  | +        // 如果存在
 | 
	
		
			
				|  |  | +        // 如果是短信登录
 | 
	
		
			
				|  |  | +        if ("0".equals(this.getA_a00002().getType())) {
 | 
	
		
			
				|  |  |              // 验证短信验证码
 | 
	
		
			
				|  |  |              if (!IdentifyingCodeUtil.verification(this.getA_a00002().getPhoneNo(), this.getA_a00002().getAuthCode())) {
 | 
	
		
			
				|  |  |                  // 验证码校验失败!
 | 
	
		
			
				|  |  |                  throw new BusinessException("EB8000021");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        }else if (loginWay.equals(LoginWay.MANUAL.getIndex())) { //手动登录
 | 
	
		
			
				|  |  | -            if (LoginType.PASSWD.getIndex().equals(loginType)) {// 密码登录
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                String password_ = XIDESedeCoderUtils.dec(this.getA_a00002().getPassword(), this.getA_systemhead().getClientToken());//3DES解密
 | 
	
		
			
				|  |  | -                if (!LoginService.encodePassword(sysUser.getId(), password_).equals(sysUser.getUserpwd())) {//比较密码是否相同
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    userLogin.setStatus(Loginflag.fail.getIndex());
 | 
	
		
			
				|  |  | -                    userLogin.setLoginCode("EB8000015");
 | 
	
		
			
				|  |  | -                    userLogin.setLoginMsg(UtilTools.getText(userLogin.getLoginCode()));
 | 
	
		
			
				|  |  | -                    userLoginDAO.insertSelective(userLogin);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    throw new BusinessException(userLogin.getLoginCode());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            } else if (LoginType.VERIFYCODE.getIndex().equals(loginType)) {// 验证码登录
 | 
	
		
			
				|  |  | -//			if (!IdentifyingCodeUtil.verification(this.getA_a00002().getPhoneNo(), this.getA_a00002().getAuthCode())) {
 | 
	
		
			
				|  |  | -//				// 验证码校验失败!
 | 
	
		
			
				|  |  | -//				throw new BusinessException("EB8000021");
 | 
	
		
			
				|  |  | -//			}
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        } else { //自动登录,验证clientToken
 | 
	
		
			
				|  |  | -            boolean isCheckJwtToken=false;
 | 
	
		
			
				|  |  | -            try {
 | 
	
		
			
				|  |  | -                isCheckJwtToken=LoginService.checkJwtTokenForUser(this.getA_systemhead().getUserId(), this.getA_systemhead().getClientToken());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            }catch (Exception e){}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (!isCheckJwtToken) {
 | 
	
		
			
				|  |  | -                userLogin.setStatus("1");
 | 
	
		
			
				|  |  | -                userLogin.setLoginCode("EB8000015");
 | 
	
		
			
				|  |  | -                userLogin.setLoginMsg(UtilTools.getText(userLogin.getLoginCode()));
 | 
	
		
			
				|  |  | -                userLoginDAO.insertSelective(userLogin);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                throw new BusinessException(userLogin.getLoginCode());
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            // 如果是密码登录
 | 
	
		
			
				|  |  | +            String password_ = XIDESedeCoderUtils.dec(this.getA_a00002().getPassword(), this.getA_systemhead().getClientToken());//3DES解密
 | 
	
		
			
				|  |  | +            if(!LoginService.encodePassword(userInfoList.get(0).getId(),password_).equals(userInfoList.get(0).getUserpwd())){//比较密码是否相同
 | 
	
		
			
				|  |  | +                throw new BusinessException("EB8000015");//用户名或密码错误!
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        // 如果是密码登录
 | 
	
		
			
				|  |  | +//		String password_ = DESedeCoderUtils.dec(this.getA_a00002().getPassword(), this.getA_systemhead().getClientToken());//3DES解密
 | 
	
		
			
				|  |  | +//		if(!LoginService.encodePassword(userInfoList.get(0).getId(),password_).equals(userInfoList.get(0).getUserpwd())){//比较密码是否相同
 | 
	
		
			
				|  |  | +//			throw new BusinessException("EB8000015");//用户名或密码错误!
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if (sysUser.getUserstate().equals(UserState.delete.getIndex())) {
 | 
	
		
			
				|  |  | -            userLogin.setStatus(Loginflag.fail.getIndex());
 | 
	
		
			
				|  |  | -            userLogin.setLoginCode("EB8000015");
 | 
	
		
			
				|  |  | -            userLogin.setLoginMsg(UtilTools.getText(userLogin.getLoginCode()));
 | 
	
		
			
				|  |  | -            userLoginDAO.insertSelective(userLogin);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            throw new BusinessException(userLogin.getLoginCode());
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if (sysUser.getUserstate().equals(UserState.black.getIndex())) {
 | 
	
		
			
				|  |  | -            userLogin.setStatus(Loginflag.fail.getIndex());
 | 
	
		
			
				|  |  | -            userLogin.setLoginCode("EB8000104");
 | 
	
		
			
				|  |  | -            userLogin.setLoginMsg(UtilTools.getText(userLogin.getLoginCode()));
 | 
	
		
			
				|  |  | -            userLoginDAO.insertSelective(userLogin);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            throw new BusinessException(userLogin.getLoginCode());
 | 
	
		
			
				|  |  | +        if(userInfoList.get(0).getUserstate().equals(UserState.black.getIndex())){
 | 
	
		
			
				|  |  | +            throw new BusinessException("EB8000104");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        SysUser sysUser =userInfoList.get(0);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        //若登录成功,增加登录日志,并正常返回
 | 
	
		
			
				|  |  | +        UserLoginMapper userLoginDAO = UtilTools.getBean(UserLoginMapper.class);
 | 
	
		
			
				|  |  | +        UserLoginSQLBuilder ulsb = new UserLoginSQLBuilder();
 | 
	
		
			
				|  |  | +        UserLogin userLogin = new UserLogin();
 | 
	
		
			
				|  |  | +        userLogin.setId(UtilTools.getUUid());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        userLogin.setLoginTime(XIDateTimeUtils.getNowDate());
 | 
	
		
			
				|  |  | +        userLogin.setLoginIp(XIUtils.getClientIp());
 | 
	
		
			
				|  |  | +        userLogin.setWrongTimes(0);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -//        //用户是否可用此登录渠道进行登录权限判断
 | 
	
		
			
				|  |  | -//        if (!XIUtils.getListFromStrDelEmpty(sysUser.getFuncids()).stream()
 | 
	
		
			
				|  |  | -//                .anyMatch(func -> func.equals(LoginMedia.getLoginMedia(loginMedia).getDesc()))) {
 | 
	
		
			
				|  |  | -//            userLogin.setStatus(Loginflag.fail.getIndex());
 | 
	
		
			
				|  |  | -//            userLogin.setLoginCode("EB8000012");
 | 
	
		
			
				|  |  | -//            userLogin.setLoginMsg(UtilTools.getText(userLogin.getLoginCode()));
 | 
	
		
			
				|  |  | -//            userLoginDAO.insertSelective(userLogin);
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//            throw new BusinessException(userLogin.getLoginCode());
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | +        userLogin.setStatus("");
 | 
	
		
			
				|  |  | +        userLogin.setCreateTime(XIDateTimeUtils.getNowDate());
 | 
	
		
			
				|  |  | +        userLogin.setUpdateTime(userLogin.getCreateTime());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        ///////////////////////////////
 | 
	
		
			
				|  |  | -        userLoginDAO.insertSelective(userLogin);
 | 
	
		
			
				|  |  | +        userLoginDAO.insert(userLogin);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          String userId = sysUser.getId();
 | 
	
		
			
				|  |  |          String tocken = this.getA_systemhead().getClientToken();
 | 
	
		
			
				|  |  | -        if (loginWay.equals(LoginWay.MANUAL.getIndex())) { //手动登录
 | 
	
		
			
				|  |  | -            if (UtilTools.isNotNullAndBlank(this.getA_a00002().getIsLoginAuto()) && this.getA_a00002().getIsLoginAuto().equals("1")) {
 | 
	
		
			
				|  |  | -                tocken = JwtManageUtil.getClientLoginAutoJWT(MFMiniCoreProperties.getInstance().getUniqueid(), userId, userId);
 | 
	
		
			
				|  |  | -            } else {
 | 
	
		
			
				|  |  | -                tocken = UUID.randomUUID().toString().replace("-", "").trim();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //部门自定义的用户权限
 | 
	
		
			
				|  |  |          Map deptFuncMap = new HashMap();
 |