| | |
| | | import java.util.Set; |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.EasyExcelFactory; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.exception.ExcelDataConvertException; |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.type.StatesType; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.core.utils.PageUtil; |
| | | import com.consum.base.pojo.FinSysTenantUserSearchParam; |
| | | import com.consum.base.pojo.FinSysTenantUserUpdParam; |
| | | import com.consum.base.pojo.ImportUserParam; |
| | | import com.consum.base.pojo.RolePageParam; |
| | | import com.consum.base.pojo.request.FinSysTenantUserParam; |
| | | import com.consum.base.pojo.response.DepartmentVO; |
| | | import com.consum.base.pojo.response.FinSysTenantUserVO; |
| | |
| | | import com.iplatform.model.po.S_dept; |
| | | import com.iplatform.model.po.S_role; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.infrastructure.utils.NumberGenerator; |
| | |
| | | String tel = finSysTenantUser.getUserPhone() != null |
| | | ? AESUtils.decryptStrAES(finSysTenantUser.getUserPhone(), PlatformRSAUtils.AES_KEY) : null; |
| | | finSysTenantUser.setUserPhone(StringUtils.isNotEmpty(tel) ? PhoneNumberUtils.maskMobile(tel) : ""); |
| | | |
| | | // 列表不需要查询角色,只显示列表所需要的信息 |
| | | /*List<S_role> list = finSysTenantUserService.getByUserId(finSysTenantUser.getSysUserId()); |
| | | StringBuilder roleStr = new StringBuilder(); |
| | | list.forEach(s_role -> roleStr.append(s_role.getRole_name()).append(" ")); |
| | | finSysTenantUser.setRoleStr(roleStr.toString()); |
| | | finSysTenantUser.setIsSupplier(finSysTenantUser.getSupplierId() != null ? "是" : "否");*/ |
| | | |
| | | } |
| | | return ResponseValue.success(pager); |
| | |
| | | List<S_role> roles = this.roleService.select(new S_role()); |
| | | ArrayList<FinSysTenantUser> finSysTenantUsers = new ArrayList<>(); |
| | | |
| | | EasyExcel.read(file.getInputStream(), ImportUserParam.class, new AnalysisEventListener<ImportUserParam>() { |
| | | @Override |
| | | public void invoke(ImportUserParam data, AnalysisContext context) { |
| | | if (StringUtils.isEmpty(data.getUserName()) || StringUtils.isEmpty(data.getUserCode()) |
| | | || StringUtils.isEmpty(data.getUserPhone()) || null == data.getSex() |
| | | || StringUtils.isEmpty(data.getEmail()) || null == data.getSeq() |
| | | || StringUtils.isEmpty(data.getRoleName())) { |
| | | throw new ImportUserParamVerifyException("单元格不能为空!"); |
| | | } |
| | | // 根据员工编号查询,如果存在则提示 |
| | | if (finSysTenantUserService.getByUserCode(data.getUserCode()) != null) { |
| | | throw new ImportUserParamVerifyException("员工编号为空或已存在!"); |
| | | } |
| | | if (data.getSex() < 1 && data.getSex() > 0) { |
| | | throw new ImportUserParamVerifyException("性别码只能为 0 或 1"); |
| | | } |
| | | FinSysTenantUser user = new FinSysTenantUser(); |
| | | user.setUserName(data.getUserName()); |
| | | user.setUserCode(data.getUserCode()); |
| | | user.setUserPhone(data.getUserPhone()); |
| | | user.setSex(data.getSex()); |
| | | user.setEmail(data.getEmail()); |
| | | user.setSeq(data.getSeq()); |
| | | user.setTenantId(tenantId); |
| | | user.setTenantCode(tenantCode); |
| | | // 设置角色 |
| | | Optional<S_role> sRole = |
| | | roles.stream().filter(role -> role.getRole_name().equals(data.getRoleName())).findFirst(); |
| | | user.setRoleList(Arrays.asList(sRole.orElse(new S_role()).getRole_id())); |
| | | |
| | | user.setId(NumberGenerator.getLongSequenceNumber()); |
| | | user.setCreateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | user.setCreateBy(currentUser.getUser_name()); |
| | | user.setUpdateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | user.setUpdateBy(currentUser.getUser_name()); |
| | | user.setStatus(1);// 0禁用 1启用 |
| | | user.setIsDelete(0);// 是否删除 0是 1否 |
| | | user.setSysUserId(NumberGenerator.getLongSequenceNumber()); |
| | | user.setRemark("批量导入"); |
| | | // 加密手机号 |
| | | setUserPhone(user, data.getUserPhone()); |
| | | |
| | | user.setIsDelete(1); |
| | | // 怎么获取左侧机构树数据 |
| | | user.setSysDeptId(3L); // 对应平台机构id 默认为平台管理 |
| | | finSysTenantUsers.add(user); |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onException(Exception exception, AnalysisContext context) throws Exception { |
| | | if (exception != null) { |
| | | // 如果是某一个单元格的转换异常 能获取到具体行号 封装时异常 |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception; |
| | | logger.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(), |
| | | excelDataConvertException.getColumnIndex() + 1, |
| | | excelDataConvertException.getCellData().getStringValue()); |
| | | throw new IllegalStateException("第" + (excelDataConvertException.getRowIndex() + 1) + "行,第" |
| | | + (excelDataConvertException.getColumnIndex() + 1) + "列解析异常,异常数据为:[ " |
| | | + excelDataConvertException.getCellData().getStringValue() + " ]"); |
| | | EasyExcelFactory |
| | | .read(file.getInputStream(), ImportUserParam.class, new AnalysisEventListener<ImportUserParam>() { |
| | | @Override |
| | | public void invoke(ImportUserParam data, AnalysisContext context) { |
| | | if (StringUtils.isEmpty(data.getUserName()) || StringUtils.isEmpty(data.getUserCode()) |
| | | || StringUtils.isEmpty(data.getUserPhone()) || null == data.getSex() |
| | | || StringUtils.isEmpty(data.getEmail()) || null == data.getSeq() |
| | | || StringUtils.isEmpty(data.getRoleName())) { |
| | | throw new ImportUserParamVerifyException("单元格不能为空!"); |
| | | } |
| | | if (exception instanceof ImportUserParamVerifyException) { |
| | | throw new IllegalStateException("第" + context.readSheetHolder().getRowIndex() + "行, 解析错误:[ " |
| | | + exception.getMessage() + " ]"); |
| | | // 根据员工编号查询,如果存在则提示 |
| | | if (finSysTenantUserService.getByUserCode(data.getUserCode()) != null) { |
| | | throw new ImportUserParamVerifyException("员工编号为空或已存在!"); |
| | | } |
| | | throw exception; |
| | | if (data.getSex() < 1 && data.getSex() > 0) { |
| | | throw new ImportUserParamVerifyException("性别码只能为 0 或 1"); |
| | | } |
| | | FinSysTenantUser user = new FinSysTenantUser(); |
| | | user.setUserName(data.getUserName()); |
| | | user.setUserCode(data.getUserCode()); |
| | | user.setUserPhone(data.getUserPhone()); |
| | | user.setSex(data.getSex()); |
| | | user.setEmail(data.getEmail()); |
| | | user.setSeq(data.getSeq()); |
| | | user.setTenantId(tenantId); |
| | | user.setTenantCode(tenantCode); |
| | | // 设置角色 |
| | | Optional<S_role> sRole = |
| | | roles.stream().filter(role -> role.getRole_name().equals(data.getRoleName())).findFirst(); |
| | | user.setRoleList(Arrays.asList(sRole.orElse(new S_role()).getRole_id())); |
| | | |
| | | user.setId(NumberGenerator.getLongSequenceNumber()); |
| | | user.setCreateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | user.setCreateBy(currentUser.getUser_name()); |
| | | user.setUpdateTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | user.setUpdateBy(currentUser.getUser_name()); |
| | | user.setStatus(1);// 0禁用 1启用 |
| | | user.setIsDelete(0);// 是否删除 0是 1否 |
| | | user.setSysUserId(NumberGenerator.getLongSequenceNumber()); |
| | | user.setRemark("批量导入"); |
| | | // 加密手机号 |
| | | setUserPhone(user, data.getUserPhone()); |
| | | |
| | | user.setIsDelete(1); |
| | | // 怎么获取左侧机构树数据 |
| | | user.setSysDeptId(3L); // 对应平台机构id 默认为平台管理 |
| | | finSysTenantUsers.add(user); |
| | | } |
| | | } |
| | | }).sheet().doRead(); |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onException(Exception exception, AnalysisContext context) throws Exception { |
| | | if (exception != null) { |
| | | // 如果是某一个单元格的转换异常 能获取到具体行号 封装时异常 |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception; |
| | | logger.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(), |
| | | excelDataConvertException.getColumnIndex() + 1, |
| | | excelDataConvertException.getCellData().getStringValue()); |
| | | throw new IllegalStateException("第" + (excelDataConvertException.getRowIndex() + 1) + "行,第" |
| | | + (excelDataConvertException.getColumnIndex() + 1) + "列解析异常,异常数据为:[ " |
| | | + excelDataConvertException.getCellData().getStringValue() + " ]"); |
| | | } |
| | | if (exception instanceof ImportUserParamVerifyException) { |
| | | throw new IllegalStateException("第" + context.readSheetHolder().getRowIndex() + "行, 解析错误:[ " |
| | | + exception.getMessage() + " ]"); |
| | | } |
| | | throw exception; |
| | | } |
| | | } |
| | | }).sheet().doRead(); |
| | | |
| | | insertUserAndUserCoreBatch(finSysTenantUsers); |
| | | |
| | |
| | | finSysTenantUser.setStatus(user.getStatus()); |
| | | finSysTenantUserService.update(finSysTenantUser); |
| | | // 2.更新平台用户 S_USER_CORE |
| | | S_user_core userCore = buildUpdateUserCore(tenantUser); |
| | | S_user_core userCore = buildUpdateUserCore(finSysTenantUser); |
| | | this.userService.update(userCore); |
| | | return ResponseValue.success(1); |
| | | } |
| | |
| | | finSysTenantUser.setUserPhone(phone); |
| | | Long sysUserId = finSysTenantUser.getSysUserId(); |
| | | List<S_role> roleList = finSysTenantUserService.getRoleBySysUserId(sysUserId); |
| | | // 过滤仓库管理员的显示 |
| | | roleList.removeIf(role -> "仓库管理员".equals(role.getRole_name())); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("list", roleList); |
| | | map.put("data", finSysTenantUser); |
| | |
| | | // 查询父类的orgcode 需要将自己的org先查出来 再根据parentid 查父类 |
| | | String tenantId = sysInfo.getTenantId(); |
| | | if (StringUtils.isNotEmpty(tenantId)) { |
| | | List<FinSysTenant> select = finSysTenantService.select(new FinSysTenant(Long.valueOf(tenantId))); |
| | | if (select != null && select.size() > 0) { |
| | | FinSysTenant finSysTenant = select.get(0); |
| | | if (finSysTenant != null && finSysTenant.getParentId() != null) { |
| | | List<FinSysTenant> parents = |
| | | finSysTenantService.select(new FinSysTenant(finSysTenant.getParentId())); |
| | | if (parents != null && parents.size() > 0) { |
| | | sysInfo.setParentCode(parents.get(0).getCode()); |
| | | } |
| | | FinSysTenant finSysTenant = finSysTenantService.get(new FinSysTenant(Long.valueOf(tenantId))); |
| | | if (finSysTenant != null && finSysTenant.getParentId() != null) { |
| | | FinSysTenant parentTenant = finSysTenantService.get(new FinSysTenant(finSysTenant.getParentId())); |
| | | if (ObjectUtils.isNotEmpty(parentTenant)) { |
| | | sysInfo.setParentCode(parentTenant.getCode()); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | return ResponseValue.success(sysInfo); |
| | |
| | | // 选择的权限 |
| | | List<Long> roleList = user.getRoleList(); |
| | | // 先删除再添加 |
| | | if (list != null && list.size() > 0) { |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | Long sysUserId = user.getSysUserId(); |
| | | finSysTenantUserService.execDelRoleUserList(sysUserId); |
| | | // 删除库管员信息记录 |
| | | list.stream().filter(item -> "仓库管理员".equals(item.getRole_name())).findFirst() |
| | | .ifPresent(item -> baseWarehouseManagerService.deleteMangerBySysUserId(sysUserId)); |
| | | } |
| | | if (roleList != null && roleList.size() > 0) { |
| | | if (!CollectionUtils.isEmpty(roleList)) { |
| | | finSysTenantUserService.execInsertRoleUserList(roleList, user.getSysUserId()); |
| | | } |
| | | return ResponseValue.success(1); |
| | |
| | | } |
| | | // 获取运维管理 |
| | | List<S_dept> depts = this.finSysTenantUserService.selectDept(roleName); |
| | | if (depts == null || depts.size() == 0) { |
| | | if (CollectionUtils.isEmpty(depts)) { |
| | | return ResponseValue.error(roleName + "的角色不存在"); |
| | | } |
| | | // 根据员工编号查询,如果存在则提示 |
| | |
| | | return ResponseValue.success(1); |
| | | } |
| | | |
| | | private Set<String> picFormatArr = new HashSet<String>() { |
| | | private final Set<String> picFormatArr = new HashSet<String>() { |
| | | { |
| | | add(".pjp"); |
| | | add(".svgz"); |
| | |
| | | // 部门 |
| | | FinSysTenantDepartment finSysTenantDepartment = new FinSysTenantDepartment(); |
| | | finSysTenantDepartment.setTenantId(agencyId); |
| | | finSysTenantDepartment.setStatus(StatesType.NORMAL.getValue()); |
| | | finSysTenantDepartment.setIsDelete(0); |
| | | List<FinSysTenantDepartment> tenantDepartmentList = |
| | | finSysTenantDepartmentService.select(finSysTenantDepartment); |
| | | List<DepartmentVO> departmentVOList = Lists.newArrayList(); |
| | |
| | | departmentVO.setName(department.getName()); |
| | | departmentVO.setType("department"); |
| | | |
| | | String sql = "SELECT SYS_USER_ID,USER_NAME FROM " + "fin_sys_tenant_user " |
| | | + "WHERE SYS_DEPT_ID =:deptId AND SYS_USER_ID NOT IN(SELECT MANAGER_ID FROM base_warehouse_manager)"; |
| | | String sql = "SELECT SYS_USER_ID,USER_NAME FROM fin_sys_tenant_user " |
| | | + "WHERE STATUS =1 and SYS_DEPT_ID =:deptId AND SYS_USER_ID NOT IN(SELECT MANAGER_ID FROM base_warehouse_manager)"; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("deptId", id); |
| | | List<Map<String, Object>> select = finSysTenantUserService.select(sql, param, new MapperUtil()); |
| | |
| | | return ResponseValue.success(finSysTenantVO); |
| | | } |
| | | |
| | | @GetMapping("/query/role") |
| | | public ResponseValue pageList() { |
| | | RolePageParam roleParam = CommonUtil.getObjFromReq(RolePageParam.class); |
| | | RolePageParam param2 = new RolePageParam(); |
| | | CommonUtil.copyProperties(roleParam, param2); |
| | | roleParam = param2; |
| | | if (roleParam != null && roleParam.getOrgId() > 0L) { |
| | | long orgId = 0L; |
| | | if (!this.isSupervisor()) { |
| | | orgId = this.getCurrentUser().getOrg_id(); |
| | | } else { |
| | | orgId = roleParam.getOrgId(); |
| | | } |
| | | |
| | | FinSysTenantUser finSysTenantUser = this.getSysInfo(); |
| | | Integer dataScope = finSysTenantUser.getLv(); |
| | | GenericPager<S_role> pager = finSysTenantUserService.queryPageRoleList(orgId, roleParam.getStatus(), |
| | | roleParam.getRoleName(), dataScope,roleParam.getPageNum(), roleParam.getPageSize()); |
| | | return ResponseValue.success(pager); |
| | | } else { |
| | | return ResponseValue.error("参数不能为空"); |
| | | } |
| | | } |
| | | } |