| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.catalina.User; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CacheConstant; |
| | |
| | | import org.jeecg.common.util.PasswordUtil; |
| | | import org.jeecg.common.util.UUIDGenerator; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.base.entity.UserFactory; |
| | | import org.jeecg.modules.base.mapper.UserFactoryMapper; |
| | | import org.jeecg.modules.base.service.BaseCommonService; |
| | | import org.jeecg.modules.system.entity.*; |
| | | import org.jeecg.modules.system.mapper.*; |
| | |
| | | @Autowired |
| | | SysRoleIndexMapper sysRoleIndexMapper; |
| | | @Resource |
| | | MdcUserProductionMapper mdcUserProductionMapper; |
| | | UserFactoryMapper userFactoryMapper; |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | @Resource |
| | | private MdcProductionEquipmentMapper mdcProductionEquipmentMapper; |
| | | @Resource |
| | | private DncDevicePermissionMapper dncDevicePermissionMapper; |
| | | |
| | | @Override |
| | | @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) |
| | |
| | | // 2. 删除用户部门关系 |
| | | line += sysUserDepartMapper.delete(new LambdaQueryWrapper<SysUserDepart>().in(SysUserDepart::getUserId, userIds)); |
| | | // 3. 删除用户产线关系 |
| | | line += mdcUserProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getUserId, userIds)); |
| | | line += userFactoryMapper.delete(new LambdaQueryWrapper<UserFactory>().in(UserFactory::getUserId, userIds)); |
| | | //3. 删除用户角色关系 |
| | | line += sysUserRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, userIds)); |
| | | //4.同步删除第三方App的用户 |
| | |
| | | //step.4 保存所属产线 |
| | | if (oConvertUtils.isNotEmpty(selectedProductions)) { |
| | | arr = selectedProductions.split(","); |
| | | for (String productionId : arr) { |
| | | MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId); |
| | | mdcUserProductionMapper.insert(mdcUserProduction); |
| | | for (String factoryId : arr) { |
| | | UserFactory userFactory = new UserFactory(user.getId(), factoryId); |
| | | userFactoryMapper.insert(userFactory); |
| | | } |
| | | } |
| | | //step.5 保存设备权限 |
| | | List<String> EquipmentIds= mdcProductionEquipmentMapper.selectList(new QueryWrapper<MdcProductionEquipment>().in("production_id",arr)) |
| | | .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | if (oConvertUtils.isNotEmpty(EquipmentIds)) { |
| | | for (String equipmentId : EquipmentIds) { |
| | | DncDevicePermission dncDevicePermission=new DncDevicePermission(); |
| | | dncDevicePermission.setDeviceId(equipmentId); |
| | | dncDevicePermission.setUserId(user.getId()); |
| | | dncDevicePermissionMapper.insert(dncDevicePermission); |
| | | } |
| | | } |
| | | // List<String> EquipmentIds= mdcProductionEquipmentMapper.selectList(new QueryWrapper<MdcProductionEquipment>().in("production_id",arr)) |
| | | // .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | // if (oConvertUtils.isNotEmpty(EquipmentIds)) { |
| | | // for (String equipmentId : EquipmentIds) { |
| | | // DncDevicePermission dncDevicePermission=new DncDevicePermission(); |
| | | // dncDevicePermission.setDeviceId(equipmentId); |
| | | // dncDevicePermission.setUserId(user.getId()); |
| | | // dncDevicePermissionMapper.insert(dncDevicePermission); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | @Override |
| | |
| | | array = productions.split(","); |
| | | } |
| | | //先删后加 |
| | | mdcUserProductionMapper.delete(new QueryWrapper<MdcUserProduction>().lambda().eq(MdcUserProduction::getUserId, user.getId())); |
| | | userFactoryMapper.delete(new QueryWrapper<UserFactory>().lambda().eq(UserFactory::getUserId, user.getId())); |
| | | if (oConvertUtils.isNotEmpty(productions)) { |
| | | for (String productionId : array) { |
| | | MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId); |
| | | mdcUserProductionMapper.insert(mdcUserProduction); |
| | | for (String factoryId : array) { |
| | | UserFactory userFactory = new UserFactory(user.getId(), factoryId); |
| | | userFactoryMapper.insert(userFactory); |
| | | } |
| | | } |
| | | //step.5 修改设备权限 |
| | | //先删后加 |
| | | dncDevicePermissionMapper.delete(new QueryWrapper<DncDevicePermission>().lambda().eq(DncDevicePermission::getUserId, user.getId())); |
| | | List<String> EquipmentIds= mdcProductionEquipmentMapper.selectList(new QueryWrapper<MdcProductionEquipment>().in("production_id",array)) |
| | | .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | if (oConvertUtils.isNotEmpty(EquipmentIds)) { |
| | | for (String equipmentId : EquipmentIds) { |
| | | DncDevicePermission dncDevicePermission=new DncDevicePermission(); |
| | | dncDevicePermission.setDeviceId(equipmentId); |
| | | dncDevicePermission.setUserId(user.getId()); |
| | | dncDevicePermissionMapper.insert(dncDevicePermission); |
| | | } |
| | | } |
| | | // dncDevicePermissionMapper.delete(new QueryWrapper<DncDevicePermission>().lambda().eq(DncDevicePermission::getUserId, user.getId())); |
| | | // List<String> EquipmentIds= mdcProductionEquipmentMapper.selectList(new QueryWrapper<MdcProductionEquipment>().in("production_id",array)) |
| | | // .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | // if (oConvertUtils.isNotEmpty(EquipmentIds)) { |
| | | // for (String equipmentId : EquipmentIds) { |
| | | // DncDevicePermission dncDevicePermission=new DncDevicePermission(); |
| | | // dncDevicePermission.setDeviceId(equipmentId); |
| | | // dncDevicePermission.setUserId(user.getId()); |
| | | // dncDevicePermissionMapper.insert(dncDevicePermission); |
| | | // } |
| | | // } |
| | | //step.6 修改手机号和邮箱 |
| | | // 更新手机号、邮箱空字符串为 null |
| | | userMapper.updateNullByEmptyString("email"); |
| | |
| | | (existing, replacement) -> existing // 重复键处理 |
| | | )); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据班组Id查询 |
| | | * @param page |
| | | * @param groupId 班组id |
| | | * @param username 用户账户名称 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<SysUser> getUserByGroupId(Page<SysUser> page, String groupId, String username) { |
| | | return userMapper.getUserByGroupId(page,groupId,username); |
| | | } |
| | | } |