#
Junjie
3 天以前 6d99081f3f6e0363b0bd28053e545a8e4589b979
src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java
@@ -140,9 +140,11 @@
                    stationProtocol.setFullPlt(statusEntity.isFullPlt());
                    stationProtocol.setPalletHeight(statusEntity.getPalletHeight());
                    stationProtocol.setError(statusEntity.getError());
                    stationProtocol.setErrorMsg(statusEntity.getErrorMsg());
                    stationProtocol.setBarcode(statusEntity.getBarcode());
                    stationProtocol.setRunBlock(statusEntity.isRunBlock());
                    stationProtocol.setEnableIn(statusEntity.isEnableIn());
                    stationProtocol.setWeight(statusEntity.getWeight());
                }
            }
        }
@@ -217,7 +219,8 @@
        CommandResponse commandResponse = null;
        try {
            commandResponse = zyStationConnectDriver.sendCommand(command);
            return commandResponse;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            BasStationOptService optService = SpringUtils.getBean(BasStationOptService.class);
            List<ZyStationStatusEntity> statusListEntity = zyStationConnectDriver.getStatus();
@@ -249,6 +252,7 @@
                optService.insert(basStationOpt);
            }
        }
        return commandResponse;
    }
    @Override
@@ -292,7 +296,7 @@
            List<Integer> segmentEndIndices = new ArrayList<>();
            int idx = 0;
            while (idx < total) {
                int end = Math.min(idx + 20, total) - 1;
                int end = Math.min(idx + 3, total) - 1;
                segmentTargets.add(path.get(end));
                segmentEndIndices.add(end);
                idx = end + 1;
@@ -312,22 +316,29 @@
            segCmd.setNavigatePath(new ArrayList<>(path.subList(0, currentEndIdx + 1)));
            sendCommand(segCmd);
            boolean finished = false;
            while (!finished) {
            long runTime = System.currentTimeMillis();
            while (true) {
                try {
                    Integer currentStationId = findCurrentStationByTask(original.getTaskNo());
                    if (currentStationId == null) {
                    StationProtocol currentStation = findCurrentStationByTask(original.getTaskNo());
                    if (currentStation == null) {
                        if(System.currentTimeMillis() - runTime > 1000 * 60){
                            break;
                        }
                        Thread.sleep(500);
                        continue;
                    }
                    int currentIndex = path.indexOf(currentStationId);
                    runTime = System.currentTimeMillis();
                    if (currentStation.isRunBlock()) {
                        break;
                    }
                    int currentIndex = path.indexOf(currentStation.getStationId());
                    if (currentIndex < 0) {
                        Thread.sleep(500);
                        continue;
                    }
                    int remaining = total - currentIndex - 1;
                    if (remaining <= 0) {
                        finished = true;
                        break;
                    }
                    int currentSegEndIndex = path.indexOf(segmentTargets.get(segCursor));
@@ -359,7 +370,7 @@
        }
    }
    private Integer findCurrentStationByTask(Integer taskNo) {
    private StationProtocol findCurrentStationByTask(Integer taskNo) {
        try {
            com.zy.asrs.service.DeviceConfigService deviceConfigService = SpringUtils.getBean(com.zy.asrs.service.DeviceConfigService.class);
            if (deviceConfigService == null) {
@@ -378,7 +389,7 @@
                }
                for (StationProtocol sp : m.values()) {
                    if (sp.getTaskNo() != null && sp.getTaskNo().equals(taskNo) && sp.isLoading()) {
                        return sp.getStationId();
                        return sp;
                    }
                }
            }