|
@@ -5,6 +5,7 @@ import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.macro.mall.tiny.common.util.EprdmsHttpUtils;
|
|
|
import com.macro.mall.tiny.common.util.SpringUtils;
|
|
|
+import com.macro.mall.tiny.config.CustomSpringConfigurator;
|
|
|
import com.macro.mall.tiny.modules.business.dto.SensorListenParam;
|
|
|
import com.macro.mall.tiny.modules.business.service.RedisSubscribeListener;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.listener.ChannelTopic;
|
|
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.socket.server.standard.SpringConfigurator;
|
|
|
|
|
|
import javax.websocket.*;
|
|
|
import javax.websocket.server.ServerEndpoint;
|
|
@@ -20,7 +22,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
@Component
|
|
|
-@ServerEndpoint("/sensor/websocket")
|
|
|
+@ServerEndpoint(value = "/sensor/websocket", configurator = CustomSpringConfigurator.class)
|
|
|
@Slf4j
|
|
|
public class WebSocketServer {
|
|
|
|
|
@@ -45,8 +47,9 @@ public class WebSocketServer {
|
|
|
|
|
|
private RedisSubscribeListener subscribeListener;
|
|
|
|
|
|
- @Value("${keystar.eprdms.url:localhost:18060}")
|
|
|
+ @Value("${keystar.eprdms.url}")
|
|
|
private String eprdmsUrl;
|
|
|
+
|
|
|
private static final String OPEN_LISTEN_URL = "/eprdms/meteorology/sensor/start/listen";
|
|
|
private static final String CLOSE_LISTEN_URL = "/eprdms/meteorology/sensor/stop/listen";
|
|
|
private static final String GET_LISTEN_URL = "/eprdms/meteorology/sensor/current/listen";
|
|
@@ -187,7 +190,7 @@ public class WebSocketServer {
|
|
|
|
|
|
private void initSensorMac() {
|
|
|
HashMap<String, String> paramMap = new HashMap<>();
|
|
|
- paramMap.put("monitorClient", "COLLECT_DATA");
|
|
|
+ paramMap.put("monitorClient", "MONITOR_CLIENT_COLLECT");
|
|
|
JSONObject result = EprdmsHttpUtils.getForEprdms(eprdmsUrl + GET_LISTEN_URL + "?monitorClient={monitorClient}", paramMap, JSONObject.class);
|
|
|
if (result == null) return;
|
|
|
JSONArray listingMacList = result.getJSONArray("sensorMacs");
|