| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CacheConstant; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | |
| | | import org.jeecg.modules.system.model.SysUserSysDepartModel; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jeecg.modules.system.vo.EamUserRepDepVo; |
| | | import org.jeecg.modules.system.vo.MdcUserProVo; |
| | | import org.jeecg.modules.system.vo.SysUserDepVo; |
| | | import org.jeecg.modules.system.vo.UserSelector; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | |
| | | SysRoleIndexMapper sysRoleIndexMapper; |
| | | @Resource |
| | | MdcUserProductionMapper mdcUserProductionMapper; |
| | | @Resource |
| | | EamBaseRepairDepartUserMapper eamBaseRepairDepartUserMapper; |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | |
| | |
| | | /** |
| | | * 根据设备车间管理Id查询 |
| | | * @param page |
| | | * @param workShopDepartId 设备车间管理Id |
| | | * @param baseFactoryId 设备车间管理Id |
| | | * @return |
| | | */ |
| | | public IPage<SysUser> getUserByworkShopDepartId(Page<SysUser> page,String workShopDepartId,String username){ |
| | | return userMapper.getUserByWorkShopDepartId(page,workShopDepartId,username); |
| | | public IPage<SysUser> getUserByworkShopDepartId(Page<SysUser> page,String baseFactoryId,String username){ |
| | | return userMapper.getUserByWorkShopDepartId(page,baseFactoryId,username); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveUser(SysUser user, String selectedRoles, String selectedDeparts, String selectedProductions) { |
| | | public void saveUser(SysUser user, String selectedRoles, String selectedDeparts, String selectedProductions, String selectedRepairDeparts) { |
| | | //step.1 保存用户 |
| | | this.save(user); |
| | | //step.2 保存角色 |
| | |
| | | mdcUserProductionMapper.insert(mdcUserProduction); |
| | | } |
| | | } |
| | | //step.5 保存所属维修部门 |
| | | if (oConvertUtils.isNotEmpty(selectedRepairDeparts)) { |
| | | String[] arr = selectedRepairDeparts.split(","); |
| | | for (String repairDepartId : arr) { |
| | | EamBaseRepairDepartUser eamBaseRepairDepartUser = new EamBaseRepairDepartUser(user.getId(), repairDepartId); |
| | | eamBaseRepairDepartUserMapper.insert(eamBaseRepairDepartUser); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) |
| | | public void editUser(SysUser user, String roles, String departs, String productions) { |
| | | public void editUser(SysUser user, String roles, String departs, String productions, String repairDeparts) { |
| | | //step.1 修改用户基础信息 |
| | | this.updateById(user); |
| | | //step.2 修改角色 |
| | |
| | | mdcUserProductionMapper.insert(mdcUserProduction); |
| | | } |
| | | } |
| | | //step.5 修改维修部门 |
| | | String[] arrayRepDep = {}; |
| | | if(oConvertUtils.isNotEmpty(repairDeparts)){ |
| | | arrayRepDep = repairDeparts.split(","); |
| | | } |
| | | //先删后加 |
| | | eamBaseRepairDepartUserMapper.delete(new QueryWrapper<EamBaseRepairDepartUser>().lambda().eq(EamBaseRepairDepartUser::getUserId, user.getId())); |
| | | if (oConvertUtils.isNotEmpty(repairDeparts)) { |
| | | for (String repairDepartId : arrayRepDep) { |
| | | EamBaseRepairDepartUser eamBaseRepairDepartUser = new EamBaseRepairDepartUser(user.getId(), repairDepartId); |
| | | eamBaseRepairDepartUserMapper.insert(eamBaseRepairDepartUser); |
| | | } |
| | | } |
| | | //step.5 修改手机号和邮箱 |
| | | // 更新手机号、邮箱空字符串为 null |
| | | userMapper.updateNullByEmptyString("email"); |
| | |
| | | return res; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, String> getRepDepNamesByUserIds(List<String> userIds) { |
| | | List<EamUserRepDepVo> list = this.baseMapper.getRepDepNamesByUserIds(userIds); |
| | | |
| | | Map<String, String> res = new HashMap<>(5); |
| | | list.forEach(item -> { |
| | | if (res.get(item.getUserId()) == null) { |
| | | res.put(item.getUserId(), item.getRepairDepartName()); |
| | | } else { |
| | | res.put(item.getUserId(), res.get(item.getUserId()) + "," + item.getRepairDepartName()); |
| | | } |
| | | }); |
| | | return res; |
| | | } |
| | | |
| | | // 根据角色Id查询该角色下的所有用户信息 |
| | | @Override |
| | | public List<SysUser> getAllUsersByRoleId(String roleId) { |
| | |
| | | public List<SysUser> getEquipmentAdmin(String roleCode, String equipmentId) { |
| | | return this.baseMapper.getEquipmentAdmin(roleCode, equipmentId); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserSelector> selectOperatorList(String equipmentCode, String productionId, String positionCode) { |
| | | LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(SysUser::getPost, positionCode); |
| | | if(StringUtils.isNotBlank(equipmentCode)) { |
| | | queryWrapper.and(q -> q.isNull(SysUser::getEquipmentIds).or().eq(SysUser::getEquipmentIds, "").or().like(SysUser::getEquipmentIds, equipmentCode)); |
| | | } |
| | | if(StringUtils.isNotBlank(productionId)) { |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id=sys_user.id and t.pro_id={0}", productionId); |
| | | } |
| | | queryWrapper.eq(SysUser::getDelFlag, CommonConstant.DEL_FLAG_0); |
| | | queryWrapper.eq(SysUser::getStatus, CommonConstant.DEL_FLAG_1); |
| | | queryWrapper.orderByDesc(SysUser::getId); |
| | | List<SysUser> sysUsers = userMapper.selectList(queryWrapper); |
| | | List<UserSelector> collect = sysUsers.stream().map(user -> new UserSelector(user.getId(), user.getUsername(), user.getRealname())).collect(Collectors.toList()); |
| | | return collect; |
| | | } |
| | | |
| | | /** |
| | | * 选择用户 |
| | | * @param equipmentCode 选择的设备ID |
| | | * @param factoryId 选择的工厂ID |
| | | * @param positionCode 岗位编号 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<UserSelector> selectOperatorFactoryList(String equipmentCode, String factoryId, String positionCode){ |
| | | LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(SysUser::getPost, positionCode); |
| | | // if(StringUtils.isNotBlank(equipmentCode)) { |
| | | // queryWrapper.and(q -> q.isNull(SysUser::getEquipmentIds).or().eq(SysUser::getEquipmentIds, "").or().like(SysUser::getEquipmentIds, equipmentCode)); |
| | | // } |
| | | // if(StringUtils.isNotBlank(factoryId)) { |
| | | // queryWrapper.exists("select 1 from eam_base_factory_user t where t.user_id=sys_user.id and t.factory_id={0}", factoryId); |
| | | // } |
| | | queryWrapper.eq(SysUser::getDelFlag, CommonConstant.DEL_FLAG_0); |
| | | queryWrapper.eq(SysUser::getStatus, CommonConstant.DEL_FLAG_1); |
| | | queryWrapper.orderByDesc(SysUser::getId); |
| | | List<SysUser> sysUsers = userMapper.selectList(queryWrapper); |
| | | List<UserSelector> collect = sysUsers.stream().map(user -> new UserSelector(user.getId(), user.getUsername(), user.getRealname())).collect(Collectors.toList()); |
| | | return collect; |
| | | } |
| | | |
| | | @Override |
| | | public List<UserSelector> selectOperatorList(String positionCode) { |
| | | LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(SysUser::getPost, positionCode); |
| | | queryWrapper.eq(SysUser::getDelFlag, CommonConstant.DEL_FLAG_0); |
| | | queryWrapper.eq(SysUser::getStatus, CommonConstant.DEL_FLAG_1); |
| | | queryWrapper.orderByDesc(SysUser::getId); |
| | | List<SysUser> sysUsers = userMapper.selectList(queryWrapper); |
| | | List<UserSelector> collect = sysUsers.stream().map(user -> new UserSelector(user.getId(), user.getUsername(), user.getRealname())).collect(Collectors.toList()); |
| | | return collect; |
| | | } |
| | | } |