| | |
| | | |
| | | Map<Integer, Integer> mapCheckTypeVsDisplayColumn = null; |
| | | |
| | | Map<Integer, List<QueueDO>> mapDisplaySlotVsCallingData = new HashMap<>(); |
| | | |
| | | Integer waitingFrom = 0; |
| | | Integer passedFrom = 0; |
| | | |
| | |
| | | this.bigScreenConfig = bigScreenConfig; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<Integer, List<QueueDO>> callingData() { |
| | | if (null == mapCheckTypeVsDisplayColumn) { |
| | | getDisplayColumnConfig(); |
| | | } else { |
| | | mapDisplaySlotVsCallingData.values().stream().forEach(slotQueueList -> slotQueueList.clear()); |
| | | public Map<Integer, List<String>> getDisplayColInfo() { |
| | | CheckTypePageReqVO checkTypePageReqVO = new CheckTypePageReqVO(); |
| | | checkTypePageReqVO.setPageSize(-1); |
| | | checkTypePageReqVO.setCallingColumn(-1); // 列号 -1 的不显示 |
| | | PageResult<CheckTypeDO> pageResult = checkTypeMapper.selectPageForCallingScreen(checkTypePageReqVO); |
| | | |
| | | // 显示列 包含的检查类型列表 |
| | | Map<Integer, List<CheckTypeDO>> mapDisplayColName = pageResult.getList().stream().collect(Collectors.groupingBy(CheckTypeDO::getCallingColumn)); |
| | | |
| | | // 检查类型 对应的显示列 |
| | | mapCheckTypeVsDisplayColumn = pageResult.getList().stream().collect(Collectors.toMap(CheckTypeDO::getValue, item -> item.getCallingColumn())); |
| | | |
| | | // 显示列 对应的检查类型名列表 |
| | | Map<Integer, List<String>> _map = new HashMap<>(); |
| | | mapDisplayColName.keySet().forEach(key -> { |
| | | _map.put(key, mapDisplayColName.get(key).stream().map(item->item.getName()+item.getSeqPrefix()).toList()); |
| | | }); |
| | | return _map; |
| | | } |
| | | |
| | | /** |
| | | * 大屏显示的患者信息 |
| | | * 不会有安装相关的患者信息 |
| | | */ |
| | | @Override |
| | | public Map<Integer, List<QueueDO>> getBigScreenPatient() { |
| | | Map<Integer, List<QueueDO>> mapDisplayColQueue = new HashMap<>(); |
| | | int displayColCnt = (int) mapCheckTypeVsDisplayColumn.values().stream().distinct().count(); |
| | | for (int dispCol=0; dispCol<displayColCnt; dispCol++) { |
| | | List<QueueDO> columnQueueData = new ArrayList<>(); |
| | | mapDisplayColQueue.put(dispCol, columnQueueData); |
| | | } |
| | | |
| | | mapDisplayColQueue.values().forEach(List::clear); |
| | | |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.READY.getStatus()); |
| | |
| | | queueStatusList.add(QueueStatusEnum.WAITING.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.RECALLED.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.PASSED.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.PASSED_WAITING.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.AFFINITY.getStatus()); |
| | | List<QueueDO> queueDOList = queueMapper.getQueueByStatus( queueStatusList ); |
| | | queueDOList.stream().forEach(queueDO -> { |
| | | List<QueueDO> listSolt = getDisplatSlotByQueue( queueDO.getBookCheckType(), queueDO.getStatus()); |
| | | listSolt.add( queueDO ); |
| | | queueDOList.forEach(queueDO -> { |
| | | List<QueueDO> columnQueueData = mapDisplayColQueue.get(mapCheckTypeVsDisplayColumn.get(queueDO.getBookCheckType())); |
| | | columnQueueData.add( queueDO ); |
| | | }); |
| | | |
| | | mapDisplaySlotVsCallingData.values().stream().forEach(slotQueueList -> slotQueueList.sort(null)); |
| | | return mapDisplaySlotVsCallingData; |
| | | mapDisplayColQueue.values().forEach( _queueDOList -> { |
| | | //把 [亲和的] 挪到主项后面 |
| | | List<QueueDO> affinityWaitingList = new ArrayList<>(); |
| | | ListIterator<QueueDO> iterator = _queueDOList.listIterator(); |
| | | while (iterator.hasNext()) { |
| | | QueueDO item = iterator.next(); |
| | | if (item.getStatus() == QueueStatusEnum.AFFINITY.getStatus()) { |
| | | iterator.remove(); |
| | | affinityWaitingList.add(item); |
| | | } |
| | | } |
| | | affinityWaitingList.forEach( affinityWaitingItem -> { |
| | | for (int i = _queueDOList.size()-1; i >= 0; i--) { |
| | | if ( affinityWaitingItem.getSeqNum() == _queueDOList.get(i).getSeqNum() ) { |
| | | _queueDOList.add(i + 1, affinityWaitingItem); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | return mapDisplayColQueue; |
| | | } |
| | | |
| | | @Override |
| | | public Map<Integer, List<QueueDO>> callingData2() { |
| | | public List<QueueDO> getRoomCheckRelatedPatient(String ip, Long roomId) { |
| | | if (null == roomId) { |
| | | List<RoomDO> roomDOList = roomMapper.queueByIp(ip); |
| | | Optional<RoomDO> optionalQueueDO = roomDOList.stream().filter(item -> StringUtils.hasLength(item.getIp())).findFirst(); |
| | | if (!optionalQueueDO.isPresent()) { |
| | | return new ArrayList<QueueDO>(); |
| | | } |
| | | roomId = optionalQueueDO.get().getRoomId(); |
| | | } |
| | | |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.RECALLED.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.READY.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | List<QueueDO> listReady = queueMapper.getQueueByStatus( queueStatusList ); |
| | | |
| | | queueStatusList.clear(); |
| | | queueStatusList.add(QueueStatusEnum.WAITING.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.RECALLED.getStatus()); |
| | | List<QueueDO> listWaiting = queueMapper.getPartialQueueByStatus( queueStatusList, waitingFrom, bigScreenConfig.waitingSize ); |
| | | if (listWaiting.size() < bigScreenConfig.waitingSize && waitingFrom != 0) { |
| | | List<QueueDO> listWaiting_next = queueMapper.getPartialQueueByStatus( queueStatusList, 0, bigScreenConfig.waitingSize - listWaiting.size()); |
| | | listWaiting.addAll(listWaiting_next); |
| | | } |
| | | if (listWaiting.size() < bigScreenConfig.waitingSize) { |
| | | waitingFrom = 0; |
| | | } else { |
| | | waitingFrom = listWaiting.getLast().getId() + 1; |
| | | } |
| | | |
| | | queueStatusList.clear(); |
| | | queueStatusList.add(QueueStatusEnum.PASSED.getStatus()); |
| | | List<QueueDO> listPassed = queueMapper.getPartialQueueByStatus( queueStatusList, passedFrom, bigScreenConfig.passedSize ); |
| | | if (listPassed.size() < bigScreenConfig.passedSize && passedFrom != 0) { |
| | | List<QueueDO> listPassed_next = queueMapper.getPartialQueueByStatus( queueStatusList, 0, bigScreenConfig.passedSize - listPassed.size()); |
| | | listPassed.addAll(listPassed_next); |
| | | queueStatusList.add(QueueStatusEnum.AFFINITY.getStatus()); |
| | | List<QueueDO> queueDOList = queueMapper.getRoomQueueByStatus(roomId, queueStatusList); |
| | | |
| | | //把 [亲和的] 挪到主项后面 |
| | | List<QueueDO> affinityWaitingList = new ArrayList<>(); |
| | | ListIterator<QueueDO> iterator = queueDOList.listIterator(); |
| | | while (iterator.hasNext()) { |
| | | QueueDO item = iterator.next(); |
| | | if (item.getStatus() == QueueStatusEnum.AFFINITY.getStatus()) { |
| | | iterator.remove(); |
| | | affinityWaitingList.add(item); |
| | | } |
| | | } |
| | | if (listPassed.size() < bigScreenConfig.passedSize) { |
| | | passedFrom = 0; |
| | | } else { |
| | | passedFrom = listPassed.getLast().getId(); |
| | | } |
| | | affinityWaitingList.forEach( affinityWaitingItem -> { |
| | | for (int i = queueDOList.size()-1; i >= 0; i--) { |
| | | if ( affinityWaitingItem.getSeqNum() == queueDOList.get(i).getSeqNum() ) { |
| | | queueDOList.add(i + 1, affinityWaitingItem); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | log.info( " waitingFrom: {} passedFrom: {} ", waitingFrom, passedFrom); |
| | | |
| | | Map<Integer, List<QueueDO>> map = new HashMap<>(); |
| | | map.put(1, listReady); |
| | | map.put(2, listWaiting); |
| | | map.put(3, listPassed); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<QueueDO> getRoomQueue(String ip, List<Integer> statusList) { |
| | | List<RoomDO> roomDOList = roomMapper.queueByIp(ip); |
| | | Optional<RoomDO> optionalQueueDO = roomDOList.stream().filter(item -> StringUtils.hasLength(item.getIp())).findFirst(); |
| | | if (!optionalQueueDO.isPresent()) { |
| | | return new ArrayList<QueueDO>(); |
| | | } |
| | | |
| | | Long roomId = optionalQueueDO.get().getRoomId(); |
| | | List<QueueDO> queueDOList = queueMapper.getRoomQueueByStatus(roomId, statusList); |
| | | return queueDOList; |
| | | } |
| | | |
| | | private void getDisplayColumnConfig() { |
| | | CheckTypePageReqVO checkTypePageReqVO = new CheckTypePageReqVO(); |
| | | checkTypePageReqVO.setPageSize(-1); |
| | | PageResult<CheckTypeDO> pageResult = checkTypeMapper.selectPage(checkTypePageReqVO); |
| | | mapCheckTypeVsDisplayColumn = pageResult.getList().stream().collect(Collectors.toMap(CheckTypeDO::getValue, item -> item.getCallingColumn())); |
| | | @Override |
| | | public List<QueueDO> getRoomInstallRelatedPatient(String ip, Long roomId) { |
| | | if (null == roomId) { |
| | | List<RoomDO> roomDOList = roomMapper.queueByIp(ip); |
| | | Optional<RoomDO> optionalQueueDO = roomDOList.stream().filter(item -> StringUtils.hasLength(item.getIp())).findFirst(); |
| | | if (!optionalQueueDO.isPresent()) { |
| | | return new ArrayList<QueueDO>(); |
| | | } |
| | | |
| | | int displayColCnt = (int) mapCheckTypeVsDisplayColumn.values().stream().distinct().count(); |
| | | for (int i=0; i<displayColCnt; i++) { |
| | | mapDisplaySlotVsCallingData.put(i*1000 + 0, new ArrayList<>()); |
| | | mapDisplaySlotVsCallingData.put(i*1000 + 1, new ArrayList<>()); |
| | | mapDisplaySlotVsCallingData.put(i*1000 + 2, new ArrayList<>()); |
| | | roomId = optionalQueueDO.get().getRoomId(); |
| | | } |
| | | } |
| | | |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.RECEIVED.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.PASSED_INSTALL.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.AFFINITY_INSTALL.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.INSTALLING.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.RECALLED_INSTALL.getStatus()); |
| | | List<QueueDO> queueDOList = queueMapper.getRoomQueueByStatus(roomId, queueStatusList); |
| | | |
| | | private List<QueueDO> getDisplatSlotByQueue( Integer checkType, Integer queueStatus ) { |
| | | return mapDisplaySlotVsCallingData.get(mapCheckTypeVsDisplayColumn.get(checkType)*1000 + getDisplatSlotByQueueStatus(queueStatus)); |
| | | } |
| | | //把 [亲和的] 挪到主项后面 |
| | | List<QueueDO> affinityReceivedList = new ArrayList<>(); |
| | | ListIterator<QueueDO> iterator = queueDOList.listIterator(); |
| | | while (iterator.hasNext()) { |
| | | QueueDO item = iterator.next(); |
| | | if (item.getStatus() == QueueStatusEnum.AFFINITY_INSTALL.getStatus()) { |
| | | iterator.remove(); |
| | | affinityReceivedList.add(item); |
| | | } |
| | | } |
| | | affinityReceivedList.forEach( affinityReceivedItem -> { |
| | | for (int i = queueDOList.size()-1; i >= 0; i--) { |
| | | if ( affinityReceivedItem.getSeqNum() == queueDOList.get(i).getSeqNum() ) { |
| | | queueDOList.add(i + 1, affinityReceivedItem); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | private Integer getDisplatSlotByQueueStatus( Integer queueStatus ) { |
| | | if (QueueStatusEnum.READY.getStatus() == queueStatus) |
| | | return 0; |
| | | else if (QueueStatusEnum.ONSTAGE.getStatus() == queueStatus) |
| | | return 0; |
| | | else if (QueueStatusEnum.WAITING.getStatus() == queueStatus) |
| | | return 1; |
| | | else if (QueueStatusEnum.RECALLED.getStatus() == queueStatus) |
| | | return 1; |
| | | else if (QueueStatusEnum.PASSED.getStatus() == queueStatus) |
| | | return 2; |
| | | else |
| | | return 0; |
| | | return queueDOList; |
| | | } |
| | | |
| | | } |