| | |
| | | |
| | | // 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"); |
| | | log.error("failed to confirm sta reserve"); |
| | | return; |
| | | } |
| | | |
| | | int cntOfDealWithReserve = 0; |
| | |
| | | break; |
| | | } |
| | | if (cntOfDealWithReserve == 0) { |
| | | throw new BusinessException("Sta[" + sta.getStaNo() + "] apply confirmed failed, type=" + type.toString()); |
| | | throw new BusinessException("Sta[" + sta.getStaNo() + "] confirm failed, type=" + type.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void cancelStaReserve(Sta sta, Task task, Integer qty, StaReserveType type) { |
| | | qty = Optional.ofNullable(qty).orElse(1); |
| | | |
| | | // update reserve state to be canceled |
| | | if (0 == this.baseMapper.updateState(task.getId(), sta.getId(), type.toString(), StaReserveStateType.CANCELLED.toString())) { |
| | | log.error("failed to cancel sta reserve"); |
| | | return; |
| | | } |
| | | |
| | | int cntOfDealWithReserve = 0; |
| | | switch (type) { |
| | | case IN: |
| | | cntOfDealWithReserve = staMapper.releaseReserveIn(sta.getId(), qty); |
| | | break; |
| | | case OUT: |
| | | cntOfDealWithReserve = staMapper.releaseReserveOut(sta.getId(), qty); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (cntOfDealWithReserve == 0) { |
| | | throw new BusinessException("Sta[" + sta.getStaNo() + "] cancel failed, type=" + type.toString()); |
| | | } |
| | | } |
| | | |