|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | private DepartmentExtService departmentExtService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyUserExtMapper companyUserExtMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyMapper companyMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|
|  |  |  | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(),"用户数量超过购买数量,请联系业务经理续购!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|