#
vincentlu
2025-12-26 787e2917c8113a56ee58fc3a6ae11b0cd5f8e133
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -96,6 +96,8 @@
    private LaneService laneService;
    @Autowired
    private ActionSorter actionSorter;
    @Autowired
    private StaReserveService staReserveService;
    @SuppressWarnings("all")
    @Transactional
@@ -176,24 +178,14 @@
                    }
                    destSta = staService.getById(task.getDestSta());
                    if (!destSta.getStaSts().equals(StaStsType.IDLE.val())) {
                        throw new BusinessException("destSta:" + task.getDestSta$() + " is not in IDLE status");
                    }
                    destSta.setStaSts(StaStsType.READY_RELEASE.val());
                    destSta.setUpdateTime(now);
                    if (!staService.updateById(destSta)) {
                        throw new BusinessException("destSta:" + task.getDestSta$() + " failed to update");
                    if (null == staReserveService.reserveStaIn(destSta, task, 1)) {
                        throw new BusinessException("destSta:" + task.getDestSta$() + " failed to reserve");
                    }
                    break;
                case STA_TO_LOC:
                    oriSta = staService.getById(task.getOriSta());
                    if (!oriSta.getStaSts().equals(StaStsType.STOCK.val())) {
                        throw new BusinessException("oriSta:" + task.getOriSta$() + " is not in STOCK status");
                    }
                    oriSta.setStaSts(StaStsType.READY_TAKE.val());
                    oriSta.setUpdateTime(now);
                    if (!staService.updateById(oriSta)) {
                        throw new BusinessException("oriSta:" + task.getOriSta$() + " failed to update");
                    if (null == staReserveService.reserveStaOut(oriSta, task, 1)) {
                        throw new BusinessException("oriSta:" + task.getOriSta$() + " failed to reserve");
                    }
                    destLoc = locService.getById(task.getDestLoc());
@@ -208,23 +200,13 @@
                    break;
                case STA_TO_STA:
                    oriSta = staService.getById(task.getOriSta());
                    if (!oriSta.getStaSts().equals(StaStsType.STOCK.val())) {
                        throw new BusinessException("oriSta:" + task.getOriSta$() + " is not in STOCK status");
                    }
                    oriSta.setStaSts(StaStsType.READY_TAKE.val());
                    oriSta.setUpdateTime(now);
                    if (!staService.updateById(oriSta)) {
                        throw new BusinessException("oriSta:" + task.getOriSta$() + " failed to update");
                    if (null == staReserveService.reserveStaOut(oriSta, task, 1)) {
                        throw new BusinessException("oriSta:" + task.getOriSta$() + " failed to reserve");
                    }
                    destSta = staService.getById(task.getDestSta());
                    if (!destSta.getStaSts().equals(StaStsType.IDLE.val())) {
                        throw new BusinessException("destSta:" + task.getDestSta$() + " is not in IDLE status");
                    }
                    destSta.setStaSts(StaStsType.READY_RELEASE.val());
                    destSta.setUpdateTime(now);
                    if (!staService.updateById(destSta)) {
                        throw new BusinessException("destSta:" + task.getDestSta$() + " failed to update");
                    if (null == staReserveService.reserveStaIn(destSta, task, 1)) {
                        throw new BusinessException("destSta:" + task.getDestSta$() + " failed to reserve");
                    }
                    break;
                default:
@@ -249,10 +231,12 @@
            );
            if (Cools.isEmpty(taskList)) {
                bus.setBusSts(BusStsType.PROGRESS.val());
                bus.setUpdateTime(now);
                if (!busService.updateById(bus)) {
                    log.error("Bus [{}] failed to Update !!!", bus.getUuid());
                if (bus.getBusSts().equals(BusStsType.RECEIVE.val())) {
                    bus.setBusSts(BusStsType.PROGRESS.val());
                    bus.setUpdateTime(now);
                    if (!busService.updateById(bus)) {
                        log.error("Bus [{}] failed to Update !!!", bus.getUuid());
                    }
                }
                return;
            }
@@ -1112,7 +1096,24 @@
                        ));
                        break;
                    case TO_STANDBY:
//                        FuncSta standByFuncSta = funcStaService.query(agvId, lastCode.getId(), 2);
                        // load lift
//                        actionList.add(new Action(
//                                null,    // 编号
//                                null,    // 总线
//                                task.getId(),    // 任务
//                                null,    // 动作号
//                                null,    // 优先级
//                                ActionTypeType.LoadPlatformLift.desc,    // 名称
//                                null,    // 属性值
//                                lastCode.getData(),    // 地面码
//                                String.valueOf(0),   // 动作参数
//                                ActionTypeType.LoadPlatformLift.val(),    // 动作类型
//                                actionPrepareSts,    // 动作进度
//                                agvId,    // AGV
//                                now    // 工作时间
//                        ));
                        // turn
//                        FuncSta standByFuncSta = funcStaService.query(lastCode.getId(), FuncStaType.STANDBY.toString());
//                        Double standByDirection = Double.parseDouble(standByFuncSta.getAngle());
//                        if (!lastDirection.equals(standByDirection)) {
//                            actionList.add(new Action(
@@ -1177,6 +1178,7 @@
            for (Segment item : segmentList) {
                item.setGroupId(groupId);
                item.setState(SegmentStateType.RUNNING.toString());
                item.setStartTime(now);
                item.setUpdateTime(now);
                if (null != algoStartTime) {
                    item.setAlgoTime((int) (now.getTime() - algoStartTime.getTime()));
@@ -1297,6 +1299,13 @@
                        break;
                    case ReadyReleaseToShelvesLoc:
                        agvAction.add(new AgvActionItem<>(ReadyReleaseToShelvesLoc.class)
                                .setVal(action.getVal().intValue())
                                .setQrCode(action.getCode())
                                .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
                        );
                        break;
                    case LoadPlatformLift:
                        agvAction.add(new AgvActionItem<>(LoadPlatformLift.class)
                                .setVal(action.getVal().intValue())
                                .setQrCode(action.getCode())
                                .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
@@ -1530,6 +1539,7 @@
        // segment
        for (Segment segment : segmentList) {
            segment.setState(SegmentStateType.FINISH.toString());
            segment.setEndTime(now);
            segment.setUpdateTime(now);
            if (!segmentService.updateById(segment)) {
                log.error("Segment [{}] 更新失败 !!!", segment.getGroupId() + " - " + segment.getSerial());