| | |
| | | package com.fzzy.gateway.hx2023; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import org.apache.commons.lang.math.RandomUtils; |
| | | |
| | | /** |
| | | * 常量 |
| | |
| | | public static String API_URL_AUTH = "${auth}/authorize/login"; |
| | | |
| | | |
| | | public static String MESSAGE_TYPE_REPORT_PROPERTY = "REPORT_PROPERTY"; |
| | | |
| | | public static String MESSAGE_TYPE_INVOKE_FUNCTION = "INVOKE_FUNCTION"; |
| | | |
| | | /** |
| | | * 设备在线标记,针对WEBSocket请求,控制设备是否在线,key = deviceId,Value=Y/N |
| | | * 粮情采指令 |
| | | */ |
| | | public static Map<String, String> contextOnlineMap = new HashMap<>(); |
| | | public static String FUNCTION_getTAndRHInfo = "getTAndRHInfo"; |
| | | |
| | | |
| | | public static void updateOnline(String deviceId) { |
| | | contextOnlineMap.put(deviceId, "Y"); |
| | | public static String getMessageId() { |
| | | return System.currentTimeMillis() + RandomUtils.nextInt(1000) + ""; |
| | | } |
| | | |
| | | public static void updateOffOnline(String deviceId) { |
| | | contextOnlineMap.put(deviceId, "N"); |
| | | } |
| | | |
| | | public static boolean isOnline(String deviceId) { |
| | | String value = contextOnlineMap.get(deviceId); |
| | | if (null == value || "N".equals(value)) return false; |
| | | return true; |
| | | } |
| | | public static int CODE_200 = 200; |
| | | |
| | | /** |
| | | * 下发指令回复报文topic |
| | | */ |
| | | public static String TOPIC_REPORT = "/${productId}/${deviceId}/properties/report"; |
| | | |
| | | /** |
| | | * 设备相关信息恢复报文-topic |
| | | */ |
| | | public static String TOPIC_MESSAGE_REPORT = "/device/${productId}/${deviceId}/message/property/report"; |
| | | |
| | | } |