vince
2024-01-16 236cf59aae727d304487676413c4337f73b16e67
src/main/java/com/fzzy/gateway/GatewayUtils.java
@@ -4,7 +4,6 @@
import com.fzzy.api.data.ApiCommonDevice;
import com.fzzy.api.data.GatewayDeviceType;
import com.fzzy.gateway.entity.GatewayDevice;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.*;
@@ -57,6 +56,16 @@
            if (deviceSn.equals(device.getDeviceSn())) return device;
        }
        return null;
    }
    public static GatewayDevice getCacheByDeviceSIp(String ip) {
        Collection<GatewayDevice> list = allCacheDevice();
        if (null == list || list.isEmpty()) return null;
        for (GatewayDevice device : list) {
            if (ip.equals(device.getIp())) return device;
        }
        return null;
    }
@@ -116,4 +125,17 @@
    public static Collection<GatewayDevice> listDeviceWeight() {
        return cacheMapDeviceWeight.values();
    }
    public static GatewayDevice getCacheByDepotSysId(String depotSysId) {
        if (null == depotSysId) return null;
        Collection<GatewayDevice> list = allCacheDevice();
        if (null == list || list.isEmpty()) return null;
        for (GatewayDevice device : list) {
            if (null == device.getDepotIdSys()) continue;
            if (depotSysId.equals(device.getDepotIdSys())) return device;
        }
        return null;
    }
}