#
luxiaotao1123
12 小时以前 000a710a02415542586adf2c5f5ecbe829f3d017
#
1个文件已修改
30 ■■■■ 已修改文件
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/StaReserveServiceImpl.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/StaReserveServiceImpl.java
@@ -50,7 +50,7 @@
            changed = staMapper.tryReserveInCommon(sta.getId(), qty);
        }
        if (changed < qty) {
            throw new BusinessException("Sta[" + sta.getStaNo() + "] can't reserve IN");
            throw new BusinessException("站点【" + sta.getStaNo() + "】可入库数量不足");
        }
        Date now = new Date();
@@ -71,7 +71,7 @@
        if (!this.save(reserve)) {
            staMapper.releaseReserveIn(sta.getId(), qty);
            throw new BusinessException("reserve record insert failed");
            throw new BusinessException("站点【" + sta.getStaNo() + "】入库预约保存失败");
        }
        return reserve;
@@ -91,7 +91,7 @@
            changed = staMapper.tryReserveOutCommon(sta.getId(), qty);
        }
        if (changed < qty) {
            throw new BusinessException("Sta[" + sta.getStaNo() + "] can't reserve OUT");
            throw new BusinessException("站点【" + sta.getStaNo() + "】可出库数量不足");
        }
        Date now = new Date();
@@ -113,7 +113,7 @@
        if (!this.save(reserve)) {
            staMapper.releaseReserveOut(sta.getId(), qty);
            throw new BusinessException("reserve record insert failed");
            throw new BusinessException("站点【" + sta.getStaNo() + "】出库预约保存失败");
        }
        return reserve;
@@ -175,10 +175,11 @@
    @Transactional(rollbackFor = Exception.class)
    public void confirmStaReserve(Sta sta, Task task, Integer qty, StaReserveType type) {
        qty = Optional.ofNullable(qty).orElse(DEFAULT_QTY);
        String reserveType = StaReserveType.IN.equals(type) ? "入库" : "出库";
        // update reserve state to be confirmed
        if (0 == this.baseMapper.updateState(task.getId(), sta.getId(), type.toString(), StaReserveStateType.CONFIRMED.toString())) {
            log.error("failed to confirm sta reserve");
            log.error("确认站点预约失败:未找到可确认的预约记录,站点【" + sta.getStaNo() + "】,任务【" + task.getSeqNum() + "】,预约方向【" + reserveType + "】");
            return;
        }
@@ -199,17 +200,18 @@
                break;
        }
        if (cntOfDealWithReserve == 0) {
            throw new BusinessException("Sta[" + sta.getStaNo() + "] confirm failed, type=" + type.toString());
            throw new BusinessException("站点【" + sta.getStaNo() + "】" + reserveType + "预约确认失败");
        }
    }
    @Override
    public void cancelStaReserve(Sta sta, Task task, Integer qty, StaReserveType type) {
        qty = Optional.ofNullable(qty).orElse(DEFAULT_QTY);
        String reserveType = StaReserveType.IN.equals(type) ? "入库" : "出库";
        // 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");
            log.error("取消站点预约失败:未找到可取消的预约记录,站点【" + sta.getStaNo() + "】,任务【" + task.getSeqNum() + "】,预约方向【" + reserveType + "】");
            return;
        }
@@ -225,7 +227,7 @@
                break;
        }
        if (cntOfDealWithReserve == 0) {
            throw new BusinessException("Sta[" + sta.getStaNo() + "] cancel failed, type=" + type.toString());
            throw new BusinessException("站点【" + sta.getStaNo() + "】" + reserveType + "预约取消失败");
        }
    }
@@ -251,7 +253,7 @@
//                        .gt(StaReserve::getExpireTime, now)
                );
                if (null == inStaReserve) {
                    throw new CoolException("failed to find out sta reserve");
                    throw new CoolException("未找到目标站点入库预约");
                }
                break;
            case STA_TO_LOC:
@@ -263,7 +265,7 @@
//                        .gt(StaReserve::getExpireTime, now)
                );
                if (null == outStaReserve) {
                    throw new CoolException("failed to find out sta reserve");
                    throw new CoolException("未找到起始站点出库预约");
                }
                break;
            case STA_TO_STA:
@@ -282,10 +284,10 @@
//                        .gt(StaReserve::getExpireTime, now)
                );
                if (null == inStaReserve) {
                    throw new CoolException("failed to find out sta reserve");
                    throw new CoolException("未找到目标站点入库预约");
                }
                if (null == outStaReserve) {
                    throw new CoolException("failed to find out sta reserve");
                    throw new CoolException("未找到起始站点出库预约");
                }
                break;
            default:
@@ -295,14 +297,14 @@
            inStaReserve.setAgvId(agvId);
            inStaReserve.setUpdateTime(now);
            if (!this.updateById(inStaReserve)) {
                throw new CoolException("failed to update sta reserve");
                throw new CoolException("入库预约绑定车辆失败");
            }
        }
        if (null != outStaReserve) {
            outStaReserve.setAgvId(agvId);
            outStaReserve.setUpdateTime(now);
            if (!this.updateById(outStaReserve)) {
                throw new CoolException("failed to update sta reserve");
                throw new CoolException("出库预约绑定车辆失败");
            }
        }
    }