| | |
| | | return queueMapper.selectPage(pageReqVO); |
| | | } |
| | | |
| | | /** |
| | | * 系统重启时,从DB同步队列数据到 工位优先队列 |
| | | */ |
| | | public void initQueue() { |
| | | priorityQueue.clear(); |
| | | mapBedVsQueue.clear(); |
| | |
| | | bedQueueBOList.forEach(item -> { |
| | | item.maxQueueNum = MAX_QUEUE_NUM; |
| | | Optional<QueueStatisticDO> queueStatisticDOOptional = queueStatisticDOList.stream().filter(it->it.getRoomId()==item.roomId && it.getBedNo().equals(item.getBedNo())).findFirst(); |
| | | item.queueNum.set( queueStatisticDOOptional.isPresent() ? queueStatisticDOOptional.get().getTotalInStatus() : 0 ); |
| | | int queueNum = queueStatisticDOOptional.isPresent() ? queueStatisticDOOptional.get().getTotalInStatus() : 0; |
| | | if ( MAX_QUEUE_NUM < queueNum ) |
| | | throw new RuntimeException("init: exceed max queue number!"); |
| | | |
| | | item.queueNum.set( queueNum ); |
| | | priorityQueue.offer(item); |
| | | mapBedVsQueue.put(String.format("%09d%s", item.roomId, item.bedNo), item); |
| | | }); |
| | |
| | | curSeqNum = new AtomicInteger(null == num ? 0 : num); |
| | | } |
| | | |
| | | /** |
| | | * 这个逻辑 不需要了 |
| | | */ |
| | | public void reorderQueue() { |
| | | // 根据预约前后,从DB 获取 队列中 就诊准备中人员 列表 |
| | | List<Byte> queueStatusList = new ArrayList<>(); |
| | |
| | | |
| | | int curQueueNum = bedQueueBO.queueNum.get(); |
| | | if (curQueueNum > bedQueueBO.maxQueueNum) |
| | | throw new RuntimeException("exceed max queue number!"); |
| | | throw new RuntimeException("hurryup: exceed max queue number!"); |
| | | |
| | | if (curQueueNum == bedQueueBO.maxQueueNum) |
| | | return; |
| | |
| | | QueueDO queue = BeanUtils.toBean(queueSaveReqVO, QueueDO.class); |
| | | queueMapper.insert(queue); |
| | | |
| | | singleThreadExecutor.submit( () -> { |
| | | singleThreadExecutor.execute( () -> { |
| | | hurryup(); |
| | | }); |
| | | } |
| | | |
| | | private void nextPatient(Long roomId, String bedNo) { |
| | | // 从 DB 把 序号最小的 就诊准备中的人 设置为就诊中 |
| | | queueMapper.updateQueueStatus(roomId, bedNo, |
| | | Integer updateNum = queueMapper.updateQueueStatus(roomId, bedNo, |
| | | QueueStatusEnum.READY.getStatus(), QueueStatusEnum.ONSTAGE.getStatus()); |
| | | |
| | | // 该工位 没有 就诊准备中 人员 |
| | | if (null == updateNum || 0 == updateNum) { |
| | | return; |
| | | } |
| | | |
| | | // 优先队列中 该工位 就诊准备中人的数量 减一 |
| | | BedQueueBO bo = mapBedVsQueue.get(String.format("%09d%s", roomId, bedNo)); |
| | |
| | | priorityQueue.remove(bo); |
| | | priorityQueue.offer(bo); |
| | | |
| | | singleThreadExecutor.submit( () -> { |
| | | singleThreadExecutor.execute( () -> { |
| | | hurryup(); |
| | | }); |
| | | } |