bug
jiangping
2023-12-06 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5
server/src/main/java/doumeemes/biz/system/impl/SystemUserBizImpl.java
@@ -10,6 +10,7 @@
import doumeemes.core.utils.DateUtil;
import doumeemes.core.utils.Utils;
import doumeemes.core.utils.excel.EasyExcelUtil;
import doumeemes.dao.business.CompanyMapper;
import doumeemes.dao.business.CompanyPositionMapper;
import doumeemes.dao.business.dto.AutoLoginUserDTO;
import doumeemes.dao.business.dto.CompanyInitDataDTO;
@@ -78,6 +79,9 @@
    private DepartmentExtService departmentExtService;
    @Autowired
    private CompanyUserExtMapper companyUserExtMapper;
    @Autowired
    private CompanyMapper companyMapper;
    @Override
    public void deleteById(Integer id) {
@@ -162,6 +166,18 @@
        if(plansList == null || plansList.size()==0){
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "导入数据内容有误!");
        }
        //添加企业员工关联关系
        CompanyUser cuw = new CompanyUser();
        cuw.setDeleted(Constants.ZERO);
        cuw.setRootDepartId(user.getRootDepartment().getId());
        Company company = companyMapper.selectById(user.getCompany().getId());
        if(company.getOpenUserNum() > 0){
            //人数限制输入0,表示不限制人数
            if(companyUserExtMapper.selectCount(new QueryWrapper<>(cuw)) + plansList.size() > company.getOpenUserNum() ){
                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户数量超过购买数量,请联系业务经理续购!");
            }
        }
        CompanyPosition cp = new CompanyPosition();
        cp.setDeleted(Constants.ZERO);
        cp.setCompanyId(user.getCompany().getId());
@@ -213,10 +229,13 @@
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,第【"+index+"】行【手机号】员工账号已经存!");
            }
            cuu.setPhone(null);
            cuu.setCode(p.getNo());
            if(companyUserService.findOne(cuu) !=null){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,第【"+index+"】行【工号】已经存!");
            if (StringUtils.isNotBlank(p.getNo())){
                cuu.setCode(p.getNo());
                if(companyUserService.findOne(cuu) !=null){
                    throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,第【"+index+"】行【工号】已经存!");
                }
            }
            SystemUser systemUser = new SystemUser();
            systemUser.setUsername(cu.getPhone());
            systemUser.setDeleted(Boolean.FALSE);
@@ -325,10 +344,12 @@
        cu.setDeleted(Constants.ZERO);
        cu.setCreateTime(date);
        cu.setCode("NO."+userParam.getPhone());
        cu.setIsMaster(com.getIsNew());//是否主账号
        cu.setPhoneAuthStatus(Constants.ZERO+"");
        cu.setQrcodeid(barcodeParamExtService.getByType(com.getId(),com.getRootDepartment().getId(),Constants.BARCODEPARAM_TYPE.user)+"");
        cu.setComDepartId(com.getRootDepartment().getId());
        cu.setDepartmentId(com.getRootDepartment().getId());
        cu.setOrigin(userParam.getOrigin());
        if(userParam.getOrigin() == Constants.COMPANY_ORIGIN.lingyang){
            cu.setLingyangUserid(userParam.getUserId());
        }else if(userParam.getOrigin() == Constants.COMPANY_ORIGIN.edgp){
@@ -362,6 +383,9 @@
            cu.setUserId(userId);
        }
        companyUserService.create(cu);
        CompanyUserExtListVO userModel = new CompanyUserExtListVO();
        BeanUtils.copyProperties(cu, userModel);
        com.setUserModel(userModel);
        if(StringUtils.equals(userParam.getManager(),Constants.ONE+"")){
            //如果是管理员角色,绑定默认角色
            SystemRole sr = new SystemRole();
@@ -463,7 +487,6 @@
        if(srList!=null && srList.size()>0){
            List<SystemUserRole> urList = new ArrayList<>();
            for(SystemRole tr :srList){
                SystemUserRole userRole = new SystemUserRole();
                userRole.setUserId(cu.getUserId());
                userRole.setDeleted(false);
@@ -473,7 +496,7 @@
                userRole.setCreateTime(userRole.getInvalidTime());
                userRole.setRemark("羚羊企业生成自动导入");
                urList.add(userRole);
//                    systemUserRoleMapper.insert(userRole);
//              systemUserRoleMapper.insert(userRole);
            }
            systemRoleMapper.insertRoleUserBatch(urList);
        }
@@ -542,10 +565,11 @@
            cu.setDeleted(Constants.ZERO);
            cu.setRootDepartId(loginUser.getRootDepartment().getId());
            //限制人数
            int limitUserNum = Constants.formatIntegerNum(loginUser.getCompany().getOpenUserNum());
            if(limitUserNum > 0){
//            int limitUserNum = Constants.formatIntegerNum(loginUser.getCompany().getOpenUserNum());
            Company company = companyMapper.selectById(loginUser.getCompany().getId());
            if(company.getOpenUserNum() > 0){
                //人数限制输入0,表示不限制人数
                if(companyUserExtMapper.selectCount(new QueryWrapper<>(cu)) +1 > limitUserNum ){
                if(companyUserExtMapper.selectCount(new QueryWrapper<>(cu)) +1 > company.getOpenUserNum() ){
                    throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户数量超过购买数量,请联系业务经理续购!");
                }
            }
@@ -569,10 +593,14 @@
                    throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "手机号已存在!");
                }
            }
            cu.setCode(systemUser.getEmpNo());
            if(companyUserService.findOne(cu) !=null){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "工号已存在");
            //存在工号需要唯一判断
            if (StringUtils.isNotBlank(systemUser.getEmpNo())){
                cu.setCode(systemUser.getEmpNo());
                if(companyUserService.findOne(cu) !=null){
                    throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "工号已存在");
                }
            }
            cu.setUserId(userId);
            cu.setComDepartId(loginUser.getComDepartment().getId());
            cu.setCreateUser(loginUser.getId());
@@ -688,6 +716,8 @@
                if (codeUser != null && !codeUser.getId().equals(cu.getId())) {
                    throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "工号已存在");
                }
            }else if (StringUtils.isBlank(systemUser.getEmpNo())) {
                u.setCode(systemUser.getEmpNo());
            }
            u.setId(cu.getId());
            u.setName(systemUser.getRealname());