| | |
| | | public Integer distributeSeqNo(Integer checkType, Integer timeslot) { |
| | | Integer curSeqNo = queueSequenceMapper.selectQueueNoForUpdate(checkType, timeslot); |
| | | if (null == curSeqNo) { |
| | | throw exception(QUEUE_SEQUENCE_TIMESLOT_FULL); |
| | | } |
| | | // 从下一个时段 获取序号。原因系统用30分钟的间隔划分预约时间段,HIS的预约时间段可能是30分钟或60分钟 |
| | | Integer nextTimeslot = getNextTimeSlot(timeslot, checkType); |
| | | if (null == nextTimeslot) { |
| | | throw exception(QUEUE_SEQUENCE_TIMESLOT_FULL); |
| | | } |
| | | |
| | | Integer updateRowNum = queueSequenceMapper.updateGivenCheckTypeTimeslotSeqNo(checkType, timeslot, curSeqNo); |
| | | if (null == updateRowNum || updateRowNum == 0) { |
| | | throw exception(QUEUE_SEQUENCE_TIMESLOT_EXCEPTION); |
| | | curSeqNo = queueSequenceMapper.selectQueueNoForUpdate(checkType, nextTimeslot); |
| | | if (null == curSeqNo) { |
| | | throw exception(QUEUE_SEQUENCE_TIMESLOT_FULL); |
| | | } |
| | | |
| | | Integer updateRowNum = queueSequenceMapper.updateGivenCheckTypeTimeslotSeqNo(checkType, nextTimeslot, curSeqNo); |
| | | if (null == updateRowNum || updateRowNum == 0) { |
| | | throw exception(QUEUE_SEQUENCE_TIMESLOT_EXCEPTION); |
| | | } |
| | | |
| | | } else { |
| | | Integer updateRowNum = queueSequenceMapper.updateGivenCheckTypeTimeslotSeqNo(checkType, timeslot, curSeqNo); |
| | | if (null == updateRowNum || updateRowNum == 0) { |
| | | throw exception(QUEUE_SEQUENCE_TIMESLOT_EXCEPTION); |
| | | } |
| | | } |
| | | |
| | | return curSeqNo + 1; |
| | |
| | | return curVipSeqNo + 1; |
| | | } |
| | | |
| | | private Integer getNextTimeSlot(Integer timeslot, Integer checkType) { |
| | | List<DictDataRespDTO> dictBookTimeslotList = dictDataApi.getDictDataList(ECG_BOOK_TIMESLOT); |
| | | Optional<Integer> index = dictBookTimeslotList.stream() |
| | | .filter(e -> e.getValue().equals(String.valueOf(timeslot))) |
| | | .findFirst() |
| | | .map(dictBookTimeslotList::indexOf); |
| | | if (!index.isPresent()) |
| | | return null; |
| | | |
| | | if (dictBookTimeslotList.size() <= (index.get() + 1)) |
| | | return null; |
| | | |
| | | DictDataRespDTO dictDataRespDTO = dictBookTimeslotList.get(index.get() + 1); |
| | | return Integer.valueOf(dictDataRespDTO.getValue()); |
| | | } |
| | | |
| | | } |
| | | |