| | |
| | | import cn.lihu.jh.module.ecg.config.DynamicSchedulingConfig; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; |
| | | import cn.lihu.jh.module.ecg.service.room.RoomService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.scheduling.config.CronTask; |
| | | import org.springframework.scheduling.config.ScheduledTask; |
| | | import org.springframework.scheduling.config.ScheduledTaskRegistrar; |
| | |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @Slf4j |
| | | public class QueueServiceImpl implements QueueService { |
| | | |
| | | @Resource |
| | |
| | | bedQueueBO.setBedNo(bedNo); |
| | | bedQueueBO.setMaxQueueNum(queueReadyMax); |
| | | bedQueueBO.setQueueNum(new AtomicInteger(queueDOList.size())); |
| | | bedQueueBO.setStatusEnum(BedStatusEnum.OPENING); |
| | | bedQueueBO.setBedStatus(BedStatusEnum.OPENING.getStatus()); |
| | | priorityQueue.offer(bedQueueBO); |
| | | mapBedVsQueue.put(String.format("%09d%s", roomId, bedNo), bedQueueBO); |
| | | return SUCCESS; |
| | |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | bedQueueBO.setStatusEnum(BedStatusEnum.PAUSE); |
| | | bedQueueBO.setBedStatus(BedStatusEnum.PAUSE.getStatus()); |
| | | priorityQueue.remove(bedQueueBO); |
| | | return SUCCESS; |
| | | } |
| | |
| | | @Override |
| | | public ErrorCode bedDoctorResume(Long roomId, String bedNo, Long docId, String docName) { |
| | | BedQueueBO bedQueueBO = mapBedVsQueue.get(String.format("%09d%s", roomId, bedNo)); |
| | | if (null == bedQueueBO) |
| | | if (null == bedQueueBO || !bedQueueBO.getBedStatus().equals(BedStatusEnum.PAUSE)) |
| | | return QUEUE_BED_ABNORMAL; |
| | | |
| | | // DB update |
| | |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | bedQueueBO.setStatusEnum(BedStatusEnum.DOCTOR_ON); |
| | | bedQueueBO.setBedStatus(BedStatusEnum.DOCTOR_ON.getStatus()); |
| | | if (!priorityQueue.contains(bedQueueBO)) { |
| | | priorityQueue.offer(bedQueueBO); |
| | | } else { |
| | | log.error("bedDoctorResume HAVE EXCEPTION!"); |
| | | } |
| | | |
| | | hurryup(); |
| | | return SUCCESS; |
| | |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | bedQueueBO.setStatusEnum(BedStatusEnum.DOCTOR_ON); |
| | | bedQueueBO.setBedStatus(BedStatusEnum.DOCTOR_ON.getStatus()); |
| | | |
| | | return SUCCESS; |
| | | } |
| | |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | bedQueueBO.setStatusEnum(BedStatusEnum.OPENING); |
| | | bedQueueBO.setBedStatus(BedStatusEnum.OPENING.getStatus()); |
| | | |
| | | return SUCCESS; |
| | | } |
| | |
| | | * 1. æ¯å¤©å¼è¯å ä»DB忥工ä½çæ£è
éåæ°æ®å° å·¥ä½ä¼å
éå |
| | | * 2. æå¡è¿ç»´é坿¶ |
| | | */ |
| | | public void initBedQueueAndSeqNumFromDB() { |
| | | @Override |
| | | public ErrorCode bedReload() { |
| | | priorityQueue.clear(); |
| | | mapBedVsQueue.clear(); |
| | | |
| | | // æ¸
é¤éå½å¤©çæé人å |
| | | queueMapper.clearQueue(); |
| | | |
| | | // ä»DB è·å å·¥ä½å表 |
| | | List<BedStatusEnum> bedStatusEnumList = new ArrayList<BedStatusEnum>(); |
| | |
| | | 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); |
| | | if (BedStatusEnum.PAUSE.getStatus() != item.getBedStatus()) { |
| | | priorityQueue.offer(item); |
| | | } |
| | | }); |
| | | |
| | | Integer num = queueMapper.getMaxSeqNum(); |
| | | curSeqNum = new AtomicInteger(null == num ? 0 : num); |
| | | |
| | | return SUCCESS; |
| | | } |
| | | |
| | | /** |
| | |
| | | public void hurryup() { |
| | | if (0 == openingFlag.get()) |
| | | return; |
| | | |
| | | if (mapBedVsQueue.size() != priorityQueue.size()) { |
| | | log.error("map " + mapBedVsQueue.size() + " priority " + priorityQueue.size()); |
| | | } |
| | | |
| | | // å¤ç è¿å·-忥 ç人 |
| | | for (BedQueueBO bedQueueBO : mapBedVsQueue.values()) { |
| | |
| | | if (1 == openingFlag.get()) |
| | | return; |
| | | |
| | | // æ¸
é¤éå½å¤©çæé人å |
| | | queueMapper.clearQueue(); |
| | | |
| | | initBedQueueAndSeqNumFromDB(); |
| | | |
| | | openingFlag.set(1); |
| | | hurryup(); |
| | | startBedReload(); |
| | | } |
| | | |
| | | public void closeBiz() { |
| | |
| | | }); |
| | | } |
| | | |
| | | private void startBedReload() { |
| | | singleThreadExecutor.execute( () -> { |
| | | bedReload(); |
| | | hurryup(); |
| | | }); |
| | | } |
| | | |
| | | } |