| | |
| | | return reserve; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void confirmStaReserve(Sta sta, Task task, Integer qty, StaReserveType type) { |
| | | qty = Optional.ofNullable(qty).orElse(1); |
| | | |
| | | // update reserve state to be confirmed |
| | | if (0 == this.baseMapper.updateState(task.getId(), sta.getId(), type.toString(), StaReserveStateType.CONFIRMED.toString())) { |
| | | throw new BusinessException("failed to confirm sta reserve"); |
| | | } |
| | | |
| | | int cntOfDealWithReserve = 0; |
| | | switch (type) { |
| | | case IN: |
| | | cntOfDealWithReserve = staMapper.confirmReserveIn(sta.getId(), qty); |
| | | break; |
| | | case OUT: |
| | | cntOfDealWithReserve = staMapper.confirmReserveOut(sta.getId(), qty); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (cntOfDealWithReserve == 0) { |
| | | throw new BusinessException("Sta[" + sta.getStaNo() + "] apply confirmed failed, type=" + type.toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | private String generateReserveUniqKey(Long staId, Long taskId, StaReserveType type) { |
| | | return "STA:" + staId + "-TASK:" + taskId + "-T:" + type.toString(); |