longz
2026-05-14 11029948d45564975527b2c21e9c2def1903164a
backend/src/main/java/com/sinata/appointment/service/MiniApprovalDetailApplicationService.java
@@ -12,6 +12,7 @@
import com.sinata.appointment.dto.MiniApprovalDetailVisitorVo;
import com.sinata.appointment.dto.MiniApprovalDetailVo;
import com.sinata.appointment.dto.MiniLocalUnitVo;
import com.sinata.appointment.dto.MiniVisitedUserVo;
import com.sinata.appointment.entity.AppointmentOrder;
import com.sinata.appointment.entity.AppointmentVehicle;
import com.sinata.appointment.entity.AppointmentVisitor;
@@ -20,6 +21,7 @@
import com.sinata.appointment.entity.BizVisitReason;
import com.sinata.appointment.entity.MpPassLocalUnit;
import com.sinata.appointment.entity.MpVisitor;
import com.sinata.appointment.entity.MpUser;
import com.sinata.appointment.entity.SysDept;
import com.sinata.appointment.exception.BizException;
import com.sinata.appointment.mapper.AppointmentOrderMapper;
@@ -30,6 +32,7 @@
import com.sinata.appointment.mapper.BizVisitReasonMapper;
import com.sinata.appointment.mapper.MpPassLocalUnitMapper;
import com.sinata.appointment.mapper.MpVisitorMapper;
import com.sinata.appointment.mapper.MpUserMapper;
import com.sinata.appointment.mapper.SysDeptMapper;
import com.sinata.appointment.util.MobileMaskUtil;
import com.sinata.appointment.util.SensitiveDataUtil;
@@ -63,6 +66,7 @@
    private final AppointmentVisitorMapper appointmentVisitorMapper;
    private final AppointmentVehicleMapper appointmentVehicleMapper;
    private final MpVisitorMapper mpVisitorMapper;
    private final MpUserMapper mpUserMapper;
    private final SysDeptMapper sysDeptMapper;
    private final BizVisitReasonMapper bizVisitReasonMapper;
    private final MpPassLocalUnitMapper mpPassLocalUnitMapper;
@@ -94,6 +98,9 @@
        vo.setOrderId(order.getId());
        vo.setOrderUuid(order.getUuid());
        vo.setOrderNo(order.getOrderNo());
        MpUser submitter = loadSubmitter(order.getSubmitterId());
        vo.setSubmitterName(resolveSubmitterName(submitter, order.getSubmitterId()));
        vo.setSubmitTime(order.getCreateTime());
        vo.setTaskStatus(currentUserTask == null ? null : currentUserTask.getTaskStatus());
        vo.setNodeCode(currentUserTask == null ? null : currentUserTask.getNodeCode());
        vo.setNodeName(resolveNodeName(currentUserTask == null ? null : currentUserTask.getNodeCode()));
@@ -110,6 +117,7 @@
        vo.setPassAccessAreaNames(parseStringList(order.getPassAccessAreaNames()));
        vo.setInvolveOtherLocalUnit(Boolean.TRUE.equals(order.getInvolveOtherLocalUnit()));
        vo.setLocalUnits(loadLocalUnits(parseLongList(order.getPassLocalUnitIds())));
        vo.setNoticeUsers(loadNoticeUsers(parseCommaSeparatedIds(currentUserTask == null ? null : currentUserTask.getNoticeIds())));
        vo.setVisitors(loadVisitors(order.getId()));
        List<ApprovalFlowNodeVo> flowTree = approvalFlowViewApplicationService.treeByOrderId(order.getId());
        vo.setFlowTree(flowTree == null ? List.of() : flowTree);
@@ -146,6 +154,10 @@
        }
        if (ApprovalTaskStatus.REJECTED.equals(currentUserTask.getTaskStatus())) {
            vo.setApprovalStatusText("已拒绝");
            return;
        }
        if (ApprovalTaskStatus.CANCELLED.equals(currentUserTask.getTaskStatus())) {
            vo.setApprovalStatusText("已取消");
            return;
        }
        vo.setApprovalStatusText("待审批");
@@ -232,11 +244,10 @@
            vo.setGender(visitor == null ? null : visitor.getGender());
            vo.setCompanyName(visitor == null ? null : visitor.getVisitorCompany());
            vo.setMobileMasked(
                    MobileMaskUtil.mask(
                            firstNonBlank(
                                    row.getMobile(),
                                    visitor == null ? null : visitor.getVisitorMobile(),
                                    null)));
                    firstNonBlank(
                            row.getMobile(),
                            visitor == null ? null : visitor.getVisitorMobile(),
                            null));
            String idCardPlain =
                    StringUtils.hasText(row.getIdCardCipher())
                            ? SensitiveDataUtil.decryptIdCard(row.getIdCardCipher())
