|
|
|
@ -80,119 +80,6 @@ public class InteractiveHandler extends TextWebSocketHandler {
|
|
|
|
|
QuestionHandlerService service = SpringUtil.getBean(QuestionHandlerService.class); |
|
|
|
|
service.handleMessage(messageDTO); |
|
|
|
|
} |
|
|
|
|
// JSONObject messageJSON = JSONObject.parseObject(message.getPayload());
|
|
|
|
|
// if("0".equals(messageJSON.getString("type"))) {
|
|
|
|
|
// // 接收心跳消息,返回一条心跳消息
|
|
|
|
|
// try {
|
|
|
|
|
// session.sendMessage(InteractiveSessionManager.getTextMessage("0","收到心跳消息"));
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// String sessionId = InteractiveSessionManager.getEntryBySession(session).getKey();
|
|
|
|
|
// if(messageJSON.containsKey("content")) {
|
|
|
|
|
// // 将发送参数存入redis
|
|
|
|
|
// redisTemplate.expire(RedisKeyConstants.SESSION_CONTENT_KEY,30, TimeUnit.MINUTES);
|
|
|
|
|
// redisTemplate.opsForHash().put(RedisKeyConstants.SESSION_CONTENT_KEY,sessionId,messageJSON.getObject("content", SessionContentVO.class));
|
|
|
|
|
// }
|
|
|
|
|
// this.handleMessage(messageJSON, sessionId);
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleMessage(JSONObject messageContext, String sessionId) { |
|
|
|
|
Boolean isSpecial = messageContext.getBoolean("isSpecial"); |
|
|
|
|
if (Func.isEmpty(isSpecial) || !isSpecial) { |
|
|
|
|
String context = messageContext.getString("context"); |
|
|
|
|
String userId = messageContext.getString("userId"); |
|
|
|
|
String knowledge = messageContext.getString("knowledge"); |
|
|
|
|
IHznlmInvokeService hznlmInvokeService = SpringUtil.getBean(IHznlmInvokeService.class); |
|
|
|
|
if (knowledge != null) { |
|
|
|
|
hznlmInvokeService.knowledgeAsk(context, sessionId, userId, knowledge); |
|
|
|
|
} else { |
|
|
|
|
hznlmInvokeService.ask(context, sessionId, userId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
String funcCode = messageContext.getString("func"); |
|
|
|
|
FuncRouteEnum funcEnum = FuncRouteEnum.getEnumByFuncCode(funcCode); |
|
|
|
|
switch (funcEnum) { |
|
|
|
|
case CHOOSE_STATION: |
|
|
|
|
case CHOOSE_YC: |
|
|
|
|
case CHOOSE_FAULT: |
|
|
|
|
case CHOOSE_YK: |
|
|
|
|
this.handleDefaultChoose(messageContext,sessionId); |
|
|
|
|
break; |
|
|
|
|
case CHOOSE_VIDEO: |
|
|
|
|
this.handleVideoChoose(messageContext,sessionId); |
|
|
|
|
break; |
|
|
|
|
case CHOOSE_CANVAS: |
|
|
|
|
this.handleScadaChoose(messageContext,sessionId); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleDefaultChoose(JSONObject messageContext,String sessionId) { |
|
|
|
|
IHznlmInvokeService invokeService = SpringUtil.getBean(IHznlmInvokeService.class); |
|
|
|
|
Map<String, Object> extra = messageContext.toJavaObject(Map.class); |
|
|
|
|
extra.put("func",extra.get("func")); |
|
|
|
|
extra.put("data",JSONObject.parseObject(JSON.toJSONString(extra.get("selection")))); |
|
|
|
|
invokeService.specialAsk(sessionId, (String) extra.get("userId"),extra); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleVideoChoose(JSONObject messageContext,String sessionId) { |
|
|
|
|
InteractiveWsService wsService = SpringUtil.getBean(InteractiveWsService.class); |
|
|
|
|
try { |
|
|
|
|
VideoSelectionVO selection = messageContext.getObject("selection", VideoSelectionVO.class); |
|
|
|
|
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_VIDEO.getFunc()); |
|
|
|
|
String videoId = selection.getItemId(); |
|
|
|
|
ExtraVO videoExtras = resolveService.resolve(videoId); |
|
|
|
|
AnswerVO answerVO = new AnswerVO(); |
|
|
|
|
answerVO.setSessionId(sessionId); |
|
|
|
|
answerVO.setQuery(selection.getItemName()); |
|
|
|
|
answerVO.setRunning(0); |
|
|
|
|
answerVO.setStatus(0); |
|
|
|
|
answerVO.setAnswer("已成功打开"+selection.getItemName()+"视频"); |
|
|
|
|
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 { |
|
|
|
|
ScadaSelectionVO selection = messageContext.getObject("selection", ScadaSelectionVO.class); |
|
|
|
|
IResolveService resolveService = ResolveFactory.getResolveService(FuncRouteEnum.OPEN_CANVAS.getFunc()); |
|
|
|
|
ExtraVO scadaExtra = resolveService.resolve(selection.getItemId()); |
|
|
|
|
AnswerVO answerVO = new AnswerVO(); |
|
|
|
|
answerVO.setSessionId(sessionId); |
|
|
|
|
answerVO.setRunning(0); |
|
|
|
|
answerVO.setStatus(0); |
|
|
|
|
answerVO.setQuery(selection.getItemName()); |
|
|
|
|
answerVO.setAnswer("已成功打开"+selection.getItemName()+"实时画面"); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|