| | |
| | | private final IUserDeptService userDeptService; |
| | | private final IUserOauthService userOauthService; |
| | | private final IRoleService roleService; |
| | | private final IDeptService deptService; |
| | | private final BladeTenantProperties tenantProperties; |
| | | private final IPoliceAffairsGridService policeAffairsGridService; |
| | | |
| | |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | boolean save = save(user); |
| | | // 更新警格或网格的绑定 |
| | | updateGridBind(user); |
| | | // 返回 |
| | | return save && submitUserDept(user); |
| | | } |
| | |
| | | user.setPassword(null); |
| | | boolean b = updateById(user); |
| | | // 更新警格或网格的绑定 |
| | | updateGridBind(user); |
| | | // updateGridBind(user); |
| | | return b; |
| | | } |
| | | |
| | |
| | | * @param tenantId |
| | | * @param account |
| | | * @param password |
| | | * @param type 登录类型 2:pc 3:app |
| | | * @param type 登录类型 2:pc 3:app |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param user |
| | | * @param type 登录类型 2:pc 3:app |
| | | * @return |
| | |
| | | userInfo.setUser(user); |
| | | if (Func.isNotEmpty(user)) { |
| | | // 判断登录类型设置对应的角色id |
| | | user.setRoleId(Strings.join(roleService.getRoleIdStrByRoleIdAndType(user.getRoleId(),type), ',')); |
| | | user.setRoleId(Strings.join(roleService.getRoleIdStrByRoleIdAndType(user.getRoleId(), type), ',')); |
| | | // 设置角色别名 |
| | | List<String> roleAlias = roleService.getRoleAliases(user.getRoleId()); |
| | | userInfo.setRoles(roleAlias); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean registerUser(UserVO user) { |
| | | if (StringUtils.isEmpty(user.getAccount())) { |
| | | throw new ServiceException("账号不能为空!"); |
| | | } |
| | | if (StringUtils.isEmpty(user.getPassword())) { |
| | | throw new ServiceException("密码不能为空!"); |
| | | } |
| | | if (!StringUtils.equals(user.getPassword(), user.getPassword2())) { |
| | | throw new ServiceException("两次的密码不一致!"); |
| | | } |
| | | long count = count(Wrappers.<User>lambdaQuery().eq(User::getAccount, user.getAccount())); |
| | | if (count > 0) { |
| | | throw new ServiceException("改账号已存在,请更换其他账号!"); |
| | | } |
| | | |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | user.setRoleId("1717429059648606209"); |
| | | boolean oauthTemp = save(user); |
| | | return (oauthTemp); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updatePlatform(Long userId, Integer userType, String userExt) { |
| | | if (userType.equals(UserEnum.WEB.getCategory())) { |
| | | UserWeb userWeb = new UserWeb(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理漏绑定的user_dept |
| | | */ |
| | |
| | | for (PoliceUserExcel userExcel : data) { |
| | | // 查询用户 |
| | | List<User> list = getUserListByPhoneOrAccount(userExcel.getPhone()); |
| | | |
| | | if (list.size() > 0) { |
| | | User userInfo = list.get(0); |
| | | // 判断角色 |
| | | if (!userInfo.getRoleId().contains("1727864411451359233")) { |
| | | userInfo.setRoleId(userInfo.getRoleId() + ",1727864411451359233"); |
| | | } |
| | | // 设置性别 |
| | | setSex(userInfo, userExcel); |
| | | // 更新机构 |
| | | setDeptId(userInfo, userExcel); |
| | | // 更新 |
| | | updateById(userInfo); |
| | | // 更新用户机构绑定 |
| | | submitUserDept(userInfo); |
| | | // 更新社区民警绑定信息 |
| | | updateGridBind(userInfo); |
| | | } else { |
| | | // 插入用户角色 |
| | | User user = new User(); |
| | |
| | | user.setRealName(userExcel.getRealName()); |
| | | user.setPhone(userExcel.getPhone()); |
| | | user.setAccount(userExcel.getPhone()); |
| | | // 设置性别 |
| | | setSex(user, userExcel); |
| | | // 更新机构 |
| | | setDeptId(user, userExcel); |
| | | // 设置初始密码 |
| | |
| | | submit(user); |
| | | // 更新用户机构绑定 |
| | | submitUserDept(user); |
| | | // 更新社区民警绑定信息 |
| | | updateGridBind(user); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置性别 |
| | | * |
| | | * @param user |
| | | * @param userExcel |
| | | */ |
| | | private void setSex(User user, PoliceUserExcel userExcel) { |
| | | if (userExcel.getSex().contains("男")) { |
| | | user.setSex(1); |
| | | } |
| | | if (userExcel.getSex().contains("女")) { |
| | | user.setSex(2); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public void setDeptId(User user, PoliceUserExcel userExcel) { |
| | | // 查询机构 |
| | | QueryWrapper<PoliceAffairsGridEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_deleted", 0) |
| | | .eq("community_code", userExcel.getCommunityCode()) |
| | | .eq("pcs_name", userExcel.getPoliceStationName()); |
| | | PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridService.getOne(queryWrapper); |
| | | if (null != policeAffairsGridEntity) { |
| | | // 查询对应绑定的机构 |
| | | QueryWrapper<Dept> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("dept_nature", 1) |
| | | .eq("region_code", policeAffairsGridEntity.getJwGridCode()); |
| | | Dept dept = SpringUtil.getBean(IDeptService.class).getOne(wrapper); |
| | | if (null != dept) { |
| | | if (null != user.getId()) { |
| | | DeptNotHandle(user, dept); |
| | | } else { |
| | | user.setDeptId(dept.getId().toString()); |
| | | } |
| | | } |
| | | } |
| | | String deptIds = deptService.getDeptIds("000000", userExcel.getDeptName()); |
| | | user.setDeptId(deptIds); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (!user.getDeptId().contains(dept.getId().toString())) { |
| | | user.setDeptId(user.getDeptId() + "," + dept.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新社区民警绑定信息 |
| | | * |
| | | * @param userExcel |
| | | * @param user |
| | | */ |
| | | public void updateCommunityInfo(PoliceUserExcel userExcel, User user) { |
| | | QueryWrapper<CommunityEntity> wrapper = new QueryWrapper<>(); |
| | | System.out.println("wrapper = " + userExcel.getCommunityCode()); |
| | | wrapper.eq("is_deleted", 0).eq("code", userExcel.getCommunityCode()); |
| | | CommunityEntity one = SpringUtil.getBean(ICommunityService.class).getOne(wrapper); |
| | | if (null != one) { |
| | | String userId = user.getId().toString(); |
| | | if (!Strings.isBlank(one.getResPoliceUserId())) { |
| | | if (!one.getResPoliceUserId().contains(userId)) { |
| | | one.setResPoliceUserId(one.getResPoliceUserId() + "," + userId); |
| | | // 更新 |
| | | SpringUtil.getBean(ICommunityService.class).updateById(one); |
| | | } |
| | | } else { |
| | | one.setResPoliceUserId(userId); |
| | | // 更新 |
| | | SpringUtil.getBean(ICommunityService.class).updateById(one); |
| | | } |
| | | } |
| | | } |