| | |
| | | q.like(StringUtils.hasText(staffNo), MpUser::getStaffNo, staffNo != null ? staffNo.trim() : null); |
| | | q.like(StringUtils.hasText(mobile), MpUser::getMobile, mobile != null ? mobile.trim() : null); |
| | | if ("LEADER".equalsIgnoreCase(position)) { |
| | | q.eq(MpUser::getDeptLeaderFlag, true); |
| | | q.apply("1 = 0"); |
| | | } else if ("STAFF".equalsIgnoreCase(position)) { |
| | | q.and( |
| | | w -> |
| | |
| | | } |
| | | userIds.add(u.getId()); |
| | | } |
| | | List<SysDept> allDepts = sysDeptMapper.selectList( |
| | | new LambdaQueryWrapper<SysDept>().eq(SysDept::getDelFlag, 0)); |
| | | Map<Long, String> deptPaths = buildDeptPathById(allDepts); |
| | | Map<Long, String> deptNames = deptNamesByIds(deptIds); |
| | | Map<Long, String> groupDisplay = groupDisplayByMpUserIds(userIds); |
| | | return p.convert(u -> toListVo(u, deptNames, groupDisplay.getOrDefault(u.getId(), "—"))); |
| | | return p.convert(u -> toListVo(u, deptNames, deptPaths, groupDisplay.getOrDefault(u.getId(), "—"))); |
| | | } |
| | | |
| | | private Set<Long> mpUserIdsInStaffGroup(Long staffGroupId) { |
| | |
| | | u.setMobile(mobileRaw); |
| | | u.setAvatarUrl(trimToNull(req.getAvatarUrl())); |
| | | u.setDeptId(req.getDeptId()); |
| | | u.setDeptLeaderFlag(Boolean.TRUE.equals(req.getDeptLeader())); |
| | | u.setDeptLeaderFlag(false); |
| | | u.setStatus(1); |
| | | mpUserMapper.insert(u); |
| | | MpUser fresh = mpUserMapper.selectById(u.getId()); |
| | |
| | | u.setAvatarUrl(trimToNull(req.getAvatarUrl())); |
| | | u.setMobile(mobileRaw); |
| | | u.setDeptId(req.getDeptId()); |
| | | u.setDeptLeaderFlag(Boolean.TRUE.equals(req.getDeptLeader())); |
| | | u.setDeptLeaderFlag(false); |
| | | mpUserMapper.updateById(u); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | Long deptId = parseDeptId(dept, deptPathToId, deptNameToIds); |
| | | boolean leader = parseDeptLeader(position); |
| | | parseDeptLeader(position); |
| | | |
| | | StaffCreateRequest req = new StaffCreateRequest(); |
| | | req.setNickName(name); |
| | | req.setStaffNo(StringUtils.hasText(staffNo) ? staffNo : null); |
| | | req.setMobile(mobile); |
| | | req.setDeptId(deptId); |
| | | req.setDeptLeader(leader); |
| | | req.setDeptLeader(false); |
| | | Map<String, Object> created = create(req); |
| | | Object idObj = created.get("id"); |
| | | Long uid = idObj instanceof Number ? ((Number) idObj).longValue() : null; |
| | |
| | | List<List<String>> rows = new ArrayList<>(); |
| | | for (int i = 0; i < max; i++) { |
| | | String dept = i < deptPaths.size() ? deptPaths.get(i) : ""; |
| | | String pos = i == 0 ? "部门负责人" : (i == 1 ? "员工" : ""); |
| | | String pos = i == 0 ? "员工" : ""; |
| | | String grp = i < groupNames.size() ? groupNames.get(i) : ""; |
| | | rows.add(java.util.Arrays.asList(dept, pos, grp)); |
| | | } |
| | |
| | | } |
| | | Name posRange = wb.createName(); |
| | | posRange.setNameName("pos_list"); |
| | | posRange.setRefersToFormula("字典!$B$1:$B$2"); |
| | | posRange.setRefersToFormula("字典!$B$1:$B$1"); |
| | | if (!groupNames.isEmpty()) { |
| | | Name groupRange = wb.createName(); |
| | | groupRange.setNameName("group_list"); |
| | |
| | | return false; |
| | | } |
| | | String t = position.trim(); |
| | | if ("部门负责人".equals(t) || "LEADER".equalsIgnoreCase(t)) { |
| | | return true; |
| | | } |
| | | if ("员工".equals(t) || "STAFF".equalsIgnoreCase(t)) { |
| | | return false; |
| | | } |
| | |
| | | exist.setAvatarUrl(trimToNull(req.getAvatarUrl())); |
| | | exist.setMobile(mobileRaw); |
| | | exist.setDeptId(req.getDeptId()); |
| | | exist.setDeptLeaderFlag(Boolean.TRUE.equals(req.getDeptLeader())); |
| | | exist.setDeptLeaderFlag(false); |
| | | exist.setStatus(1); |
| | | mpUserMapper.updateById(exist); |
| | | } |
| | |
| | | return m; |
| | | } |
| | | |
| | | private StaffListVo toListVo(MpUser u, Map<Long, String> deptNames, String groupDisplay) { |
| | | private StaffListVo toListVo(MpUser u, Map<Long, String> deptNames, Map<Long, String> deptPaths, String groupDisplay) { |
| | | StaffListVo vo = new StaffListVo(); |
| | | vo.setId(u.getId()); |
| | | vo.setUuid(u.getUuid()); |
| | |
| | | vo.setDeptId(u.getDeptId()); |
| | | vo.setDeptName( |
| | | u.getDeptId() == null ? "—" : deptNames.getOrDefault(u.getDeptId(), "—")); |
| | | vo.setPositionLabel(Boolean.TRUE.equals(u.getDeptLeaderFlag()) ? "部门负责人" : "员工"); |
| | | vo.setDeptPath( |
| | | u.getDeptId() == null ? "—" : deptPaths.getOrDefault(u.getDeptId(), "—")); |
| | | vo.setPositionLabel("员工"); |
| | | vo.setGroupDisplay(groupDisplay); |
| | | vo.setStatus(u.getStatus() == null ? 1 : u.getStatus()); |
| | | vo.setCreateTime(u.getCreateTime()); |
| | |
| | | vo.setAvatarUrl(u.getAvatarUrl()); |
| | | vo.setMobile(u.getMobile()); |
| | | vo.setDeptId(u.getDeptId()); |
| | | vo.setDeptLeader(Boolean.TRUE.equals(u.getDeptLeaderFlag())); |
| | | vo.setDeptLeader(false); |
| | | vo.setStatus(u.getStatus() == null ? 1 : u.getStatus()); |
| | | vo.setGroupNames(loadGroupNamesForUser(u.getId())); |
| | | return vo; |