@@ -318,6 +329,47 @@
        return result;
    }
    private List<MiniVisitedUserVo> loadNoticeUsers(List<Long> noticeIds) {
        if (noticeIds.isEmpty()) {
            return List.of();
        }
        List<MpUser> users =
                mpUserMapper.selectList(
                        new LambdaQueryWrapper<MpUser>()
                                .eq(MpUser::getDelFlag, 0)
                                .in(MpUser::getId, noticeIds));
        if (users.isEmpty()) {
            return List.of();
        }
        Map<Long, MpUser> userMap =
                users.stream().collect(Collectors.toMap(MpUser::getId, x -> x, (a, b) -> a, LinkedHashMap::new));
        List<Long> deptIds =
                users.stream().map(MpUser::getDeptId).filter(id -> id != null && id > 0).distinct().toList();
        Map<Long, String> deptNameMap = new LinkedHashMap<>();
        if (!deptIds.isEmpty()) {
            deptNameMap =
                    sysDeptMapper.selectList(
                                    new LambdaQueryWrapper<SysDept>()
                                            .eq(SysDept::getDelFlag, 0)
                                            .in(SysDept::getId, deptIds))
                            .stream()
                            .collect(Collectors.toMap(SysDept::getId, SysDept::getDeptName, (a, b) -> a, LinkedHashMap::new));
        }
        List<MiniVisitedUserVo> result = new ArrayList<>();
        for (Long noticeId : noticeIds) {
            MpUser user = userMap.get(noticeId);
            if (user == null) {
                continue;
            }
            MiniVisitedUserVo vo = new MiniVisitedUserVo();
            vo.setId(user.getId());
            vo.setRealName(trimToNull(user.getNickName()));
            vo.setDeptName(user.getDeptId() == null ? null : deptNameMap.get(user.getDeptId()));
            result.add(vo);
        }
        return result;
    }
    private String buildVisitTypeText(AppointmentOrder order) {
        boolean personEntry = order.getPersonEntryFlag() == null || Boolean.TRUE.equals(order.getPersonEntryFlag());
        boolean vehicleEntry = Boolean.TRUE.equals(order.getVehicleEntryFlag());
@@ -334,7 +386,7 @@
        String code = trimToNull(order.getVisitReasonCode());
        if (AppointmentBizConstants.VISIT_REASON_OTHER.equalsIgnoreCase(code)) {
            String other = trimToNull(order.getVisitReasonOther());
            return StringUtils.hasText(other) ? "其他-" + other : "其他";
            return StringUtils.hasText(other) ? "其他:" + other : "其他";
        }
        if (!StringUtils.hasText(code)) {
            return "-";
@@ -354,9 +406,9 @@
        if (AppointmentBizConstants.TIME_MODE_SINGLE.equals(order.getVisitTimeMode())) {
            String slotLabel =
                    switch (trimToNull(order.getVisitTimeSlot())) {
                        case AppointmentBizConstants.TIME_SLOT_ALL_DAY -> "全天";
                        case AppointmentBizConstants.TIME_SLOT_AM -> "上午";
                        case AppointmentBizConstants.TIME_SLOT_PM -> "下午";
                        case AppointmentBizConstants.TIME_SLOT_ALL_DAY -> "00:00-23:59";
                        case AppointmentBizConstants.TIME_SLOT_AM -> "00:00-11:59";
                        case AppointmentBizConstants.TIME_SLOT_PM -> "12:00-23:59";
                        default -> "";
                    };
            if (order.getVisitStartDate() == null) {
@@ -397,6 +449,33 @@
        };
    }
    private MpUser loadSubmitter(Long submitterId) {
        if (submitterId == null) {
            return null;
        }
        List<MpUser> users =
                mpUserMapper.selectList(
                        new LambdaQueryWrapper<MpUser>()
                                .eq(MpUser::getDelFlag, 0)
                                .eq(MpUser::getId, submitterId)
                                .last("limit 1"));
        return users.isEmpty() ? null : users.get(0);
    }
    private String resolveSubmitterName(MpUser submitter, Long submitterId) {
        if (submitter != null) {
            String name = trimToNull(submitter.getNickName());
            if (StringUtils.hasText(name)) {
                return name;
            }
            String mobile = trimToNull(submitter.getMobile());
            if (StringUtils.hasText(mobile)) {
                return mobile;
            }
        }
        return submitterId == null ? "发起人" : "用户" + submitterId;
    }
    private List<Long> parseLongList(String json) {
        if (!StringUtils.hasText(json)) {
            return List.of();
@@ -415,6 +494,27 @@
        }
    }
    private List<Long> parseCommaSeparatedIds(String raw) {
        if (!StringUtils.hasText(raw)) {
            return List.of();
        }
        Set<Long> result = new LinkedHashSet<>();
        String[] parts = raw.split(",");
        for (String part : parts) {
            if (!StringUtils.hasText(part)) {
                continue;
            }
            try {
                long id = Long.parseLong(part.trim());
                if (id > 0) {
                    result.add(id);
                }
            } catch (NumberFormatException ignored) {
            }
        }
        return new ArrayList<>(result);
    }
    private List<String> parseStringList(String json) {
        if (!StringUtils.hasText(json)) {
            return List.of();