|
|
@@ -15,9 +15,11 @@ import com.xunmei.system.api.Eto.SubSystemControlEto;
|
|
|
import com.xunmei.system.api.util.LogUtils;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.socket.WebSocketSession;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
@@ -53,6 +55,7 @@ public class HostController {
|
|
|
websocketService.getDevices();
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation("布撤防控制")
|
|
|
@PostMapping({"/subSystemControl"})
|
|
|
public AjaxResult subSystemControl(@RequestBody SubSystemControlEto eto) {
|
|
|
@@ -78,10 +81,9 @@ public class HostController {
|
|
|
}*/
|
|
|
|
|
|
|
|
|
-
|
|
|
@ApiOperation("关闭iot链接")
|
|
|
@GetMapping({"/closeSession"})
|
|
|
- public AjaxResult closeSession(String iotCode){
|
|
|
+ public AjaxResult closeSession(String iotCode) {
|
|
|
//集群环境下 此功能不稳地,暂时取消
|
|
|
//WebSocketSessionHolder.closeServe(iotCode);
|
|
|
return AjaxResult.success();
|
|
|
@@ -144,14 +146,23 @@ public class HostController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/deletedRetryMsg/{date}")
|
|
|
- AjaxResult deletedRetryMsg(@PathVariable("date") String date){
|
|
|
+ AjaxResult deletedRetryMsg(@PathVariable("date") String date) {
|
|
|
websocketMsgService.deletedRetryMsg(date);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
@GetMapping("/hostInfo")
|
|
|
- AjaxResult hostInfo(){
|
|
|
- final Set<String> sessionsAll = WebSocketSessionHolder.getSessionsAll();
|
|
|
- return AjaxResult.success(sessionsAll);
|
|
|
+ AjaxResult hostInfo() {
|
|
|
+ Set<String> set = WebSocketSessionHolder.getSessionsAll();
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (String token : set) {
|
|
|
+ WebSocketSession sessions = WebSocketSessionHolder.getSessions(token);
|
|
|
+ if (sessions != null && sessions.isOpen()) {
|
|
|
+ list.add(token);
|
|
|
+ } else {
|
|
|
+ WebSocketSessionHolder.removeSession(token);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AjaxResult.success(list);
|
|
|
}
|
|
|
}
|