| | |
| | | queueMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public Integer bedControl(Long roomId, String bedNo, Integer status) { |
| | | // 营业期间不能关闭工位 |
| | | if ( status == 0 && openingFlag.get() == 1 ) |
| | | return 301; |
| | | |
| | | // 当前状态 |
| | | roomMapper.select |
| | | |
| | | // DB update |
| | | Integer updateNum = roomMapper.setBedStatus(roomId, bedNo, status); |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return 310; |
| | | |
| | | if ( status == 10 ) { |
| | | BedQueueBO bedQueueBO = new BedQueueBO(); |
| | | bedQueueBO.setRoomId(roomId); |
| | | bedQueueBO.setBedNo(bedNo); |
| | | bedQueueBO.setMaxQueueNum(MAX_QUEUE_NUM); |
| | | bedQueueBO.setQueueNum(new AtomicInteger(0)); |
| | | priorityQueue.offer(bedQueueBO); |
| | | mapBedVsQueue.put(String.format("%09d%s", bedQueueBO.roomId, bedQueueBO.bedNo), bedQueueBO); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private void validatequeueExists(Integer id) { |
| | | if (queueMapper.selectById(id) == null) { |
| | | throw exception(QUEUE_NOT_EXISTS); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 系统重启时,从DB同步工位的患者队列数据到 工位优先队列 |
| | | * !!开诊期间,不能执行这个方法,否则会有 P0 问题 |
| | | * 1. 每天开诊前 从DB同步工位的患者队列数据到 工位优先队列 |
| | | * 2. 服务运维重启时 |
| | | */ |
| | | public void initQueue() { |
| | | public void initBedQueueAndSeqNumFromDB() { |
| | | priorityQueue.clear(); |
| | | mapBedVsQueue.clear(); |
| | | |
| | |
| | | |
| | | Integer num = queueMapper.getMaxSeqNum(); |
| | | curSeqNum = new AtomicInteger(null == num ? 0 : num); |
| | | } |
| | | |
| | | /** |
| | | * 这个逻辑 不需要了 |
| | | */ |
| | | public void reorderQueue() { |
| | | // 根据预约前后,从DB 获取 队列中 就诊准备中人员 列表 |
| | | List<Byte> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.READY.getStatus()); |
| | | List<QueueDO> queueDOList = queueMapper.getOrderedQueue(queueStatusList); |
| | | if (queueDOList.isEmpty()) |
| | | return; |
| | | |
| | | AtomicInteger seqNum = new AtomicInteger(1); |
| | | queueDOList.forEach(item -> {item.setSeqNum(seqNum.getAndIncrement());}); |
| | | queueMapper.updateBatch(queueDOList); |
| | | |
| | | curSeqNum.set( seqNum.get() ); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | public void startBiz() { |
| | | if (1 == openingFlag.get()) |
| | | return; |
| | | |
| | | // 清除非当天的排队人员 |
| | | queueMapper.clearQueue(); |
| | | |
| | | initBedQueueAndSeqNumFromDB(); |
| | | |
| | | openingFlag.set(1); |
| | | hurryup(); |
| | | } |
| | | |
| | | public void closeBiz() { |
| | | openingFlag.set(0); |
| | | } |
| | | |
| | | @Override |
| | | public Integer recallPatient(Long roomId, String bedNo, String patId) { |
| | | Integer updateNum = queueMapper.passedPatientReturn(roomId, bedNo, patId, |