| | |
| | | package cn.lihu.jh.module.ecg.service.callingscreen; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.ErrorCode; |
| | | import cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants; |
| | | import cn.lihu.jh.framework.common.pojo.PageResult; |
| | | import cn.lihu.jh.module.ecg.controller.admin.checktype.vo.CheckTypePageReqVO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.queue.queueMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.checktype.CheckTypeMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.queue.QueueMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.room.RoomMapper; |
| | | import cn.lihu.jh.module.ecg.enums.QueueStatusEnum; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.PATIENT_NOT_EXISTS; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 排队 Service 实现类 |
| | |
| | | public class CallingScreenServiceImpl implements CallingScreenService { |
| | | |
| | | @Resource |
| | | private queueMapper queueMapper; |
| | | private QueueMapper queueMapper; |
| | | |
| | | @Resource |
| | | private RoomMapper roomMapper; |
| | | |
| | | @Resource |
| | | private CheckTypeMapper checkTypeMapper; |
| | | |
| | | BigScreenConfig bigScreenConfig; |
| | | |
| | | Map<Integer, Integer> mapCheckTypeVsDisplayColumn = null; |
| | | |
| | | Map<Integer, List<QueueDO>> mapDisplaySlotVsCallingData = new HashMap<>(); |
| | | |
| | | Integer waitingFrom = 0; |
| | | Integer passedFrom = 0; |
| | |
| | | |
| | | @Override |
| | | public Map<Integer, List<QueueDO>> callingData() { |
| | | List<Byte> queueStatusList = new ArrayList<>(); |
| | | if (null == mapCheckTypeVsDisplayColumn) { |
| | | getDisplayColumnConfig(); |
| | | } else { |
| | | mapDisplaySlotVsCallingData.values().stream().forEach(slotQueueList -> slotQueueList.clear()); |
| | | } |
| | | |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.READY.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.WAITING.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.RECALLED.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.PASSED.getStatus()); |
| | | List<QueueDO> queueDOList = queueMapper.getQueueByStatus( queueStatusList ); |
| | | queueDOList.stream().forEach(queueDO -> { |
| | | List<QueueDO> listSolt = getDisplatSlotByQueue( queueDO.getBookCheckType(), queueDO.getStatus()); |
| | | listSolt.add( queueDO ); |
| | | }); |
| | | |
| | | mapDisplaySlotVsCallingData.values().stream().forEach(slotQueueList -> slotQueueList.sort(null)); |
| | | return mapDisplaySlotVsCallingData; |
| | | } |
| | | |
| | | @Override |
| | | public Map<Integer, List<QueueDO>> callingData2() { |
| | | List<Integer> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.READY.getStatus()); |
| | | queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | List<QueueDO> listReady = queueMapper.getQueueByStatus( queueStatusList ); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<QueueDO> getRoomQueue(String ip, List<Byte> statusList) { |
| | | public List<QueueDO> getRoomQueue(String ip, List<Integer> statusList) { |
| | | List<RoomDO> roomDOList = roomMapper.queueByIp(ip); |
| | | Optional<RoomDO> optionalQueueDO = roomDOList.stream().filter(item -> StringUtils.hasLength(item.getIp())).findFirst(); |
| | | if (!optionalQueueDO.isPresent()) { |
| | |
| | | return queueDOList; |
| | | } |
| | | |
| | | @Override |
| | | public ErrorCode markCalled(String patientId) { |
| | | Integer rowNum = queueMapper.markCalled(patientId); |
| | | if (rowNum == 1) |
| | | return GlobalErrorCodeConstants.SUCCESS; |
| | | private void getDisplayColumnConfig() { |
| | | CheckTypePageReqVO checkTypePageReqVO = new CheckTypePageReqVO(); |
| | | checkTypePageReqVO.setPageSize(-1); |
| | | PageResult<CheckTypeDO> pageResult = checkTypeMapper.selectPage(checkTypePageReqVO); |
| | | mapCheckTypeVsDisplayColumn = pageResult.getList().stream().collect(Collectors.toMap(CheckTypeDO::getValue, item -> item.getCallingColumn())); |
| | | |
| | | return PATIENT_NOT_EXISTS; |
| | | int displayColCnt = (int) mapCheckTypeVsDisplayColumn.values().stream().distinct().count(); |
| | | for (int i=0; i<displayColCnt; i++) { |
| | | mapDisplaySlotVsCallingData.put(i*1000 + 0, new ArrayList<>()); |
| | | mapDisplaySlotVsCallingData.put(i*1000 + 1, new ArrayList<>()); |
| | | mapDisplaySlotVsCallingData.put(i*1000 + 2, new ArrayList<>()); |
| | | } |
| | | } |
| | | |
| | | private List<QueueDO> getDisplatSlotByQueue( Integer checkType, Integer queueStatus ) { |
| | | return mapDisplaySlotVsCallingData.get(mapCheckTypeVsDisplayColumn.get(checkType)*1000 + getDisplatSlotByQueueStatus(queueStatus)); |
| | | } |
| | | |
| | | private Integer getDisplatSlotByQueueStatus( Integer queueStatus ) { |
| | | if (QueueStatusEnum.READY.getStatus() == queueStatus) |
| | | return 0; |
| | | else if (QueueStatusEnum.ONSTAGE.getStatus() == queueStatus) |
| | | return 0; |
| | | else if (QueueStatusEnum.WAITING.getStatus() == queueStatus) |
| | | return 1; |
| | | else if (QueueStatusEnum.RECALLED.getStatus() == queueStatus) |
| | | return 1; |
| | | else if (QueueStatusEnum.PASSED.getStatus() == queueStatus) |
| | | return 2; |
| | | else |
| | | return 0; |
| | | } |
| | | |
| | | } |