| | |
| | | package cn.lihu.jh.module.ecg.service.callingscreen; |
| | | |
| | | 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.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 javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 排队 Service 实现类 |
| | |
| | | @Resource |
| | | private RoomMapper roomMapper; |
| | | |
| | | @Resource |
| | | private CheckTypeMapper checkTypeMapper; |
| | | |
| | | BigScreenConfig bigScreenConfig; |
| | | |
| | | Map<Integer, Integer> mapCheckTypeVsDisplayColumn = null; |
| | | |
| | | Integer waitingFrom = 0; |
| | | Integer passedFrom = 0; |
| | |
| | | this.bigScreenConfig = bigScreenConfig; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<Integer, List<QueueDO>> callingData() { |
| | | List<Byte> queueStatusList = new ArrayList<>(); |
| | | public Map<Integer, List<String>> getDisplayColInfo() { |
| | | CheckTypePageReqVO checkTypePageReqVO = new CheckTypePageReqVO(); |
| | | checkTypePageReqVO.setPageSize(-1); |
| | | checkTypePageReqVO.setCallingColumn(-1); // 列号 -1 的不显示 |
| | | PageResult<CheckTypeDO> pageResult = checkTypeMapper.selectPageForCallingScreen(checkTypePageReqVO); |
| | | Map<Integer, List<CheckTypeDO>> mapDisplayColName = pageResult.getList().stream().collect(Collectors.groupingBy(CheckTypeDO::getCallingColumn)); |
| | | mapCheckTypeVsDisplayColumn = pageResult.getList().stream().collect(Collectors.toMap(CheckTypeDO::getValue, item -> item.getCallingColumn())); |
| | | |
| | | Map<Integer, List<String>> _map = new HashMap<>(); |
| | | mapDisplayColName.keySet().forEach(key -> { |
| | | _map.put(key, mapDisplayColName.get(key).stream().map(item->item.getName()).toList()); |
| | | }); |
| | | return _map; |
| | | } |
| | | |
| | | @Override |
| | | public Map<Integer, Map<Integer, List<QueueDO>>> callingData() { |
| | | Map<Integer, Map<Integer, List<QueueDO>>> mapDisplayColQueue = new HashMap<>(); |
| | | int displayColCnt = (int) mapCheckTypeVsDisplayColumn.values().stream().distinct().count(); |
| | | for (int dispCol=0; dispCol<displayColCnt; dispCol++) { |
| | | Map<Integer, List<QueueDO>> mapSoltQueueData = new HashMap<>(); |
| | | mapSoltQueueData.put(0, new ArrayList<>()); |
| | | mapSoltQueueData.put(1, new ArrayList<>()); |
| | | mapSoltQueueData.put(2, new ArrayList<>()); |
| | | mapDisplayColQueue.put(dispCol, mapSoltQueueData); |
| | | } |
| | | |
| | | mapDisplayColQueue.values().stream().forEach(mapSlotQueue -> { |
| | | mapSlotQueue.values().stream().forEach(queueList -> queueList.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 -> { |
| | | Map<Integer, List<QueueDO>> mapSlotQueue = mapDisplayColQueue.get(mapCheckTypeVsDisplayColumn.get(queueDO.getBookCheckType())); |
| | | List<QueueDO> soltList = mapSlotQueue.get(getDisplatSlotByQueueStatus(queueDO.getStatus())); |
| | | soltList.add( queueDO ); |
| | | }); |
| | | |
| | | mapDisplayColQueue.values().stream().forEach(mapSoltQueue -> mapSoltQueue.values().stream().forEach( |
| | | slotQueueList -> slotQueueList.sort((o1, o2) -> { |
| | | if (null == o1.getSeqNum() && null == o2.getSeqNum()) { |
| | | return o1.getBookTimeslot() - o2.getBookTimeslot(); |
| | | } else if (null != o1.getSeqNum() && null != o2.getSeqNum()) { |
| | | return o1.getSeqNum() - o2.getSeqNum(); |
| | | } else if (null == o1.getSeqNum()) { |
| | | return 1; |
| | | } else { //这里 必定 null == o2.getSeqNum() |
| | | return -1; |
| | | } |
| | | }))); |
| | | return mapDisplayColQueue; |
| | | } |
| | | |
| | | @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; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | } |