zhang
2 天以前 f6df128b575bdb9d0f2512b5fa5a126edfce2799
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java
@@ -201,16 +201,21 @@
            //        ArrayList<List<TaskPosDto>> list = JSON.parseObject(travel.getTaskContent(), new TypeReference<ArrayList<List<TaskPosDto>>>() {});
            // * sync wave scope
            if (!avoidWaveCalculator.calcWaveScope()) {
                log.error("failed to calculate avoid wave matrix ...");
                return;
            }
//            if (!avoidWaveCalculator.calcWaveScope(agvModelService.getByAgvId(agv.getId()))) {
//                log.error("failed to calculate avoid wave matrix ...");
//                return;
//            }
            // checkout path
            Code startCode = agvDetailService.getCurrentCode(travel.getAgvId());
            Code endCode = codeService.getCacheById(endNode);
//            long startTime = System.currentTimeMillis();
            List<String> pathList = this.checkoutPath(agv, startCode, endCode, segment);
            List<Jam> unfinishedOriginJamByCurrAgv = jamService.getUnfinishedOriginJamByAvo(agv.getId(), startCode.getId(), segment.getId());
            List<String> blackPath = this.getBlackPathList(unfinishedOriginJamByCurrAgv);
            List<String> pathList = mapService.checkoutPath(agv.getUuid(), startCode, endCode, false, blackPath, segment);
            //List<String> pathList = this.checkoutPath(agv, startCode, endCode, segment);
//            System.out.println("checkoutPath: " + (System.currentTimeMillis() - startTime));
            if (Cools.isEmpty(pathList)) {
                return;
@@ -247,7 +252,7 @@
                insertSeg.setPosType(TaskPosDto.PosType.MOVE.toString());
                insertSeg.setState(SegmentStateType.WAITING.toString());
                if (!segmentService.save(insertSeg)) {
                    log.error("Segment [{}] failed to save !!!", segment.getTravelId() + " - " + segment.getSerial());
                    log.error("Segment [{}] failed to save !!!", insertSeg.getTravelId() + " - " + insertSeg.getSerial());
                }
                segmentList.add(insertSeg);
@@ -277,7 +282,7 @@
                }
            }
            mapService.lockPath(null, pathList, agv.getUuid());
            //mapService.lockPath(null, pathList, agv.getUuid());
//            startTime = System.currentTimeMillis();
            mainService.generateAction(segment.getAgvId(), segmentList, pathList, now);
@@ -287,6 +292,7 @@
            log.error("TrafficService.trigger", e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            throw new RuntimeException("trigger method caught an exception", e);
        }
    }
@@ -309,7 +315,7 @@
        List<String> lockPathList = mapService.checkoutPath(agvNo, startCode, endCode, true, blackPath, segment);
        if (!Cools.isEmpty(lockPathList) && // 存在避让解
            Math.abs(lockPathList.size() - unlockPathList.size()) <= Arrays.stream(mapDataDispatcher.getCodeMatrix(lev)).mapToInt(row -> row.length).sum() / 10
                Math.abs(lockPathList.size() - unlockPathList.size()) <= Arrays.stream(mapDataDispatcher.getCodeMatrix(lev)).mapToInt(row -> row.length).sum() / 10
        ) {
            pathList = lockPathList;
@@ -348,7 +354,7 @@
                    }
                }
            // 无可走行路径
                // 无可走行路径
            } else {
                if (Cools.isEmpty(blockVehicleList)) {
@@ -671,7 +677,7 @@
                            // the wave of first node
                            Double avoidDistance = MapDataUtils.getVehicleWaveSafeDistance(
                                    agvModelService.getById(jamAgv.getAgvModel()).getDiameter(),
                                    agvModelService.getByAgvId(jamAgv.getId()).getDiameter(),
                                    MapDataConstant.MAX_DISTANCE_BETWEEN_ADJACENT_AGV_FACTOR
                            );
                            List<String> waveCodeList = mapService.getWaveScopeByCode(lev, firstCodeNode, avoidDistance)
@@ -696,10 +702,18 @@
            if (!blockVehicleDto.isAvoidable()) {
                continue;
            }
            Long agvId = agvService.getAgvId(blockVehicleDto.getVehicle());
            // 当前vehicle正在进行避让作业
            if (!Cools.isEmpty(jamService.getUnfinishedAvoSegByAvo(blockVehicleDto.getVehicle(), null))) {
            if (!Cools.isEmpty(jamService.getUnfinishedAvoSegByAvo(agvId, null))) {
                continue;
            }
            // 当前vehicle正在进行滚筒输送线等待
            if (travelService.hasRollerWaiting(agvId)) {
                continue;
            }
//            if (segmentService.isRollerWaiting(agvId)) {
//                continue;
//            }
            return blockVehicleDto.getVehicle();
        }
        return null;