#
zwl
2026-02-09 ad79ba405b2d1ac96423f88f4e8a76c584b9d38a
src/main/java/com/zy/core/network/fake/ZyCrnFakeConnect.java
@@ -29,6 +29,7 @@
    @Override
    public boolean disconnect() {
        try { executor.shutdownNow(); } catch (Exception ignore) {}
        return true;
    }
@@ -52,6 +53,33 @@
        }
        response.setResult(true);
        return response;
    }
    @Override
    public CommandResponse sendCommand1(CrnCommand command) {
        CommandResponse response = new CommandResponse(false);
        if (command.getTaskMode().intValue() == CrnTaskModeType.LOC_MOVE.id) {
            //取放货
            executor.submit(() -> commandTake(command));
        } else if (command.getTaskMode().intValue() == CrnTaskModeType.CRN_MOVE.id) {
            //移动
            executor.submit(() -> commandMove(command));
        } else if (command.getTaskMode().intValue() == CrnTaskModeType.NONE.id) {
            //复位
            executor.submit(() -> commandTaskComplete(command));
        }
        response.setResult(true);
        return response;
    }
    @Override
    public CommandResponse sendCommand2(CrnCommand command) {
        return null;
    }
    @Override
    public CommandResponse sendCommand3(CrnCommand command) {
        return null;
    }
    private void commandTaskComplete(CrnCommand command) {
@@ -90,6 +118,9 @@
        moveZ(this.crnStatus.getLevel(), sourcePosZ);
        this.crnStatus.setStatus(CrnStatusType.FETCHING.id);
        sleep(2000);
        if (Thread.currentThread().isInterrupted()) {
            return;
        }
        this.crnStatus.setLoaded(1);
        this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id);
@@ -97,6 +128,9 @@
        moveZ(this.crnStatus.getLevel(), destinationPosZ);
        this.crnStatus.setStatus(CrnStatusType.PUTTING.id);
        sleep(2000);
        if (Thread.currentThread().isInterrupted()) {
            return;
        }
        this.crnStatus.setLoaded(0);
        this.crnStatus.setStatus(CrnStatusType.WAITING.id);
    }
@@ -109,6 +143,9 @@
                initSourcePosZ++;
                this.crnStatus.setLevel(initSourcePosZ);
                sleep(1000);
                if (Thread.currentThread().isInterrupted()) {
                    return;
                }
            }
        }else {
            int moveLength = sourcePosZ - destinationPosZ;
@@ -117,6 +154,9 @@
                initSourcePosZ--;
                this.crnStatus.setLevel(initSourcePosZ);
                sleep(1000);
                if (Thread.currentThread().isInterrupted()) {
                    return;
                }
            }
        }
    }
@@ -129,6 +169,9 @@
                initSourcePosY++;
                this.crnStatus.setBay(initSourcePosY);
                sleep(1000);
                if (Thread.currentThread().isInterrupted()) {
                    return;
                }
            }
        }else {
            int moveLength = sourcePosY - destinationPosY;
@@ -137,15 +180,18 @@
                initSourcePosY--;
                this.crnStatus.setBay(initSourcePosY);
                sleep(1000);
                if (Thread.currentThread().isInterrupted()) {
                    return;
                }
            }
        }
    }
        private void sleep(long ms) {
    private void sleep(long ms) {
        try {
            Thread.sleep(ms);
        } catch (InterruptedException e) {
            e.printStackTrace();
            Thread.currentThread().interrupt();
        }
    }
}