| | |
| | | import java.util.concurrent.*; |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.lihu.jh.module.ecg.Utils; |
| | | import cn.lihu.jh.module.ecg.controller.admin.room.vo.MonitorInfoVO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.call.CallMapper; |
| | |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; |
| | | import cn.lihu.jh.framework.common.pojo.PageResult; |
| | | import cn.lihu.jh.framework.common.util.object.BeanUtils; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.queue.queueMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.queue.QueueMapper; |
| | | import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*; |
| | | import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.lihu.jh.framework.common.pojo.CommonResult.error; |
| | |
| | | private OAuth2TokenApi oAuth2TokenApi; |
| | | |
| | | @Resource |
| | | private queueMapper queueMapper; |
| | | private QueueMapper queueMapper; |
| | | |
| | | @Resource |
| | | private RoomMapper roomMapper; |
| | |
| | | private DevRentMapper devRentMapper; |
| | | |
| | | ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); |
| | | |
| | | ConcurrentHashMap<String, RoomDO> mapRoomBed = new ConcurrentHashMap<>(); |
| | | |
| | | @Override |
| | | public Integer createqueue(QueueSaveReqVO createReqVO) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ErrorCode startNextInstallPatient(Long roomId, String bedNo) { |
| | | Future<ErrorCode> future = singleThreadExecutor.submit( |
| | | new BedDoctorNextInstallPatientCallable(queueServiceTxFunctions, roomId, bedNo) |
| | | ); |
| | | |
| | | try { |
| | | ErrorCode ret = future.get(); |
| | | return ret; |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } catch (ExecutionException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | System.out.println("startNextInstallPatient ========"); |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | |
| | | @Override |
| | | public void startHurryUpOneBed(Long roomId, String bedNo) { |
| | | singleThreadExecutor.execute( () -> { |
| | | queueServiceTxFunctions.hurryupOneBed(roomId, bedNo); |
| | |
| | | |
| | | DevRentDO devRent = BeanUtils.toBean(queueSaveReqVO, DevRentDO.class); |
| | | devRent.setState( DevRentStateEnum.FREE.getState() ); |
| | | devRent.setPatDetails( queueSaveReqVO.getPatDetails() ); |
| | | devRentMapper.insert(devRent); |
| | | |
| | | startHurryUpOneCheckType(Integer.valueOf(queue.getBookCheckType())); |
| | | startHurryUpOneCheckType( queue.getBookCheckType() ); |
| | | } |
| | | |
| | | // 常规检查 叫号 |
| | | @Override |
| | | public void finishNextPatient(Long roomId, String bedNo) { |
| | | // 从 DB 把 就诊中的人 设置为就诊完成 |
| | | Integer ret = queueMapper.updateQueueStatus(roomId, bedNo, |
| | | QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.FINISH.getStatus()); |
| | | //Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo, |
| | | // QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.FINISH.getStatus()); |
| | | |
| | | // 从 DB 检查 该工位 是否有 [就诊中] 人员,若有就.放弃取下一位 |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | Integer num = queueMapper.bedQueueStatisticByStatus(roomId, bedNo, queueStatusList); |
| | | if ( num != null && num > 0) |
| | | return; |
| | | |
| | | startNextPatient(roomId, bedNo); |
| | | } |
| | | |
| | | // 领用 叫号 |
| | | @Override |
| | | public void finishReceiveNextPatient(Long roomId, String bedNo) { |
| | | // 从 DB 把 [就诊中] 的人 设置为 【已领用】 |
| | | //Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo, |
| | | // QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.RECEIVED.getStatus()); |
| | | |
| | | // 从 DB 检查 该工位 是否有 [就诊中] 人员,若有就.放弃取下一位 |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | Integer num = queueMapper.bedQueueStatisticByStatus(roomId, bedNo, queueStatusList); |
| | | if ( num != null && num > 0) |
| | | return; |
| | | |
| | | startNextPatient(roomId, bedNo); |
| | | } |
| | | |
| | | // 装机 叫号 |
| | | @Override |
| | | public void finishInstallNextPatient(Long roomId, String bedNo) { |
| | | // 从 DB 把 [安装中] 的人 设置为 [已就诊] |
| | | //Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo, |
| | | // QueueStatusEnum.INSTALLING.getStatus(), QueueStatusEnum.FINISH.getStatus()); |
| | | |
| | | // 从 DB 检查 该工位 是否有 [就诊中] 人员,若有就.放弃取下一位 |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.INSTALLING.getStatus()); |
| | | Integer num = queueMapper.bedQueueStatisticByStatus(roomId, bedNo, queueStatusList); |
| | | if ( num != null && num > 0) |
| | | return; |
| | | |
| | | startNextInstallPatient(roomId, bedNo); |
| | | } |
| | | |
| | | public void passNextPatient(Long roomId, String bedNo) { |
| | | // 从 DB 把 就诊中的人 设置为过号 |
| | | Integer ret = queueMapper.updateQueueStatus(roomId, bedNo, |
| | | Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo, |
| | | QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.PASSED.getStatus()); |
| | | |
| | | startNextPatient(roomId, bedNo); |
| | | } |
| | | |
| | | public List<QueueDO> getDoctorQueueByStatus(Long roomId, String bedNo, List<Byte> statusList) { |
| | | List<QueueDO> queueDOList = queueMapper.getDoctorQueueByStatus(roomId, bedNo, statusList); |
| | | @Override |
| | | public void passInstallNextPatient(Long roomId, String bedNo) { |
| | | // 从 DB 把 [安装中]的人 设置为 [过号-安装] |
| | | Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo, |
| | | QueueStatusEnum.INSTALLING.getStatus(), QueueStatusEnum.PASSED_INSTALL.getStatus()); |
| | | |
| | | startNextPatient(roomId, bedNo); |
| | | } |
| | | |
| | | public List<QueueDO> getBedQueueByStatus(Long roomId, String bedNo, List<Integer> statusList) { |
| | | List<QueueDO> queueDOList = queueMapper.getBedQueueByStatus(roomId, bedNo, statusList); |
| | | return queueDOList; |
| | | } |
| | | |
| | | @Override |
| | | public List<QueueDO> getRoomQueueByStatus(Long roomId, List<Integer> statusList) { |
| | | List<QueueDO> queueDOList = queueMapper.getRoomQueueByStatus(roomId, statusList); |
| | | return queueDOList; |
| | | } |
| | | |
| | | // 常规检查 医生界面的统计信息 |
| | | public PatientStatisticVO getPatientStatistic(Long roomId, String bedNo) { |
| | | PatientStatisticVO patientStatisticVO = new PatientStatisticVO(); |
| | | List<BedQueueStatisticDO> bedQueueStatisticDOList = queueMapper.bedQueueStatistic(roomId, bedNo); |
| | |
| | | } |
| | | }); |
| | | |
| | | List<Byte> statusList = new ArrayList<>(); |
| | | // 统计 该工位类型的【排队中】人员数量 |
| | | RoomDO roomDO = getRoomDO(roomId, bedNo); |
| | | Integer[] checkTypes = roomDO.getCheckTypes(); |
| | | List<Integer> statusList = new ArrayList<>(); |
| | | statusList.add(QueueStatusEnum.WAITING.getStatus()); |
| | | Integer num = queueMapper.statusStatistic(statusList); |
| | | Integer num = queueMapper.checkTypeAndStatusStatistic(checkTypes, statusList); |
| | | patientStatisticVO.setQueuingNum(num); |
| | | |
| | | return patientStatisticVO; |
| | | } |
| | | |
| | | public void setCheckTypeReadyMax(Map<Integer, Integer> max) { |
| | | queueServiceTxFunctions.setCheckTypeReadyMax( max ); |
| | | public PatientStatisticVO getBedDevInstallStatistic(Long roomId, String bedNo) { |
| | | PatientStatisticVO patientStatisticVO = new PatientStatisticVO(); |
| | | List<BedQueueStatisticDO> bedQueueStatisticDOList = queueMapper.bedQueueStatistic(roomId, bedNo); |
| | | bedQueueStatisticDOList.forEach(item -> { |
| | | // } else if (QueueStatusEnum.INSTALLING.getStatus() == item.getStatus()) { |
| | | // patientStatisticVO.setReceivedNum( patientStatisticVO.getReceivedNum() + item.getTotalInStatus() ); |
| | | if (QueueStatusEnum.FINISH.getStatus() == item.getStatus()) { |
| | | patientStatisticVO.setFinishedNum(item.getTotalInStatus()); |
| | | } |
| | | }); |
| | | |
| | | // 装机界面:统计 该诊室 [已领用] 的数量, 因为安装工位看不到 [已领用] 患者,所以无法根据装机工位来统计,只能按诊室统计 |
| | | patientStatisticVO.setReceivedNum( 0 ); |
| | | List<BedQueueStatisticDO> roomQueueStatisticDOList = queueMapper.roomQueueStatistic(roomId); |
| | | roomQueueStatisticDOList.forEach(item -> { |
| | | if (QueueStatusEnum.RECEIVED.getStatus() == item.getStatus()) { |
| | | patientStatisticVO.setReceivedNum( patientStatisticVO.getReceivedNum() + item.getTotalInStatus() ); |
| | | } |
| | | }); |
| | | |
| | | return patientStatisticVO; |
| | | } |
| | | |
| | | public PatientStatisticVO getBedDevReadyStatistic(Long roomId, String bedNo) { |
| | | PatientStatisticVO patientStatisticVO = new PatientStatisticVO(); |
| | | List<BedQueueStatisticDO> bedQueueStatisticDOList = queueMapper.bedQueueStatistic(roomId, bedNo); |
| | | bedQueueStatisticDOList.forEach(item -> { |
| | | if (QueueStatusEnum.READY.getStatus() == item.getStatus()) { |
| | | patientStatisticVO.setReadyNum(item.getTotalInStatus()); |
| | | } else if (QueueStatusEnum.PASSED.getStatus() == item.getStatus()) { |
| | | patientStatisticVO.setPassedNum(item.getTotalInStatus()); |
| | | } |
| | | }); |
| | | |
| | | // 领用界面:统计 该诊室 [已领用] 的数量, 因为安装时患者归属工位从领用工位变更到安装工位,所以无法根据领用工位来统计,只能按诊室统计 |
| | | patientStatisticVO.setReceivedNum( 0 ); |
| | | List<BedQueueStatisticDO> roomQueueStatisticDOList = queueMapper.roomQueueStatistic(roomId); |
| | | roomQueueStatisticDOList.forEach(item -> { |
| | | if (QueueStatusEnum.RECEIVED.getStatus() == item.getStatus()) { |
| | | patientStatisticVO.setReceivedNum( patientStatisticVO.getReceivedNum() + item.getTotalInStatus() ); |
| | | } else if (QueueStatusEnum.INSTALLING.getStatus() == item.getStatus()) { |
| | | patientStatisticVO.setReceivedNum( patientStatisticVO.getReceivedNum() + item.getTotalInStatus() ); |
| | | } else if (QueueStatusEnum.FINISH.getStatus() == item.getStatus()) { |
| | | patientStatisticVO.setReceivedNum(patientStatisticVO.getReceivedNum() + item.getTotalInStatus() ); |
| | | } |
| | | }); |
| | | |
| | | // 统计 该工位类型的【排队中】人员数量 |
| | | RoomDO roomDO = getRoomDO(roomId, bedNo); |
| | | Integer[] checkTypes = roomDO.getCheckTypes(); |
| | | List<Integer> statusList = new ArrayList<>(); |
| | | statusList.add(QueueStatusEnum.WAITING.getStatus()); |
| | | Integer num = queueMapper.checkTypeAndStatusStatistic(checkTypes, statusList); |
| | | patientStatisticVO.setQueuingNum(num); |
| | | |
| | | return patientStatisticVO; |
| | | } |
| | | |
| | | public void initCheckType() { |
| | | queueServiceTxFunctions.initCheckType( ); |
| | | } |
| | | |
| | | public void startBiz() { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer recallInstallPatient(Long roomId, String bedNo, String patId) { |
| | | Integer updateNum = queueMapper.recallPassedInstallPatient(roomId, bedNo, patId, |
| | | QueueStatusEnum.PASSED_INSTALL.getStatus(), QueueStatusEnum.RECALLED_INSTALL.getStatus()); |
| | | // 安装工位 不设计 优先队列 |
| | | //startHurryUpOneBed(roomId, bedNo); |
| | | return updateNum; |
| | | } |
| | | |
| | | @Override |
| | | public Integer patientJump(String patId, Byte jumped) { |
| | | Integer updateNum = queueMapper.queueJump(patId, QueueStatusEnum.WAITING.getStatus(), jumped); |
| | | |
| | |
| | | return roomMapper.getRoomByDocId(docId); |
| | | } |
| | | |
| | | @Override |
| | | public List<QueueDO> getToBeCheckedPatient(Long roomId, String bedNo) { |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.RECALLED.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.READY.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.PASSED.getStatus()); |
| | | List<QueueDO> queueDOList = getBedQueueByStatus(roomId, bedNo, queueStatusList); |
| | | return queueDOList; |
| | | } |
| | | |
| | | @Override |
| | | public List<QueueDO> getToBeInstalledPatient(Long roomId, String bedNo) { |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.RECEIVED.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.PASSED_INSTALL.getStatus()); |
| | | List<QueueDO> queueDOList = getRoomQueueByStatus(roomId, queueStatusList); |
| | | |
| | | queueStatusList.clear(); |
| | | queueStatusList.add(QueueStatusEnum.INSTALLING.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.RECALLED_INSTALL.getStatus()); |
| | | queueDOList.addAll(0, getBedQueueByStatus(roomId, bedNo, queueStatusList) ); |
| | | return queueDOList; |
| | | } |
| | | |
| | | private RoomDO getRoomDO(Long roomId, String bedNo) { |
| | | RoomDO roomDO = mapRoomBed.get( Utils.formatRoomBed(roomId, bedNo) ); |
| | | if ( null == roomDO) |
| | | roomDO = roomMapper.getRoom(roomId, bedNo); |
| | | |
| | | return roomDO; |
| | | } |
| | | |
| | | } |