| | |
| | | @PostMapping("import-user") |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "导入用户", notes = "传入excel") |
| | | public R importUser(MultipartFile file, Integer isCovered) { |
| | | UserImporter userImporter = new UserImporter(userService, false); |
| | | public R importUser(MultipartFile file, Integer isCovered,String deptId) { |
| | | UserImporter userImporter = new UserImporter(userService, false,deptId); |
| | | ExcelUtil.save(file, userImporter, UserExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | |
| | | |
| | | private final IUserService service; |
| | | private final Boolean isCovered; |
| | | private final String deptId; |
| | | |
| | | @Override |
| | | public void save(List<UserExcel> data) { |
| | | service.importUser(data, isCovered); |
| | | service.importUser(data, isCovered,deptId); |
| | | } |
| | | } |
| | |
| | | * @param isCovered |
| | | * @return |
| | | */ |
| | | void importUser(List<UserExcel> data, Boolean isCovered); |
| | | void importUser(List<UserExcel> data, Boolean isCovered,String deptId); |
| | | |
| | | /** |
| | | * 导出用户数据 |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importUser(List<UserExcel> data, Boolean isCovered) { |
| | | public void importUser(List<UserExcel> data, Boolean isCovered,String deptId) { |
| | | data.forEach(userExcel -> { |
| | | User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class)); |
| | | // 设置租户ID |
| | |
| | | } |
| | | } |
| | | //设置部门id |
| | | user.setDeptId(userDeptService.selectIn(user.getDeptId())); |
| | | String deptIds = userDeptService.selectIn(user.getDeptId()); |
| | | if (null!=deptIds && !deptIds.equals("")) { |
| | | if (null != deptId && !deptId.equals("")) { |
| | | if (!deptId.equals(deptIds)) { |
| | | throw new ServiceException("不能导入不是本公司的保安员数据!"); |
| | | } |
| | | } |
| | | user.setDeptId(deptIds); |
| | | } |
| | | //设置账号 |
| | | user.setAccount(user.getCardid()); |
| | | //获取默认密码配置 |
| | |
| | | <if test="trainingRegistration.userId!=null and trainingRegistration.userId!=''"> |
| | | and sr.user_id = #{trainingRegistration.userId} |
| | | </if> |
| | | <if test="trainingRegistration.deptId!=null and trainingRegistration.deptId!=''"> |
| | | and bu.dept_id = #{trainingRegistration.deptId} |
| | | </if> |
| | | <if test="trainingRegistration.auditStatus!=null and trainingRegistration.auditStatus!=0"> |
| | | and sr.audit_status = #{trainingRegistration.auditStatus} |
| | | </if> |