#
zy
2025-07-16 1443e13e91ffb1bc6548722ef6a7a3b68d0ceed9
src/main/java/com/zy/core/thread/fake/FakeNyShuttleThread.java
@@ -30,6 +30,7 @@
    private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"mode\":1,\"extend\":{\"countQuantity\":400,\"suspendState\":0,\"minCellVoltage\":3279,\"chargeCycleTimes\":0,\"maxCellVoltage\":3281,\"surplusQuantity\":204,\"voltage\":5248},\"hasLift\":false,\"hasPallet\":false,\"batteryVoltage\":5248,\"runDirection\":\"2\",\"currentCode\":\"{\\\"x\\\":19,\\\"y\\\":11,\\\"z\\\":2}\",\"errorCode\":\"0\",\"hasCharge\":false,\"batteryPower\":\"51\",\"speed\":0,\"deviceStatus\":1}");
    private ServerSocket serverSocket;
    private Integer gatewayPort;
    private boolean enableFakeAndDeviceThread;
    private ConcurrentHashMap<String, Thread> fakeThreadMap = new ConcurrentHashMap();
    private ConcurrentHashMap<String, Socket> fakeServerMap = new ConcurrentHashMap();
    private ConcurrentHashMap<String, JSONObject> fakeStatusMap = new ConcurrentHashMap();
@@ -37,9 +38,10 @@
    private boolean fake = false;
    public FakeNyShuttleThread(RedisUtil redisUtil, Integer gatewayPort) {
    public FakeNyShuttleThread(RedisUtil redisUtil, Integer gatewayPort, boolean enableFakeAndDeviceThread) {
        this.redisUtil = redisUtil;
        this.gatewayPort = gatewayPort;
        this.enableFakeAndDeviceThread = enableFakeAndDeviceThread;
    }
    @Override
@@ -184,16 +186,18 @@
                continue;
            }
            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
            if (shuttleThread == null) {
                // init
                NyShuttleThread thread = new NyShuttleThread(device, redisUtil);;
                new Thread(thread).start();
                SlaveConnection.put(SlaveType.Shuttle, device.getDeviceNo(), thread);
            }else {
                Socket socket = shuttleThread.getSocket();
                if(socket == null){
                    continue;
            if (enableFakeAndDeviceThread) {
                NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
                if (shuttleThread == null) {
                    // init
                    NyShuttleThread thread = new NyShuttleThread(device, redisUtil);;
                    new Thread(thread).start();
                    SlaveConnection.put(SlaveType.Shuttle, device.getDeviceNo(), thread);
                }else {
                    Socket socket = shuttleThread.getSocket();
                    if(socket == null){
                        continue;
                    }
                }
            }