| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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); |
| | |
| | | } |
| | | if (ApprovalTaskStatus.REJECTED.equals(currentUserTask.getTaskStatus())) { |
| | | vo.setApprovalStatusText("已拒绝"); |
| | | return; |
| | | } |
| | | if (ApprovalTaskStatus.CANCELLED.equals(currentUserTask.getTaskStatus())) { |
| | | vo.setApprovalStatusText("已取消"); |
| | | return; |
| | | } |
| | | vo.setApprovalStatusText("待审批"); |
| | |
| | | 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()); |
| | |
| | | } |
| | | } |
| | | |
| | | 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(); |