| | |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants; |
| | | import cn.lihu.jh.module.ecg.Utils; |
| | | import cn.lihu.jh.module.ecg.config.DynamicSchedulingConfig; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; |
| | |
| | | import cn.lihu.jh.framework.common.util.object.BeanUtils; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.queue.queueMapper; |
| | | |
| | | import static cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants.SUCCESS; |
| | | import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.lihu.jh.framework.common.pojo.CommonResult.error; |
| | | import static cn.lihu.jh.framework.common.pojo.CommonResult.success; |
| | |
| | | bedQueueBO.setStatus(BedStatusEnum.OPENING.getStatus()); |
| | | priorityQueue.offer(bedQueueBO); |
| | | mapBedVsQueue.put(String.format("%09d%s", roomId, bedNo), bedQueueBO); |
| | | return SUCCESS; |
| | | |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | mapBedVsQueue.remove(String.format("%09d%s", roomId, bedNo)); |
| | | priorityQueue.remove(bedQueueBO); |
| | | return SUCCESS; |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<RoomRespVO> getRoom(Long roomId, String bedNo, Long docId) { |
| | | RoomDO roomDO = roomMapper.getRoom(roomId, bedNo, docId); |
| | | if (null == roomDO) { |
| | | return error(ROOM_NOT_SIT); |
| | | } |
| | | |
| | | BedQueueBO bedQueueBO = mapBedVsQueue.get(String.format("%09d%s", roomId, bedNo)); |
| | | if (null == bedQueueBO) { |
| | | log.error("getRoom mapBedVsQueue DONOT existed. " + roomId + " " + bedNo); |
| | | return error(QUEUE_BED_NOT_EXIST); |
| | | } |
| | | |
| | | RoomDO roomDO = roomMapper.getRoom(roomId, bedNo, docId); |
| | | if (null == roomDO) { |
| | | return error(ROOM_NOT_SIT); |
| | | } |
| | | |
| | | RoomRespVO roomRespVO = BeanUtils.toBean(roomDO, RoomRespVO.class); |
| | |
| | | |
| | | bedQueueBO.setStatus(BedStatusEnum.PAUSE.getStatus()); |
| | | priorityQueue.remove(bedQueueBO); |
| | | return SUCCESS; |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | |
| | | hurryup(); |
| | | return SUCCESS; |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | bedQueueBO.setStatus(BedStatusEnum.DOCTOR_ON.getStatus()); |
| | | return SUCCESS; |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | bedQueueBO.setStatus(BedStatusEnum.OPENING.getStatus()); |
| | | return SUCCESS; |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | } |
| | | |
| | | private void validatequeueExists(Integer id) { |
| | |
| | | Integer num = queueMapper.getMaxSeqNum(); |
| | | curSeqNum = new AtomicInteger(null == num ? 0 : num); |
| | | |
| | | return SUCCESS; |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | } |
| | | |
| | | /** |
| | |
| | | public void hurryup() { |
| | | if (0 == openingFlag.get()) |
| | | return; |
| | | |
| | | // TODO |
| | | log.info("map " + mapBedVsQueue.size() + " priority " + priorityQueue.size()); |
| | | if (mapBedVsQueue.size() != priorityQueue.size()) { |
| | | log.error("map " + mapBedVsQueue.size() + " priority " + priorityQueue.size()); |
| | | } |
| | | |
| | | // 处理 过号-回来 的人 |
| | | for (BedQueueBO bedQueueBO : mapBedVsQueue.values()) { |
| | |
| | | priorityQueue.remove(bo); |
| | | priorityQueue.offer(bo); |
| | | |
| | | hurryup(); |
| | | return SUCCESS; |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | } |
| | | |
| | | public void finishNextPatient(Long roomId, String bedNo) { |
| | |
| | | return updateNum; |
| | | } |
| | | |
| | | @Override |
| | | public void monitorInfo() { |
| | | log.info("map " + mapBedVsQueue.size() + " priority " + priorityQueue.size() |
| | | + " opening " + openingFlag.get()); |
| | | } |
| | | |
| | | private void startHurryUp() { |
| | | singleThreadExecutor.execute( () -> { |
| | | hurryup(); |