| | |
| | | public static Map<String, GatewayDevice> cacheMapDeviceId = new HashMap<>(); |
| | | |
| | | /** |
| | | * 设备缓存 |
| | | */ |
| | | public static Map<String, GatewayDevice> cacheMapDeviceSn = new HashMap<>(); |
| | | |
| | | /** |
| | | * 设备缓存-只针对 |
| | | */ |
| | | public static Map<String, GatewayDevice> cacheMapDeviceWeight = new HashMap<>(); |
| | |
| | | |
| | | public static void add2Cache(GatewayDevice device) { |
| | | cacheMapDeviceId.put(device.getDeviceId(), device); |
| | | cacheMapDeviceSn.put(device.getDeviceSn(), device); |
| | | |
| | | //保存地磅 |
| | | if (GatewayDeviceType.TYPE_01.getCode().equals(device.getType())) { |
| | | cacheMapDeviceWeight.put(device.getDeviceId(), device); |
| | | } |
| | | } |
| | | |
| | | public static Collection<GatewayDevice> allCacheDevice() { |
| | | return cacheMapDeviceId.values(); |
| | | } |
| | | |
| | | public static GatewayDevice getCacheByDeviceId(String deviceId) { |
| | |
| | | } |
| | | |
| | | public static GatewayDevice getCacheByDeviceSn(String deviceSn) { |
| | | return cacheMapDeviceSn.get(deviceSn); |
| | | Collection<GatewayDevice> list = allCacheDevice(); |
| | | if (null == list || list.isEmpty()) return null; |
| | | |
| | | for (GatewayDevice device : list) { |
| | | if (deviceSn.equals(device.getDeviceSn())) return device; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 针对一个通讯分机对多个仓情况 |
| | | * |
| | | * @param deviceSn |
| | | * @return |
| | | */ |
| | | public static List<GatewayDevice> getCacheByDeviceSn2(String deviceSn) { |
| | | Collection<GatewayDevice> list = allCacheDevice(); |
| | | if (null == list || list.isEmpty()) return null; |
| | | |
| | | List<GatewayDevice> result = new ArrayList<>(); |
| | | for (GatewayDevice device : list) { |
| | | if (deviceSn.equals(device.getDeviceSn())) result.add(device); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public static List<GatewayDevice> getCacheByDeviceType(String deviceType) { |
| | | List<GatewayDevice> result = new ArrayList<>(); |
| | |
| | | |
| | | public static void removeCache(GatewayDevice data) { |
| | | cacheMapDeviceId.remove(data.getDeviceId()); |
| | | cacheMapDeviceSn.remove(data.getDeviceSn()); |
| | | //cacheMapDeviceSn.remove(data.getDeviceSn()); |
| | | } |
| | | |
| | | public static String getStatus(String sn) { |