Commit e4063260 authored by 耿迪迪's avatar 耿迪迪

异常问题修改 gengdidi

parent c0ee0f4c
package com.zehong.web.controller.websocket;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zehong.system.domain.TDeviceAlarm;
import com.zehong.system.domain.vo.DeviceAlarmVo;
import com.zehong.system.service.ITDeviceAlarmService;
import com.zehong.system.service.ITDeviceInfoService;
import com.zehong.system.service.ITPipeService;
import com.zehong.system.service.WebSocketServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/websocket")
public class WebSocketController {
private static final Logger log = LoggerFactory.getLogger(WebSocketController.class);
@Autowired
private WebSocketServer webSocketServer;
......@@ -34,7 +35,8 @@ public class WebSocketController {
@GetMapping("/send")
public void send(int alarmId){
TDeviceAlarm alarm = itDeviceAlarmService.selectTDeviceAlarmById(alarmId);
try {
DeviceAlarmVo alarm = itDeviceAlarmService.selectTDeviceAlarmById(alarmId);
JSONObject json = new JSONObject();
json.put("alarmInfo",alarm);
if(PIPE_TYPE.equals(alarm.getAlarmType())){
......@@ -43,5 +45,9 @@ public class WebSocketController {
json.put("deviceInfo",itDeviceInfoService.selectTDeviceInfoById(alarm.getDeviceId()));
}
webSocketServer.batchSendMessage(alarm.toString());
} catch (Exception e) {
log.error("wesocket发送失败!");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment