| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.management.api.feignClient.TCompanyShopClient; |
| | | import com.ruoyi.management.api.feignClient.TCompanyShopToUserClient; |
| | | import com.ruoyi.management.api.feignClient.TCompanyToUserClient; |
| | | import com.ruoyi.management.api.model.AddUserShopClientDto; |
| | | import com.ruoyi.management.api.model.TCompanyShop; |
| | | import com.ruoyi.management.api.model.TCompanyShopToUser; |
| | | import com.ruoyi.management.api.model.TCompanyToUser; |
| | | import com.ruoyi.system.domain.dto.IndexDto; |
| | | import com.ruoyi.system.domain.vo.UserRoleVO; |
| | | import com.ruoyi.vehicle.api.domain.IndexVo; |
| | | import com.ruoyi.vehicle.api.feignClient.VehicleClient; |
| | | import com.ruoyi.system.api.model.*; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.domain.dto.AddCompanyUserDto; |
| | |
| | | private ISysConfigService configService; |
| | | |
| | | @Autowired |
| | | private TCompanyShopToUserClient companyShopToUserClient; |
| | | |
| | | @Resource |
| | | private TCompanyShopClient companyShopClient; |
| | | |
| | | @Autowired |
| | | private ISysUserRoleService userRoleService; |
| | | |
| | | @Autowired |
| | | private VehicleClient vehicleClient; |
| | | @Autowired |
| | | private TCompanyToUserClient companyToUserClient; |
| | | |
| | | @Autowired |
| | | private ISysUserRoleService sysUserRoleService; |
| | |
| | | PageInfo<SysUser> pageInfo = new PageInfo<>(pageNumber, pageSize); |
| | | PageInfo<SysUser> page = userService.getList(pageInfo, phonenumber); |
| | | return AjaxResult.success(page); |
| | | } |
| | | |
| | | /** |
| | | * 删除用户 |
| | | */ |
| | | @PostMapping("/queryManageByCompanyId") |
| | | @ApiOperation(value = "通过公司id查询公司下的人员") |
| | | public AjaxResult<List<UserRoleVO>> queryManageByCompanyId(@RequestParam Integer companyId, |
| | | @RequestParam(required = false) String nickName, |
| | | @RequestParam(required = false) String userPhone) { |
| | | |
| | | //根据 公司id查出中间表 |
| | | R<List<TCompanyShopToUser>> companyToUser = companyShopToUserClient.getCompanyToUser(Long.valueOf(companyId)); |
| | | List<TCompanyShopToUser> data = companyToUser.getData(); |
| | | if (data == null) { |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | R<List<TCompanyToUser>> companyToUserFromCompanyId = companyShopToUserClient.getCompanyToUserFromCompanyId(Long.valueOf(companyId)); |
| | | // |
| | | List<Integer> collect2 = data.stream().map(TCompanyShopToUser::getUserId).collect(Collectors.toList()); |
| | | if(companyToUserFromCompanyId.getData()!=null){ |
| | | List<Integer> collect = companyToUserFromCompanyId.getData().stream().map(TCompanyToUser::getUserId).collect(Collectors.toList()); |
| | | collect2.addAll(collect); |
| | | } |
| | | List<Integer> collect1 = collect2.stream().distinct().collect(Collectors.toList()); |
| | | |
| | | if(collect1.size()==0){ |
| | | collect1.add(-1); |
| | | } |
| | | |
| | | List<UserRoleVO> userRoleVOS = new ArrayList<>(); |
| | | // 查询该公司下的司管用户 |
| | | LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>(); |
| | | if(StringUtils.isNotEmpty(nickName)){ |
| | | wrapper.like(SysUser::getNickName,nickName); |
| | | } |
| | | if(StringUtils.isNotEmpty(userPhone)){ |
| | | wrapper.like(SysUser::getPhonenumber,userPhone); |
| | | } |
| | | wrapper.ne(SysUser::getRoleType,1); |
| | | wrapper.ne(SysUser::getRoleType,2); |
| | | |
| | | // 查询公司绑定的用户 |
| | | List<SysUser> list = userService.list(Wrappers.lambdaQuery(SysUser.class) |
| | | .in(SysUser::getUserId, collect1)); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return AjaxResult.success(userRoleVOS); |
| | | }else { |
| | | List<Long> userIds = list.stream().map(SysUser::getUserId).collect(Collectors.toList()); |
| | | wrapper.in(SysUser::getUserId,userIds); |
| | | } |
| | | |
| | | List<SysUser> userList = userService.list(wrapper); |
| | | userList.forEach(e->{ |
| | | UserRoleVO userRoleVO = new UserRoleVO(); |
| | | userRoleVO.setManageId(e.getUserId().intValue()); |
| | | userRoleVO.setManageName(e.getNickName()); |
| | | userRoleVO.setUserName(e.getUserName()); |
| | | userRoleVOS.add(userRoleVO); |
| | | }); |
| | | return AjaxResult.success(userRoleVOS); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | @GetMapping("/companyUserList") |
| | | @ApiOperation("门店账户列表 参数 公司id") |
| | | public AjaxResult list(Long companyId, int pageNumber, int pageSize) { |
| | | if (companyId == null) { |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | //根据 公司id查出中间表 |
| | | R<List<TCompanyShopToUser>> companyToUser = companyShopToUserClient.getCompanyToUser(companyId); |
| | | List<TCompanyShopToUser> data = companyToUser.getData(); |
| | | if (data == null) { |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | R<List<TCompanyToUser>> companyToUserFromCompanyId = companyShopToUserClient.getCompanyToUserFromCompanyId(companyId); |
| | | // |
| | | PageInfo<SysUser> pageInfo = new PageInfo<>(pageNumber, pageSize); |
| | | List<Integer> collect2 = data.stream().map(TCompanyShopToUser::getUserId).collect(Collectors.toList()); |
| | | if(companyToUserFromCompanyId.getData()!=null){ |
| | | List<Integer> collect = companyToUserFromCompanyId.getData().stream().map(TCompanyToUser::getUserId).collect(Collectors.toList()); |
| | | collect2.addAll(collect); |
| | | } |
| | | List<Integer> collect1 = collect2.stream().distinct().collect(Collectors.toList()); |
| | | |
| | | if(collect1.size()==0){ |
| | | collect1.add(-1); |
| | | } |
| | | PageInfo<SysUser> page = userService.getAllList(pageInfo,collect1 ); |
| | | ArrayList<TCompanyToUserVo> tCompanyToUserVos = new ArrayList<>(); |
| | | for (SysUser sysUser : page.getRecords()) { |
| | | TCompanyToUserVo tCompanyToUserVo = new TCompanyToUserVo(); |
| | | tCompanyToUserVo.setId(sysUser.getUserId()); |
| | | tCompanyToUserVo.setCreateTime(sysUser.getCreateTime()); |
| | | tCompanyToUserVo.setLoginDate(sysUser.getLoginDate()); |
| | | tCompanyToUserVo.setPhonenumber(sysUser.getPhonenumber()); |
| | | tCompanyToUserVo.setStatus(sysUser.getStatus()); |
| | | tCompanyToUserVo.setUserName(sysUser.getUserName()); |
| | | SysUserRole one = userRoleService.getOne(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, sysUser.getUserId())); |
| | | SysRole sysRole = roleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleId,one.getRoleId())); |
| | | tCompanyToUserVo.setRoleName(sysRole.getRoleName()); |
| | | // 当前用户的门店ids |
| | | List<Integer> collect = data.stream().filter(e -> e.getUserId().toString().equals(sysUser.getUserId().toString())).map(TCompanyShopToUser::getShopId).collect(Collectors.toList()); |
| | | R<List<TCompanyShop>> listR1 = companyShopClient.queryShopByShopId(collect); |
| | | List<String> shopNames = listR1.getData().stream().map(TCompanyShop::getShopName).collect(Collectors.toList()); |
| | | tCompanyToUserVo.setShopName(shopNames); |
| | | tCompanyToUserVos.add(tCompanyToUserVo); |
| | | } |
| | | PageInfo<TCompanyToUserVo> tCompanyToUserVoPageInfo = new PageInfo<>(); |
| | | BeanUtils.copyProperties(page, tCompanyToUserVoPageInfo); |
| | | tCompanyToUserVoPageInfo.setRecords(tCompanyToUserVos); |
| | | return AjaxResult.success(tCompanyToUserVoPageInfo); |
| | | } |
| | | |
| | | |
| | | @Log(title = "账号管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/addCompanyUser") |
| | | @ApiOperation("账号管理--添加账号") |
| | |
| | | sysUserRole.setRoleId(dto.getRoleId()); |
| | | sysUserRole.setUserId(dto.getSysUser().getUserId()); |
| | | userRoleService.insertSysUserRole(sysUserRole); |
| | | |
| | | // 添加t_company_shop_to_user |
| | | companyShopToUserClient.addUserShop(new AddUserShopClientDto(dto.getSysUser().getUserId(), dto.getShopIds())); |
| | | ArrayList<Integer> id = new ArrayList<>(); |
| | | id.add(dto.getCompanyId()); |
| | | companyShopToUserClient.addUserCompany(new AddUserShopClientDto(dto.getSysUser().getUserId(), id)); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | CompanyUserVo companyUserVo = new CompanyUserVo(); |
| | | companyUserVo.setRoleId(sysUserRole.getRoleId()); |
| | | companyUserVo.setSysUser(sysUser); |
| | | // 远程根据userID 获取门店id |
| | | R<List<Integer>> shopIdsFromUserId = companyShopToUserClient.getShopIdsFromUserId(userId); |
| | | companyUserVo.setShopIds(shopIdsFromUserId.getData()); |
| | | return AjaxResult.success(companyUserVo); |
| | | } |
| | | |
| | |
| | | one.setRoleId(dto.getRoleId()); |
| | | //更新新的role |
| | | userRoleService.updateSysUserRole(one); |
| | | |
| | | // 更新t_company_shop_to_user |
| | | companyShopToUserClient.updateUserShop(new AddUserShopClientDto(dto.getSysUser().getUserId(), dto.getShopIds())); |
| | | // } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | |
| | | @Autowired |
| | | private ISysUserRoleService iSysUserRoleService; |
| | | @GetMapping("/getAllManager") |
| | | @ApiOperation("查询司管角色的用户") |
| | | public AjaxResult getAllManager(@RequestParam Integer companyId, |
| | | @RequestParam(required = false) String nickName, |
| | | @RequestParam(required = false) String userPhone) { |
| | | //根据 公司id查出中间表 |
| | | R<List<TCompanyShopToUser>> companyToUser = companyShopToUserClient.getCompanyToUser(companyId.longValue()); |
| | | List<TCompanyShopToUser> data = companyToUser.getData(); |
| | | if (data == null) { |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | R<List<TCompanyToUser>> companyToUserFromCompanyId = companyShopToUserClient.getCompanyToUserFromCompanyId(companyId.longValue()); |
| | | // |
| | | List<Integer> collect2 = data.stream().map(TCompanyShopToUser::getUserId).collect(Collectors.toList()); |
| | | if(companyToUserFromCompanyId.getData()!=null){ |
| | | List<Integer> collect = companyToUserFromCompanyId.getData().stream().map(TCompanyToUser::getUserId).collect(Collectors.toList()); |
| | | collect2.addAll(collect); |
| | | } |
| | | List<Integer> collect1 = collect2.stream().distinct().collect(Collectors.toList()); |
| | | |
| | | if(collect1.size()==0){ |
| | | collect1.add(-1); |
| | | } |
| | | |
| | | List<UserRoleVO> userRoleVOS = new ArrayList<>(); |
| | | // 查询该公司下的司管用户 |
| | | LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>(); |
| | | if(StringUtils.isNotEmpty(nickName)){ |
| | | wrapper.like(SysUser::getNickName,nickName); |
| | | } |
| | | if(StringUtils.isNotEmpty(userPhone)){ |
| | | wrapper.like(SysUser::getPhonenumber,userPhone); |
| | | } |
| | | wrapper.ne(SysUser::getRoleType,1); |
| | | wrapper.ne(SysUser::getRoleType,2); |
| | | |
| | | // 查询公司绑定的用户 |
| | | List<SysUser> list = userService.list(Wrappers.lambdaQuery(SysUser.class) |
| | | .in(SysUser::getUserId, collect1)); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return AjaxResult.success(userRoleVOS); |
| | | }else { |
| | | List<Long> userIds = list.stream().map(SysUser::getUserId).collect(Collectors.toList()); |
| | | wrapper.in(SysUser::getUserId,userIds); |
| | | } |
| | | |
| | | List<SysUser> userList = userService.list(wrapper); |
| | | userList.forEach(e->{ |
| | | UserRoleVO userRoleVO = new UserRoleVO(); |
| | | userRoleVO.setManageId(e.getUserId().intValue()); |
| | | userRoleVO.setManageName(e.getNickName()); |
| | | userRoleVO.setUserName(e.getUserName()); |
| | | userRoleVOS.add(userRoleVO); |
| | | }); |
| | | return AjaxResult.success(userRoleVOS); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/getUserList") |
| | |
| | | List<SysUser> list = userService.list(new LambdaQueryWrapper<SysUser>().in(SysUser::getUserId, userIds)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/index") |
| | | @ApiOperation("工作台") |
| | | public AjaxResult index(@RequestBody IndexDto dto) { |
| | | R<IndexVo> index = vehicleClient.indexShopIds(dto.getShopIds()); |
| | | return AjaxResult.success(index.getData()==null?new IndexVo():index.getData()); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/getSysUserFromCompanyId") |
| | | public R<List<CompanyUserListVo>> getSysUserFromCompanyId(@RequestBody CompanySysUserReq companySysUserReq) { |