longz
2026-06-29 9d4cbff7464ebfd7803c2ce53ded49d0f73fe011
backend/src/main/java/com/sinata/appointment/service/StaffManageApplicationService.java
@@ -132,7 +132,7 @@
        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 ->
@@ -166,9 +166,12 @@
            }
            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) {
@@ -364,7 +367,7 @@
        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());
@@ -399,7 +402,7 @@
        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);
    }
@@ -610,14 +613,14 @@
        }
        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;
@@ -633,7 +636,7 @@
        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));
        }
@@ -672,7 +675,7 @@
            }
            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");
@@ -782,9 +785,6 @@
            return false;
        }
        String t = position.trim();
        if ("部门负责人".equals(t) || "LEADER".equalsIgnoreCase(t)) {
            return true;
        }
        if ("员工".equals(t) || "STAFF".equalsIgnoreCase(t)) {
            return false;
        }
@@ -800,7 +800,7 @@
        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);
    }
@@ -878,7 +878,7 @@
        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());
@@ -889,7 +889,9 @@
        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());
@@ -905,7 +907,7 @@
        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;