From f15b4feb486a85dcc3b9b5c68a8526957a6ad0bd Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期六, 18 十一月 2023 16:53:24 +0800 Subject: [PATCH] 调整车牌识别配置3 --- src/main/java/com/fzzy/gateway/GatewayUtils.java | 39 ++++++++++++++++++++++++++++++++++----- 1 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/fzzy/gateway/GatewayUtils.java b/src/main/java/com/fzzy/gateway/GatewayUtils.java index 655af00..0de33a5 100644 --- a/src/main/java/com/fzzy/gateway/GatewayUtils.java +++ b/src/main/java/com/fzzy/gateway/GatewayUtils.java @@ -1,15 +1,16 @@ package com.fzzy.gateway; +import com.fzzy.api.data.GatewayDeviceType; import com.fzzy.gateway.entity.GatewayDevice; +import org.springframework.stereotype.Component; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * 甯搁噺 */ +@Component public class GatewayUtils { - /** @@ -28,10 +29,20 @@ */ 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 GatewayDevice getCacheByDeviceId(String deviceId) { @@ -42,13 +53,26 @@ 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()); cacheMapDeviceSn.remove(data.getDeviceSn()); } - - public static void updateOnline(String deviceId) { contextOnlineMap.put(deviceId, "Y"); @@ -63,4 +87,9 @@ if (null == value || "N".equals(value)) return false; return true; } + + + public static Collection<GatewayDevice> listDeviceWeight(){ + return cacheMapDeviceWeight.values(); + } } -- Gitblit v1.9.3