|
|
|
@ -2,16 +2,19 @@ package com.hnac.hzims.bigmodel.websocket.handler;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hnac.hzims.bigmodel.entity.FunctionEntity; |
|
|
|
|
import com.hnac.hzims.bigmodel.function.service.IFunctionService; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.StationSelectionVO; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.impl.JumpRouteJoinStrategy; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.impl.ParamStrategy; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.*; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
|
|
|
|
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; |
|
|
|
|
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
import org.springframework.web.socket.CloseStatus; |
|
|
|
|
import org.springframework.web.socket.TextMessage; |
|
|
|
|
import org.springframework.web.socket.WebSocketSession; |
|
|
|
@ -20,8 +23,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Author: huangxing |
|
|
|
@ -80,7 +82,13 @@ public class InteractiveHandler extends TextWebSocketHandler {
|
|
|
|
|
FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); |
|
|
|
|
switch (funcEnum) { |
|
|
|
|
case CHOOSE_STATION: |
|
|
|
|
this.handleChooseStation(messageContext,sessionId); |
|
|
|
|
this.handleDefaultChoose(messageContext,sessionId); |
|
|
|
|
break; |
|
|
|
|
case CHOOSE_VIDEO: |
|
|
|
|
this.handleVideoChoose(messageContext,sessionId); |
|
|
|
|
break; |
|
|
|
|
case CHOOSE_CANVAS: |
|
|
|
|
this.handleScadaChoose(messageContext,sessionId); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
@ -88,7 +96,7 @@ public class InteractiveHandler extends TextWebSocketHandler {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleChooseStation(JSONObject messageContext,String sessionId) { |
|
|
|
|
private void handleDefaultChoose(JSONObject messageContext,String sessionId) { |
|
|
|
|
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); |
|
|
|
|
String userId = messageContext.getString("userId"); |
|
|
|
|
String funcCode = messageContext.getString("funcCode"); |
|
|
|
@ -101,4 +109,63 @@ public class InteractiveHandler extends TextWebSocketHandler {
|
|
|
|
|
extra.put("data",data); |
|
|
|
|
interactiveService.specialAsk(sessionId,userId,extra); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleVideoChoose(JSONObject messageContext,String sessionId) { |
|
|
|
|
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); |
|
|
|
|
try { |
|
|
|
|
ParamStrategy strategy = SpringUtil.getBean(ParamStrategy.class); |
|
|
|
|
VideoSelectionVO selection = messageContext.getObject("selection", VideoSelectionVO.class); |
|
|
|
|
String videoId = selection.getId(); |
|
|
|
|
Map<String,String> param = new HashMap<>(1); |
|
|
|
|
param.put("canvas_id",videoId); |
|
|
|
|
ExtraVO videoExtras = strategy.getVideoExtra(param); |
|
|
|
|
AnswerVO answerVO = new AnswerVO(); |
|
|
|
|
answerVO.setSessionId(sessionId); |
|
|
|
|
answerVO.setQuery(selection.getName()); |
|
|
|
|
answerVO.setRunning(0); |
|
|
|
|
answerVO.setStatus(0); |
|
|
|
|
answerVO.setAnswer("已成功打开"+selection.getName()+"视频"); |
|
|
|
|
answerVO.setExtras(new Object[]{JSON.toJSONString(videoExtras)}); |
|
|
|
|
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); |
|
|
|
|
wsService.sendMessage(sessionId,textMessage); |
|
|
|
|
} |
|
|
|
|
catch (Exception e) { |
|
|
|
|
AnswerVO answerVO = new AnswerVO(); |
|
|
|
|
answerVO.setRunning(0); |
|
|
|
|
answerVO.setStatus(-2); |
|
|
|
|
answerVO.setAnswer("视频解析失败!"); |
|
|
|
|
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); |
|
|
|
|
wsService.sendMessage(sessionId,textMessage); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleScadaChoose(JSONObject messageContext,String sessionId) { |
|
|
|
|
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); |
|
|
|
|
try { |
|
|
|
|
JumpRouteJoinStrategy strategy = SpringUtil.getBean(JumpRouteJoinStrategy.class); |
|
|
|
|
ScadaSelectionVO selection = messageContext.getObject("selection", ScadaSelectionVO.class); |
|
|
|
|
Map<String,String> param = new HashMap<>(1); |
|
|
|
|
param.put("canvas_id",selection.getId()); |
|
|
|
|
IFunctionService functionService = SpringUtil.getBean(IFunctionService.class); |
|
|
|
|
FunctionEntity function = functionService.getFunctionByCode("open_scada"); |
|
|
|
|
ExtraVO scadaExtra = strategy.getScadaExtra(param, function); |
|
|
|
|
AnswerVO answerVO = new AnswerVO(); |
|
|
|
|
answerVO.setSessionId(sessionId); |
|
|
|
|
answerVO.setRunning(0); |
|
|
|
|
answerVO.setStatus(0); |
|
|
|
|
answerVO.setQuery(selection.getName()); |
|
|
|
|
answerVO.setAnswer("已成功打开"+selection.getName()+"实时画面"); |
|
|
|
|
answerVO.setExtras(new Object[]{JSON.toJSONString(scadaExtra)}); |
|
|
|
|
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); |
|
|
|
|
wsService.sendMessage(sessionId,textMessage); |
|
|
|
|
} |
|
|
|
|
catch (Exception e) { |
|
|
|
|
AnswerVO answerVO = new AnswerVO(); |
|
|
|
|
answerVO.setRunning(0); |
|
|
|
|
answerVO.setStatus(-2); |
|
|
|
|
answerVO.setAnswer("实时画面解析失败!"); |
|
|
|
|
TextMessage textMessage = InteractiveSessionManager.getTextMessage("1", JSON.toJSONString(answerVO)); |
|
|
|
|
wsService.sendMessage(sessionId,textMessage); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|