| | |
| | | package com.fzzy.gateway; |
| | | |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 常量 |
| | | */ |
| | | @Component |
| | | public class GatewayUtils { |
| | | |
| | | |
| | |
| | | return cacheMapDeviceSn.get(deviceSn); |
| | | } |
| | | |
| | | public static List<GatewayDevice> getCacheByDeviceType(String deviceType) { |
| | | List<GatewayDevice> result = new ArrayList<>(); |
| | | for (GatewayDevice device : cacheMapDeviceId.values()) { |
| | | if (deviceType.equals(device.getType())) result.add(device); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public static GatewayDevice getCacheByDeviceTypeOne(String deviceType) { |
| | | for (GatewayDevice device : cacheMapDeviceId.values()) { |
| | | if (deviceType.equals(device.getType())) return device; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static void removeCache(GatewayDevice data) { |
| | | cacheMapDeviceId.remove(data.getDeviceId()); |