| | |
| | | return contextDeviceMap.get(sn); |
| | | } |
| | | |
| | | public static void updateCacheOnline(String sn, String ip, Integer port, boolean isCreate) { |
| | | ApiCommonDevice device = getCommonDeviceCache(sn); |
| | | if (null == device && isCreate) { |
| | | device = new ApiCommonDevice(); |
| | | public static ApiCommonDevice getCommonDeviceCacheByIp(String ip) { |
| | | if (null == ip) return null; |
| | | |
| | | if (contextDeviceMap.isEmpty()) return null; |
| | | |
| | | for (ApiCommonDevice device : contextDeviceMap.values()) { |
| | | if (ip.equals(device)) return device; |
| | | } |
| | | if (null != device) { |
| | | device.setIp(ip); |
| | | device.setPort(port); |
| | | device.setStatus(Constant.YN_Y); |
| | | device.setCode("SUCCESS"); |
| | | device.setMsg("设备在线"); |
| | | device.setSn(ip); |
| | | contextDeviceMap.put(device.getSn(), device); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static void updateCacheOffline(String sn, String ip, Integer port, boolean isCreate) { |
| | | ApiCommonDevice device = getCommonDeviceCache(sn); |
| | | public static ApiCommonDevice updateCacheOffline(String ip, Integer port) { |
| | | ApiCommonDevice device = getCommonDeviceCacheByIp(ip); |
| | | |
| | | if (null == device && isCreate) { |
| | | device = new ApiCommonDevice(); |
| | | if (null == device) { |
| | | return null; |
| | | } |
| | | device.setIp(ip); |
| | | device.setPort(port); |
| | | device.setStatus(Constant.YN_N); |
| | | device.setCode("ERROR"); |
| | | device.setMsg("设备离线"); |
| | | contextDeviceMap.put(device.getSn(), device); |
| | | |
| | | if (null != device) { |
| | | device.setIp(ip); |
| | | device.setPort(port); |
| | | device.setStatus(Constant.YN_N); |
| | | device.setCode("ERROR"); |
| | | device.setMsg("设备离线"); |
| | | |
| | | contextDeviceMap.put(device.getSn(), device); |
| | | } |
| | | return device; |
| | | } |
| | | |
| | | public static void updateCache(ApiCommonDevice device) { |